From: Evgen Servetnik Date: Fri, 28 Jul 2017 10:26:26 +0000 (+0300) Subject: TizenRefApp-8953 Replace whitespaces to tabs X-Git-Tag: submit/tizen/20170803.142151~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=996f40969dc038f5ff60cc2dc20748f3f2a8bc40;p=profile%2Fwearable%2Fapps%2Fnative%2Fmessage.git TizenRefApp-8953 Replace whitespaces to tabs Change-Id: I4ca7617712e1e2a9f55afb10329a687f7dd891c4 Signed-off-by: Evgen Servetnik --- diff --git a/inc/Config.h b/inc/Config.h index 4cd5c2c..dcca5fc 100644 --- a/inc/Config.h +++ b/inc/Config.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -25,8 +25,8 @@ #define PROJECT_NAME "w-message" #endif -#ifdef LOGGER_TAG -#undef LOGGER_TAG +#ifdef LOGGER_TAG +#undef LOGGER_TAG #endif #define LOGGER_TAG "MESSAGES" diff --git a/inc/Resource.h b/inc/Resource.h index fcbc202..a434e10 100644 --- a/inc/Resource.h +++ b/inc/Resource.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -22,59 +22,59 @@ #define MORE_OPTION_DIR "More_option_icon" // Edj images: -#define ATTACH_VOICE_ICON "thread_view_msg_att_voice.png" -#define ATTACH_MUSIC_ICON "thread_view_msg_att_music.png" -#define ATTACH_CALENDAR_ICON "thread_view_msg_att_schedule.png" -#define ATTACH_CONTACT_ICON "thread_view_msg_att_vcf.png" -#define ATTACH_UNKNOWN_ICON "thread_view_msg_att_etc.png" +#define ATTACH_VOICE_ICON "thread_view_msg_att_voice.png" +#define ATTACH_MUSIC_ICON "thread_view_msg_att_music.png" +#define ATTACH_CALENDAR_ICON "thread_view_msg_att_schedule.png" +#define ATTACH_CONTACT_ICON "thread_view_msg_att_vcf.png" +#define ATTACH_UNKNOWN_ICON "thread_view_msg_att_etc.png" -#define NO_SPAM_MSG_ICON "No_item/msg_no_spam_messages.png" +#define NO_SPAM_MSG_ICON "No_item/msg_no_spam_messages.png" -#define NEW_MSG_MORE_ICON MORE_OPTION_DIR"/b_more_option_ic_compose.png" -#define DELETEG_MORE_ICON MORE_OPTION_DIR"/b_more_option_ic_delete.png" -#define ADD_TO_SPAM_MORE_ICON MORE_OPTION_DIR"/b_more_option_ic_add_to_spam.png" -#define REM_FROM_SPAM_MORE_ICON MORE_OPTION_DIR"/b_more_option_ic_remove_from_spam.png" -#define CALL_MORE_ICON MORE_OPTION_DIR"/b_more_option_ic_call.png" -#define DOWNLOAD_MORE_ICON MORE_OPTION_DIR"/b_more_option_ic_download.png" -#define RECIP_MORE_ICON MORE_OPTION_DIR"/b_more_option_ic_recipients.png" -#define REPLY_MORE_ICON MORE_OPTION_DIR"/b_more_option_ic_reply.png" -#define RESEND_MORE_ICON MORE_OPTION_DIR"/b_more_option_ic_resend.png" -#define RESTORE_MORE_ICON MORE_OPTION_DIR"/b_more_option_ic_restore.png" -#define SAVE_ATTACH_MORE_ICON MORE_OPTION_DIR"/b_more_option_ic_save_attachment.png" -#define SEND_TO_PHONE_MORE_ICON MORE_OPTION_DIR"/b_more_option_ic_send_to_phone.png" -#define SHARE_LOC_MORE_ICON MORE_OPTION_DIR"/b_more_option_ic_share_location.png" -#define SHOW_ON_DEV_MORE_ICON MORE_OPTION_DIR"/b_more_option_ic_showondevice.png" -#define VIEW_BY_ACCOUNT_MORE_ICON MORE_OPTION_DIR"/b_more_option_ic_viewbyaccount.png" +#define NEW_MSG_MORE_ICON MORE_OPTION_DIR"/b_more_option_ic_compose.png" +#define DELETEG_MORE_ICON MORE_OPTION_DIR"/b_more_option_ic_delete.png" +#define ADD_TO_SPAM_MORE_ICON MORE_OPTION_DIR"/b_more_option_ic_add_to_spam.png" +#define REM_FROM_SPAM_MORE_ICON MORE_OPTION_DIR"/b_more_option_ic_remove_from_spam.png" +#define CALL_MORE_ICON MORE_OPTION_DIR"/b_more_option_ic_call.png" +#define DOWNLOAD_MORE_ICON MORE_OPTION_DIR"/b_more_option_ic_download.png" +#define RECIP_MORE_ICON MORE_OPTION_DIR"/b_more_option_ic_recipients.png" +#define REPLY_MORE_ICON MORE_OPTION_DIR"/b_more_option_ic_reply.png" +#define RESEND_MORE_ICON MORE_OPTION_DIR"/b_more_option_ic_resend.png" +#define RESTORE_MORE_ICON MORE_OPTION_DIR"/b_more_option_ic_restore.png" +#define SAVE_ATTACH_MORE_ICON MORE_OPTION_DIR"/b_more_option_ic_save_attachment.png" +#define SEND_TO_PHONE_MORE_ICON MORE_OPTION_DIR"/b_more_option_ic_send_to_phone.png" +#define SHARE_LOC_MORE_ICON MORE_OPTION_DIR"/b_more_option_ic_share_location.png" +#define SHOW_ON_DEV_MORE_ICON MORE_OPTION_DIR"/b_more_option_ic_showondevice.png" +#define VIEW_BY_ACCOUNT_MORE_ICON MORE_OPTION_DIR"/b_more_option_ic_viewbyaccount.png" // Popup Images -#define CANCEL_BUTTON_POPUP "tw_ic_popup_btn_delete.png" -#define OK_BUTTON_POPUP "tw_ic_popup_btn_check.png" +#define CANCEL_BUTTON_POPUP "tw_ic_popup_btn_delete.png" +#define OK_BUTTON_POPUP "tw_ic_popup_btn_check.png" -#define FAIL_ICON "sent_fail_icon.png" +#define FAIL_ICON "sent_fail_icon.png" // Images(res): -#define THUMB_CONTACT_IMG_PATH IMAGE_PATH"/messages_list_thumb_image_single.png" -#define THUMB_GROUP_IMG_PATH IMAGE_PATH"/messages_list_thumb_image_multi.png" +#define THUMB_CONTACT_IMG_PATH IMAGE_PATH"/messages_list_thumb_image_single.png" +#define THUMB_GROUP_IMG_PATH IMAGE_PATH"/messages_list_thumb_image_multi.png" // Edj: -#define ICONS_EDJ_PATH EDJ_PATH"/icons.edj" -#define IMAGES_EDJ_PATH EDJ_PATH"/images.edj" +#define ICONS_EDJ_PATH EDJ_PATH"/icons.edj" +#define IMAGES_EDJ_PATH EDJ_PATH"/images.edj" -#define PREVIEW_MSG_THEME_EDJ_PATH EDJ_PATH"/preview_msg_genlist_theme.edj" -#define THREAD_COMPOSE_LIST_VIEW_ITEM EDJ_PATH"/thread_compose_list_view_item.edj" -#define SENDING_OPTION_LIST_VIEW_ITEM EDJ_PATH"/sending_option_list_view_item.edj" -#define THUMBNAIL_EDJ_PATH EDJ_PATH"/msg_thumbnail.edj" -#define DEFAULT_LAYOUT_EDJ_PATH EDJ_PATH"/default_layout.edj" -#define RECIP_LAYOUT_EDJ_PATH EDJ_PATH"/recip_layout.edj" -#define RECIP_ENTRY_EDJ_PATH EDJ_PATH"/recip_entry.edj" -#define MSG_BODY_EDJ_PATH EDJ_PATH"/msg_body.edj" -#define SEARCH_BAR_EDJ_PATH EDJ_PATH"/search_bar.edj" -#define COMMON_GENLIST_THEME_EDJ_PATH EDJ_PATH"/common_genlist_theme.edj" -#define CONV_GENLIST_THEME_EDJ_PATH EDJ_PATH"/conv_genlist_theme.edj" -#define INPUT_LAYOUT_EDJ_PATH EDJ_PATH"/input_layout.edj" -#define CONV_LIST_BUBBLE_EDJ_PATH EDJ_PATH"/conv_list_bubble.edj" -#define POPUP_EDJ_PATH EDJ_PATH"/popup.edj" +#define PREVIEW_MSG_THEME_EDJ_PATH EDJ_PATH"/preview_msg_genlist_theme.edj" +#define THREAD_COMPOSE_LIST_VIEW_ITEM EDJ_PATH"/thread_compose_list_view_item.edj" +#define SENDING_OPTION_LIST_VIEW_ITEM EDJ_PATH"/sending_option_list_view_item.edj" +#define THUMBNAIL_EDJ_PATH EDJ_PATH"/msg_thumbnail.edj" +#define DEFAULT_LAYOUT_EDJ_PATH EDJ_PATH"/default_layout.edj" +#define RECIP_LAYOUT_EDJ_PATH EDJ_PATH"/recip_layout.edj" +#define RECIP_ENTRY_EDJ_PATH EDJ_PATH"/recip_entry.edj" +#define MSG_BODY_EDJ_PATH EDJ_PATH"/msg_body.edj" +#define SEARCH_BAR_EDJ_PATH EDJ_PATH"/search_bar.edj" +#define COMMON_GENLIST_THEME_EDJ_PATH EDJ_PATH"/common_genlist_theme.edj" +#define CONV_GENLIST_THEME_EDJ_PATH EDJ_PATH"/conv_genlist_theme.edj" +#define INPUT_LAYOUT_EDJ_PATH EDJ_PATH"/input_layout.edj" +#define CONV_LIST_BUBBLE_EDJ_PATH EDJ_PATH"/conv_list_bubble.edj" +#define POPUP_EDJ_PATH EDJ_PATH"/popup.edj" #endif /* RESOURCE_H_ */ diff --git a/src/Common/AppControl/inc/AppControlCommand.h b/src/Common/AppControl/inc/AppControlCommand.h index ccd706e..7afae28 100644 --- a/src/Common/AppControl/inc/AppControlCommand.h +++ b/src/Common/AppControl/inc/AppControlCommand.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -22,37 +22,37 @@ #include namespace Msg { - class AppControlCommand; - typedef std::shared_ptr AppControlCommandRef; - - class AppControlCommand { - public: - enum OperationType - { - OpUnknown, - OpDefault, - OpComposeFamily, /** For operations Compose, Share, MultiShare and ShareText */ - OpSettings - }; - - public: - AppControlCommand(const std::string &opMsg, OperationType type); - virtual ~AppControlCommand(); - - /** - *@brief Get raw operation string. - */ - const std::string &getOperationMsg() const; - - /** - *@brief Get operation type. - */ - OperationType getOperationType() const; - - private: - std::string m_OperationMsg; - OperationType m_OperationType; - }; + class AppControlCommand; + typedef std::shared_ptr AppControlCommandRef; + + class AppControlCommand { + public: + enum OperationType + { + OpUnknown, + OpDefault, + OpComposeFamily, /** For operations Compose, Share, MultiShare and ShareText */ + OpSettings + }; + + public: + AppControlCommand(const std::string &opMsg, OperationType type); + virtual ~AppControlCommand(); + + /** + *@brief Get raw operation string. + */ + const std::string &getOperationMsg() const; + + /** + *@brief Get operation type. + */ + OperationType getOperationType() const; + + private: + std::string m_OperationMsg; + OperationType m_OperationType; + }; } #endif /* AppControlCommand_h_ */ diff --git a/src/Common/AppControl/inc/AppControlCompose.h b/src/Common/AppControl/inc/AppControlCompose.h index b696551..e1b36fd 100644 --- a/src/Common/AppControl/inc/AppControlCompose.h +++ b/src/Common/AppControl/inc/AppControlCompose.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -23,87 +23,87 @@ #include namespace Msg { - class AppControlCompose; - typedef std::shared_ptr AppControlComposeRef; - - struct VcfInfo { - std::list contactsIdList; - bool isMyProfile; - }; - - class AppControlCompose - : public AppControlCommand { - public: - typedef std::list RecipientList; - typedef std::list FileList; - - enum OpComposeType - { - OpUnknown, - OpCompose, /** APP_CONTROL_OPERATION_COMPOSE */ - OpShare, /** APP_CONTROL_OPERATION_SHARE */ - OpMultiShare, /** APP_CONTROL_OPERATION_MULTI_SHARE */ - OpShareText /** APP_CONTROL_OPERATION_SHARE_TEXT */ - }; - - public: - AppControlCompose(const std::string &opMsg, app_control_h handle); - virtual ~AppControlCompose(); - - /** - *@brief Gets compose type. - */ - OpComposeType getComposeType() const; - - /** - *@brief Gets data from APP_CONTROL_DATA_TO or URI(if exists). - */ - const RecipientList &getRecipientList() const; - - /** - *@brief Checks if is MMS. - */ - bool isMms() const; - - /** - *@brief Gets data from APP_CONTROL_DATA_TEXT. - */ - const std::string &getMessageText() const; - - /** - *@brief Gets data from APP_CONTROL_DATA_SUBJECT. - */ - const std::string &getMessageSubject() const; - - /** - *@brief Gets data from APP_CONTROL_DATA_PATH or URI(if exists). - */ - const FileList &getFileList() const; - - /** - *@brief Gets vcf info from APP_CONTROL_DATA_ID - */ - const VcfInfo &getVcfInfo() const; - - private: - bool parseUriCompose(app_control_h handle); - bool parseUriShare(app_control_h handle); - - void createComposeOp(app_control_h handle); - void createShareOp(app_control_h handle); - void createMultiShareOp(app_control_h handle); - void createShareTextOp(app_control_h handle); - void readRecipients(app_control_h handle); - - private: - OpComposeType m_ComposeType; - RecipientList m_RecipientList; - bool m_isMms; - FileList m_FileList; - std::string m_MessageText; - std::string m_Subject; - VcfInfo m_VcfInfo; - }; + class AppControlCompose; + typedef std::shared_ptr AppControlComposeRef; + + struct VcfInfo { + std::list contactsIdList; + bool isMyProfile; + }; + + class AppControlCompose + : public AppControlCommand { + public: + typedef std::list RecipientList; + typedef std::list FileList; + + enum OpComposeType + { + OpUnknown, + OpCompose, /** APP_CONTROL_OPERATION_COMPOSE */ + OpShare, /** APP_CONTROL_OPERATION_SHARE */ + OpMultiShare, /** APP_CONTROL_OPERATION_MULTI_SHARE */ + OpShareText /** APP_CONTROL_OPERATION_SHARE_TEXT */ + }; + + public: + AppControlCompose(const std::string &opMsg, app_control_h handle); + virtual ~AppControlCompose(); + + /** + *@brief Gets compose type. + */ + OpComposeType getComposeType() const; + + /** + *@brief Gets data from APP_CONTROL_DATA_TO or URI(if exists). + */ + const RecipientList &getRecipientList() const; + + /** + *@brief Checks if is MMS. + */ + bool isMms() const; + + /** + *@brief Gets data from APP_CONTROL_DATA_TEXT. + */ + const std::string &getMessageText() const; + + /** + *@brief Gets data from APP_CONTROL_DATA_SUBJECT. + */ + const std::string &getMessageSubject() const; + + /** + *@brief Gets data from APP_CONTROL_DATA_PATH or URI(if exists). + */ + const FileList &getFileList() const; + + /** + *@brief Gets vcf info from APP_CONTROL_DATA_ID + */ + const VcfInfo &getVcfInfo() const; + + private: + bool parseUriCompose(app_control_h handle); + bool parseUriShare(app_control_h handle); + + void createComposeOp(app_control_h handle); + void createShareOp(app_control_h handle); + void createMultiShareOp(app_control_h handle); + void createShareTextOp(app_control_h handle); + void readRecipients(app_control_h handle); + + private: + OpComposeType m_ComposeType; + RecipientList m_RecipientList; + bool m_isMms; + FileList m_FileList; + std::string m_MessageText; + std::string m_Subject; + VcfInfo m_VcfInfo; + }; } #endif /* AppControlCompose_h_ */ diff --git a/src/Common/AppControl/inc/AppControlDefault.h b/src/Common/AppControl/inc/AppControlDefault.h index 0fe567b..24fcf8f 100644 --- a/src/Common/AppControl/inc/AppControlDefault.h +++ b/src/Common/AppControl/inc/AppControlDefault.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -23,42 +23,42 @@ #include namespace Msg { - class AppControlDefault; - typedef std::shared_ptr AppControlDefaultRef; + class AppControlDefault; + typedef std::shared_ptr AppControlDefaultRef; - class AppControlDefault - : public AppControlCommand { - public: - enum DefaultType - { - UnknownType, - MainType, //Type from home screen - ReplyType, //Type for reply message button clicked from Active Notification - ViewType, //Type for view message button clicked from Active Notification - NotificationType, //Type from notification panel - SendFailedType //Send failed message type from notification panel - }; + class AppControlDefault + : public AppControlCommand { + public: + enum DefaultType + { + UnknownType, + MainType, //Type from home screen + ReplyType, //Type for reply message button clicked from Active Notification + ViewType, //Type for view message button clicked from Active Notification + NotificationType, //Type from notification panel + SendFailedType //Send failed message type from notification panel + }; - public: - AppControlDefault(const std::string &opMsg, app_control_h handle); - virtual ~AppControlDefault(); + public: + AppControlDefault(const std::string &opMsg, app_control_h handle); + virtual ~AppControlDefault(); - MsgId getMessageId() const; - DefaultType getDefaultType() const; - const std::string& getReplyText() const; + MsgId getMessageId() const; + DefaultType getDefaultType() const; + const std::string& getReplyText() const; - private: - bool isNotificationPanel(app_control_h handle) const; - void parse(app_control_h handle); - void replyMessage(app_control_h handle); - void viewMessage(app_control_h handle); - void makeReplyText(app_control_h handle); + private: + bool isNotificationPanel(app_control_h handle) const; + void parse(app_control_h handle); + void replyMessage(app_control_h handle); + void viewMessage(app_control_h handle); + void makeReplyText(app_control_h handle); - private: - MsgId m_MsgId; - DefaultType m_DefaultType; - std::string m_ReplyText; - }; + private: + MsgId m_MsgId; + DefaultType m_DefaultType; + std::string m_ReplyText; + }; } #endif /* AppControlDefault_h_ */ diff --git a/src/Common/AppControl/inc/AppControlHandle.h b/src/Common/AppControl/inc/AppControlHandle.h index 22ead32..aa95709 100644 --- a/src/Common/AppControl/inc/AppControlHandle.h +++ b/src/Common/AppControl/inc/AppControlHandle.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -21,52 +21,52 @@ namespace Msg { - class AppControlLauncher; + class AppControlLauncher; - class AppControlHandle { + class AppControlHandle { - friend class AppControlLauncher; + friend class AppControlLauncher; - public: - AppControlHandle(app_control_launch_mode_e launchMode = APP_CONTROL_LAUNCH_MODE_GROUP); - virtual ~AppControlHandle(); + public: + AppControlHandle(app_control_launch_mode_e launchMode = APP_CONTROL_LAUNCH_MODE_GROUP); + virtual ~AppControlHandle(); - /** - *@brief Terminate launch request related with this handle. - */ - void terminate(); + /** + *@brief Terminate launch request related with this handle. + */ + void terminate(); - /** - *@brief Sends the launch request. - *@return bool is launch success, false otherwise - */ - bool launch(); + /** + *@brief Sends the launch request. + *@return bool is launch success, false otherwise + */ + bool launch(); - /** - *@brief Returns internal handle to app_control_h - */ - operator app_control_h(); + /** + *@brief Returns internal handle to app_control_h + */ + operator app_control_h(); - bool isGroupMode() const; - void setOperation(const char *operation); - void setAppId(const char *id); - void setUri(const char *uri); - void setMime(const char *mime); - void setLaunchMode(app_control_launch_mode_e mode); - void addExtraData(const char *key, const char *data); - void removeExtraData(const char *key); + bool isGroupMode() const; + void setOperation(const char *operation); + void setAppId(const char *id); + void setUri(const char *uri); + void setMime(const char *mime); + void setLaunchMode(app_control_launch_mode_e mode); + void addExtraData(const char *key, const char *data); + void removeExtraData(const char *key); - protected: - virtual void onReply(app_control_h request, app_control_h reply, app_control_result_e result); + protected: + virtual void onReply(app_control_h request, app_control_h reply, app_control_result_e result); - AppControlLauncher &getLauncher(); + AppControlLauncher &getLauncher(); - AppControlHandle(const AppControlHandle&) = delete; - AppControlHandle& operator=(AppControlHandle) = delete; + AppControlHandle(const AppControlHandle&) = delete; + AppControlHandle& operator=(AppControlHandle) = delete; - protected: - app_control_h m_Handle; - }; + protected: + app_control_h m_Handle; + }; } #endif /* AppControlHandle_h_ */ diff --git a/src/Common/AppControl/inc/AppControlLauncher.h b/src/Common/AppControl/inc/AppControlLauncher.h index d4391ff..fd7bb41 100644 --- a/src/Common/AppControl/inc/AppControlLauncher.h +++ b/src/Common/AppControl/inc/AppControlLauncher.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -22,45 +22,45 @@ #include namespace Msg { - class AppControlLauncher { + class AppControlLauncher { - friend class AppControlHandle; + friend class AppControlHandle; - public: - AppControlLauncher(); - ~AppControlLauncher(); + public: + AppControlLauncher(); + ~AppControlLauncher(); - /** - *@brief Launch application by AppControlHandle - *@param handle for launch - *@return true if launch is success, false otherwise - */ - bool launch(AppControlHandle &handle); + /** + *@brief Launch application by AppControlHandle + *@param handle for launch + *@return true if launch is success, false otherwise + */ + bool launch(AppControlHandle &handle); - /** - *@brief Terminate current launch request. - */ - void terminate(); + /** + *@brief Terminate current launch request. + */ + void terminate(); - /** - *@brief Gets current launch status - *@return true if launch process in progress, false otherwise - */ - bool isLaunchInProgress() const; + /** + *@brief Gets current launch status + *@return true if launch process in progress, false otherwise + */ + bool isLaunchInProgress() const; - AppControlHandle *getHandle() const; + AppControlHandle *getHandle() const; - private: - AppControlLauncher(const AppControlLauncher&) = delete; - AppControlLauncher& operator=(const AppControlLauncher&) = delete; + private: + AppControlLauncher(const AppControlLauncher&) = delete; + AppControlLauncher& operator=(const AppControlLauncher&) = delete; - void onReply(app_control_h request, app_control_h reply, app_control_result_e result); + void onReply(app_control_h request, app_control_h reply, app_control_result_e result); - private: - bool m_LaunchInProgress; - Ecore_Timer *m_pTimer; - AppControlHandle *m_pHandle; - }; + private: + bool m_LaunchInProgress; + Ecore_Timer *m_pTimer; + AppControlHandle *m_pHandle; + }; } #endif /* AppControlLauncher_h_ */ diff --git a/src/Common/AppControl/inc/AppControlParser.h b/src/Common/AppControl/inc/AppControlParser.h index 483d0c9..3ae982e 100644 --- a/src/Common/AppControl/inc/AppControlParser.h +++ b/src/Common/AppControl/inc/AppControlParser.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -22,10 +22,10 @@ namespace Msg { - class AppControlParser { - public: - static AppControlCommandRef parse(app_control_h handle); - }; + class AppControlParser { + public: + static AppControlCommandRef parse(app_control_h handle); + }; } #endif /* AppControlParser_h_ */ diff --git a/src/Common/AppControl/inc/AppControlSettings.h b/src/Common/AppControl/inc/AppControlSettings.h index 0ba91e2..96ccacc 100644 --- a/src/Common/AppControl/inc/AppControlSettings.h +++ b/src/Common/AppControl/inc/AppControlSettings.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -20,31 +20,31 @@ #include "AppControlCommand.h" namespace Msg { - class AppControlSettings; - typedef std::shared_ptr AppControlSettingsRef; - - class AppControlSettings - : public AppControlCommand { - public: - AppControlSettings(const std::string &opMsg, app_control_h handle); - virtual ~AppControlSettings(); - - static constexpr const char* getOpName(); - }; - - inline AppControlSettings::AppControlSettings(const std::string &opMsg, app_control_h handle) - : AppControlCommand(opMsg, OpSettings) - { - } - - inline AppControlSettings::~AppControlSettings() - { - } - - inline constexpr const char* AppControlSettings::getOpName() - { - return "http://tizen.org/appcontrol/operation/setting/messages"; - } + class AppControlSettings; + typedef std::shared_ptr AppControlSettingsRef; + + class AppControlSettings + : public AppControlCommand { + public: + AppControlSettings(const std::string &opMsg, app_control_h handle); + virtual ~AppControlSettings(); + + static constexpr const char* getOpName(); + }; + + inline AppControlSettings::AppControlSettings(const std::string &opMsg, app_control_h handle) + : AppControlCommand(opMsg, OpSettings) + { + } + + inline AppControlSettings::~AppControlSettings() + { + } + + inline constexpr const char* AppControlSettings::getOpName() + { + return "http://tizen.org/appcontrol/operation/setting/messages"; + } } #endif /* AppControlSettings_h_ */ diff --git a/src/Common/AppControl/inc/AppControlUtils.h b/src/Common/AppControl/inc/AppControlUtils.h index 1c67d37..9413825 100644 --- a/src/Common/AppControl/inc/AppControlUtils.h +++ b/src/Common/AppControl/inc/AppControlUtils.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -22,37 +22,37 @@ #include namespace Msg { - namespace AppControlUtils { - /** - *@brief Gets a single string from given app-control handle by a key specified - */ - std::string getExtraData(app_control_h handle, const std::string &key); - - /** - *@brief Gets a string-array from given app-control handle by a key specified - */ - std::list getExtraDataArray(app_control_h handle, const std::string &key); - - /** - *@brief Gets a single int number from given app-control handle by a key specified. - */ - int getExtraDataInt(app_control_h handle, const std::string &key); - - /** - *@brief Gets an int-array from given app-control handle by a key specified. - */ - std::list getExtraDataIntArray(app_control_h handle, const std::string &key); - - /** - *@brief Gets a single mime type string from given app-control handle. - */ - std::string getMimeType(app_control_h handle); - - /** - *@brief Gets application id - */ - std::string getAppId(app_control_h handle); - }; + namespace AppControlUtils { + /** + *@brief Gets a single string from given app-control handle by a key specified + */ + std::string getExtraData(app_control_h handle, const std::string &key); + + /** + *@brief Gets a string-array from given app-control handle by a key specified + */ + std::list getExtraDataArray(app_control_h handle, const std::string &key); + + /** + *@brief Gets a single int number from given app-control handle by a key specified. + */ + int getExtraDataInt(app_control_h handle, const std::string &key); + + /** + *@brief Gets an int-array from given app-control handle by a key specified. + */ + std::list getExtraDataIntArray(app_control_h handle, const std::string &key); + + /** + *@brief Gets a single mime type string from given app-control handle. + */ + std::string getMimeType(app_control_h handle); + + /** + *@brief Gets application id + */ + std::string getAppId(app_control_h handle); + }; } #endif /* AppControlUtils_h_ */ diff --git a/src/Common/AppControl/inc/ContactEditor.h b/src/Common/AppControl/inc/ContactEditor.h index bf04a9c..354c7dc 100644 --- a/src/Common/AppControl/inc/ContactEditor.h +++ b/src/Common/AppControl/inc/ContactEditor.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -22,33 +22,33 @@ #include namespace Msg { - class IContactEditorListener; - - /** - *@brief An utility-class aimed to launch contacts-application with add-operation and edit-operation passed via app-control. - */ - class ContactEditor - : public AppControlHandle { - public: - enum Operation - { - EditOp, - CreateOp - }; - - public: - ContactEditor(); - virtual ~ContactEditor(); - - /** - * @brief Launches add-operation. - * @param[in] address number or email - * @return true in case of success, otherwise returns false. - */ - bool launch(const std::string &address, Operation operation); - private: - bool launch(const std::string &address, const char *operation, const char *addressType); - }; + class IContactEditorListener; + + /** + *@brief An utility-class aimed to launch contacts-application with add-operation and edit-operation passed via app-control. + */ + class ContactEditor + : public AppControlHandle { + public: + enum Operation + { + EditOp, + CreateOp + }; + + public: + ContactEditor(); + virtual ~ContactEditor(); + + /** + * @brief Launches add-operation. + * @param[in] address number or email + * @return true in case of success, otherwise returns false. + */ + bool launch(const std::string &address, Operation operation); + private: + bool launch(const std::string &address, const char *operation, const char *addressType); + }; } #endif /* ContactEditor */ diff --git a/src/Common/AppControl/inc/ContactPicker.h b/src/Common/AppControl/inc/ContactPicker.h index f8ad8ce..a65b61d 100644 --- a/src/Common/AppControl/inc/ContactPicker.h +++ b/src/Common/AppControl/inc/ContactPicker.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -23,51 +23,51 @@ #include namespace Msg { - class IContactPickerListener; + class IContactPickerListener; - /** - * @brief An utility-class aimed to launch contacts-application with pick-operation passed via app-control. - */ - class ContactPicker - : public AppControlHandle { + /** + * @brief An utility-class aimed to launch contacts-application with pick-operation passed via app-control. + */ + class ContactPicker + : public AppControlHandle { - public: - ContactPicker(); + public: + ContactPicker(); - /** - * @brief Sets a listener-object to be notified when pick-operation succeeds. - */ - void setListener(IContactPickerListener *pListener); + /** + * @brief Sets a listener-object to be notified when pick-operation succeeds. + */ + void setListener(IContactPickerListener *pListener); - /** - * @brief Launches pick-operation. - * @param howManyToPick defines a maximum count of contacts allowed to be picked. - * @return true in case of success, otherwise returns false. - */ - bool launch(size_t howManyToPick); + /** + * @brief Launches pick-operation. + * @param howManyToPick defines a maximum count of contacts allowed to be picked. + * @return true in case of success, otherwise returns false. + */ + bool launch(size_t howManyToPick); - private: - virtual void onReply(app_control_h request, app_control_h reply, app_control_result_e result); + private: + virtual void onReply(app_control_h request, app_control_h reply, app_control_result_e result); - private: - IContactPickerListener *m_pListener; - }; + private: + IContactPickerListener *m_pListener; + }; - class IContactPickerListener { - public: - enum AddressType { - PhoneType, - EmailType // NotSupported - }; - struct ResultData { - AddressType type; - int id; - }; + class IContactPickerListener { + public: + enum AddressType { + PhoneType, + EmailType // NotSupported + }; + struct ResultData { + AddressType type; + int id; + }; - public: - virtual ~IContactPickerListener() {} - virtual void onContactsPicked(const std::list &numberIdList) {}; - }; + public: + virtual ~IContactPickerListener() {} + virtual void onContactsPicked(const std::list &numberIdList) {}; + }; } #endif /* ContactPicker_h_ */ diff --git a/src/Common/AppControl/inc/ContactViewer.h b/src/Common/AppControl/inc/ContactViewer.h index d5f8023..97d27b3 100644 --- a/src/Common/AppControl/inc/ContactViewer.h +++ b/src/Common/AppControl/inc/ContactViewer.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -21,40 +21,40 @@ #include "ContactAddress.h" namespace Msg { - /** - *@brief An utility-class aimed to launch contacts-application with view-operation passed via app-control. - */ - class ContactViewer - : public AppControlHandle { - public: - ContactViewer(); - virtual ~ContactViewer(); - - /** - * @brief Launches view-operation. - * @param[in] address reference to ContactAddress object. - * @return true in case of success, otherwise returns false. - */ - bool launch(const ContactAddress &address); - - /** - * @brief Launches view-operation. - * @param[in] string address (phone) - * @return true in case of success, otherwise returns false. - */ - bool launch(const std::string &address); - - /** - * @brief Launches view-operation. - * @return true in case of success, otherwise returns false. - */ - bool launch(); - - private: - bool launchPrivate(const ContactAddress &address); - void clear(); - const char *toStr(ContactAddress::OwnerType type); - }; + /** + *@brief An utility-class aimed to launch contacts-application with view-operation passed via app-control. + */ + class ContactViewer + : public AppControlHandle { + public: + ContactViewer(); + virtual ~ContactViewer(); + + /** + * @brief Launches view-operation. + * @param[in] address reference to ContactAddress object. + * @return true in case of success, otherwise returns false. + */ + bool launch(const ContactAddress &address); + + /** + * @brief Launches view-operation. + * @param[in] string address (phone) + * @return true in case of success, otherwise returns false. + */ + bool launch(const std::string &address); + + /** + * @brief Launches view-operation. + * @return true in case of success, otherwise returns false. + */ + bool launch(); + + private: + bool launchPrivate(const ContactAddress &address); + void clear(); + const char *toStr(ContactAddress::OwnerType type); + }; } #endif /* ContactViewer_h_ */ diff --git a/src/Common/AppControl/inc/FileViewer.h b/src/Common/AppControl/inc/FileViewer.h index 1b01b25..0b10140 100644 --- a/src/Common/AppControl/inc/FileViewer.h +++ b/src/Common/AppControl/inc/FileViewer.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -20,18 +20,18 @@ #include "AppControlLauncher.h" namespace Msg { - class FileViewer - : public AppControlHandle { - public: - FileViewer(); - virtual ~FileViewer(); + class FileViewer + : public AppControlHandle { + public: + FileViewer(); + virtual ~FileViewer(); - bool launch(const std::string &file); - bool launchWithCopy(const std::string &file); + bool launch(const std::string &file); + bool launchWithCopy(const std::string &file); - private: - std::string m_FilePath; - }; + private: + std::string m_FilePath; + }; } #endif /* FileViewer_h_ */ diff --git a/src/Common/AppControl/inc/InputSelector.h b/src/Common/AppControl/inc/InputSelector.h index 1e89292..33df016 100644 --- a/src/Common/AppControl/inc/InputSelector.h +++ b/src/Common/AppControl/inc/InputSelector.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -23,49 +23,49 @@ #include namespace Msg { - class IInputSelectorListener; + class IInputSelectorListener; - class InputSelector - : public AppControlHandle { + class InputSelector + : public AppControlHandle { - public: - enum InputType { - VoiceType, - EmoticonType, - KeyboardType - }; + public: + enum InputType { + VoiceType, + EmoticonType, + KeyboardType + }; - public: - InputSelector(); - virtual ~InputSelector(); + public: + InputSelector(); + virtual ~InputSelector(); - void setListener(IInputSelectorListener *l); - void setText(const std::string &text); - bool launch(InputType type); - bool launch(); + void setListener(IInputSelectorListener *l); + void setText(const std::string &text); + bool launch(InputType type); + bool launch(); - protected: - virtual void onKeyboardReply(const std::string &text) {}; - virtual void onTemplateReply(const std::string &text) {}; - virtual void onVoiceReply(const std::string &text, const std::list &filePath) {}; - virtual void onEmoticonReply(const std::string &emoticon) {}; - virtual void onTerminate() {}; + protected: + virtual void onKeyboardReply(const std::string &text) {}; + virtual void onTemplateReply(const std::string &text) {}; + virtual void onVoiceReply(const std::string &text, const std::list &filePath) {}; + virtual void onEmoticonReply(const std::string &emoticon) {}; + virtual void onTerminate() {}; - void terminateHandler(); + void terminateHandler(); - private: - void onReply(app_control_h request, app_control_h reply, app_control_result_e result) override; - void clear(); + private: + void onReply(app_control_h request, app_control_h reply, app_control_result_e result) override; + void clear(); - private: - IInputSelectorListener *m_pListener; - }; + private: + IInputSelectorListener *m_pListener; + }; - class IInputSelectorListener { - public: - virtual ~IInputSelectorListener() {} - virtual void onTerminate(InputSelector &) {}; - }; + class IInputSelectorListener { + public: + virtual ~IInputSelectorListener() {} + virtual void onTerminate(InputSelector &) {}; + }; } #endif /* InputSelector_h_ */ diff --git a/src/Common/AppControl/inc/SettingsLauncher.h b/src/Common/AppControl/inc/SettingsLauncher.h index e7a711b..638f814 100644 --- a/src/Common/AppControl/inc/SettingsLauncher.h +++ b/src/Common/AppControl/inc/SettingsLauncher.h @@ -20,12 +20,12 @@ #include "AppControlLauncher.h" namespace Msg { - class SettingsLauncher - : public AppControlHandle { + class SettingsLauncher + : public AppControlHandle { - public: - bool launchConnections(); - }; + public: + bool launchConnections(); + }; } #endif /* SettingsLauncher_h_ */ diff --git a/src/Common/AppControl/inc/Share.h b/src/Common/AppControl/inc/Share.h index ca972b1..4cef95f 100644 --- a/src/Common/AppControl/inc/Share.h +++ b/src/Common/AppControl/inc/Share.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -23,22 +23,22 @@ #include namespace Msg { - class Share - : public AppControlHandle { - public: - Share(); - virtual ~Share(); - - bool launch(const std::list &files); - bool launch(const std::string &text); - - private: - void removeFiles(); - void addFiles(const std::list &files); - - private: - std::list m_FileList; - }; + class Share + : public AppControlHandle { + public: + Share(); + virtual ~Share(); + + bool launch(const std::list &files); + bool launch(const std::string &text); + + private: + void removeFiles(); + void addFiles(const std::list &files); + + private: + std::list m_FileList; + }; } #endif /* Share_h_ */ diff --git a/src/Common/AppControl/inc/VoiceCall.h b/src/Common/AppControl/inc/VoiceCall.h index 8a6877b..2e43f6f 100644 --- a/src/Common/AppControl/inc/VoiceCall.h +++ b/src/Common/AppControl/inc/VoiceCall.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -21,24 +21,24 @@ #include namespace Msg { - /** - * @brief An utility-class aimed to make voice call passed via app-control. - */ - class VoiceCall { - public: - VoiceCall(); + /** + * @brief An utility-class aimed to make voice call passed via app-control. + */ + class VoiceCall { + public: + VoiceCall(); - /** - * @brief Launches call by number - * @param[in] number Contact person number - * @return true in case of success, otherwise returns false. - */ - static bool launch(const std::string &number); + /** + * @brief Launches call by number + * @param[in] number Contact person number + * @return true in case of success, otherwise returns false. + */ + static bool launch(const std::string &number); - private: - VoiceCall(const VoiceCall&) = delete; - VoiceCall& operator=(const VoiceCall&) = delete; - }; + private: + VoiceCall(const VoiceCall&) = delete; + VoiceCall& operator=(const VoiceCall&) = delete; + }; } #endif /* VoiceCall_h_ */ diff --git a/src/Common/AppControl/src/AppControlCommand.cpp b/src/Common/AppControl/src/AppControlCommand.cpp index 9dbefb7..8a2f87d 100644 --- a/src/Common/AppControl/src/AppControlCommand.cpp +++ b/src/Common/AppControl/src/AppControlCommand.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -19,8 +19,8 @@ using namespace Msg; AppControlCommand::AppControlCommand(const std::string &opMsg, OperationType type) - : m_OperationMsg(opMsg) - , m_OperationType(type) + : m_OperationMsg(opMsg) + , m_OperationType(type) { } @@ -30,10 +30,10 @@ AppControlCommand::~AppControlCommand() const std::string &AppControlCommand::getOperationMsg() const { - return m_OperationMsg; + return m_OperationMsg; } AppControlCommand::OperationType AppControlCommand::getOperationType() const { - return m_OperationType; + return m_OperationType; } diff --git a/src/Common/AppControl/src/AppControlCompose.cpp b/src/Common/AppControl/src/AppControlCompose.cpp index b13447d..a6d66e6 100644 --- a/src/Common/AppControl/src/AppControlCompose.cpp +++ b/src/Common/AppControl/src/AppControlCompose.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -25,52 +25,52 @@ using namespace Msg; namespace { - const std::string mimeContact = "application/vnd.tizen.contact"; - const std::string myProfileDataType = "my_profile"; + const std::string mimeContact = "application/vnd.tizen.contact"; + const std::string myProfileDataType = "my_profile"; - typedef std::unordered_map OperationMap; + typedef std::unordered_map OperationMap; - const OperationMap operationMap = - { - {APP_CONTROL_OPERATION_COMPOSE, AppControlCompose::OpCompose}, - {APP_CONTROL_OPERATION_SHARE, AppControlCompose::OpShare}, - {APP_CONTROL_OPERATION_MULTI_SHARE, AppControlCompose::OpMultiShare}, - {APP_CONTROL_OPERATION_SHARE_TEXT, AppControlCompose::OpShareText} - }; + const OperationMap operationMap = + { + {APP_CONTROL_OPERATION_COMPOSE, AppControlCompose::OpCompose}, + {APP_CONTROL_OPERATION_SHARE, AppControlCompose::OpShare}, + {APP_CONTROL_OPERATION_MULTI_SHARE, AppControlCompose::OpMultiShare}, + {APP_CONTROL_OPERATION_SHARE_TEXT, AppControlCompose::OpShareText} + }; - AppControlCompose::OpComposeType getOperation(const std::string &op) - { - auto it = operationMap.find(op); - return it != operationMap.end() ? it->second : AppControlCompose::OpUnknown; - }; + AppControlCompose::OpComposeType getOperation(const std::string &op) + { + auto it = operationMap.find(op); + return it != operationMap.end() ? it->second : AppControlCompose::OpUnknown; + }; } AppControlCompose::AppControlCompose(const std::string &opMsg, app_control_h handle) - : AppControlCommand(opMsg, OpComposeFamily) - , m_ComposeType(getOperation(opMsg)) - , m_isMms(false) -{ - MSG_LOG("ComposeType: ", m_ComposeType); - - if (handle) { - switch (m_ComposeType) { - case OpCompose: - createComposeOp(handle); - break; - case OpShare: - createShareOp(handle); - break; - case OpMultiShare: - createMultiShareOp(handle); - break; - case OpShareText: - createShareTextOp(handle); - break; - case OpUnknown: - MSG_LOG_ERROR("Invalid op-type") - break; - } - } + : AppControlCommand(opMsg, OpComposeFamily) + , m_ComposeType(getOperation(opMsg)) + , m_isMms(false) +{ + MSG_LOG("ComposeType: ", m_ComposeType); + + if (handle) { + switch (m_ComposeType) { + case OpCompose: + createComposeOp(handle); + break; + case OpShare: + createShareOp(handle); + break; + case OpMultiShare: + createMultiShareOp(handle); + break; + case OpShareText: + createShareTextOp(handle); + break; + case OpUnknown: + MSG_LOG_ERROR("Invalid op-type") + break; + } + } } AppControlCompose::~AppControlCompose() @@ -79,161 +79,161 @@ AppControlCompose::~AppControlCompose() void AppControlCompose::readRecipients(app_control_h handle) { - if (m_RecipientList.empty()) - m_RecipientList = AppControlUtils::getExtraDataArray(handle, APP_CONTROL_DATA_TO); + if (m_RecipientList.empty()) + m_RecipientList = AppControlUtils::getExtraDataArray(handle, APP_CONTROL_DATA_TO); - if (m_RecipientList.empty()) { - std::string recip = AppControlUtils::getExtraData(handle, APP_CONTROL_DATA_TO); - if (!recip.empty()) - m_RecipientList.push_back(std::move(recip)); - } + if (m_RecipientList.empty()) { + std::string recip = AppControlUtils::getExtraData(handle, APP_CONTROL_DATA_TO); + if (!recip.empty()) + m_RecipientList.push_back(std::move(recip)); + } } void AppControlCompose::createComposeOp(app_control_h handle) { - parseUriCompose(handle); - readRecipients(handle); - m_MessageText = AppControlUtils::getExtraData(handle, APP_CONTROL_DATA_TEXT); - m_Subject = AppControlUtils::getExtraData(handle, APP_CONTROL_DATA_SUBJECT); - m_FileList = AppControlUtils::getExtraDataArray(handle, APP_CONTROL_DATA_PATH); + parseUriCompose(handle); + readRecipients(handle); + m_MessageText = AppControlUtils::getExtraData(handle, APP_CONTROL_DATA_TEXT); + m_Subject = AppControlUtils::getExtraData(handle, APP_CONTROL_DATA_SUBJECT); + m_FileList = AppControlUtils::getExtraDataArray(handle, APP_CONTROL_DATA_PATH); } void AppControlCompose::createShareOp(app_control_h handle) { - parseUriShare(handle); + parseUriShare(handle); - if (mimeContact == AppControlUtils::getMimeType(handle)) { - std::string idStr = AppControlUtils::getExtraData(handle, APP_CONTROL_DATA_ID); - if (!idStr.empty()) { - std::string dataType = AppControlUtils::getExtraData(handle, APP_CONTROL_DATA_TYPE); - m_VcfInfo.isMyProfile = (dataType == myProfileDataType); - m_VcfInfo.contactsIdList.push_back(atoi(idStr.c_str())); - } - } + if (mimeContact == AppControlUtils::getMimeType(handle)) { + std::string idStr = AppControlUtils::getExtraData(handle, APP_CONTROL_DATA_ID); + if (!idStr.empty()) { + std::string dataType = AppControlUtils::getExtraData(handle, APP_CONTROL_DATA_TYPE); + m_VcfInfo.isMyProfile = (dataType == myProfileDataType); + m_VcfInfo.contactsIdList.push_back(atoi(idStr.c_str())); + } + } - if (m_FileList.empty()) { - std::string path = AppControlUtils::getExtraData(handle, APP_CONTROL_DATA_PATH); - if (!path.empty()) - m_FileList.push_back(std::move(path)); - } + if (m_FileList.empty()) { + std::string path = AppControlUtils::getExtraData(handle, APP_CONTROL_DATA_PATH); + if (!path.empty()) + m_FileList.push_back(std::move(path)); + } } void AppControlCompose::createMultiShareOp(app_control_h handle) { - if (mimeContact == AppControlUtils::getMimeType(handle)) { - auto contactsList = AppControlUtils::getExtraDataArray(handle, APP_CONTROL_DATA_ID); - for (auto it : contactsList) - m_VcfInfo.contactsIdList.push_back(atoi(it.c_str())); - } + if (mimeContact == AppControlUtils::getMimeType(handle)) { + auto contactsList = AppControlUtils::getExtraDataArray(handle, APP_CONTROL_DATA_ID); + for (auto it : contactsList) + m_VcfInfo.contactsIdList.push_back(atoi(it.c_str())); + } - m_FileList = AppControlUtils::getExtraDataArray(handle, APP_CONTROL_DATA_PATH); - parseUriShare(handle); + m_FileList = AppControlUtils::getExtraDataArray(handle, APP_CONTROL_DATA_PATH); + parseUriShare(handle); } void AppControlCompose::createShareTextOp(app_control_h handle) { - parseUriShare(handle); - m_MessageText = AppControlUtils::getExtraData(handle, APP_CONTROL_DATA_TEXT); - m_Subject = AppControlUtils::getExtraData(handle, APP_CONTROL_DATA_SUBJECT); - m_FileList = AppControlUtils::getExtraDataArray(handle, APP_CONTROL_DATA_PATH); + parseUriShare(handle); + m_MessageText = AppControlUtils::getExtraData(handle, APP_CONTROL_DATA_TEXT); + m_Subject = AppControlUtils::getExtraData(handle, APP_CONTROL_DATA_SUBJECT); + m_FileList = AppControlUtils::getExtraDataArray(handle, APP_CONTROL_DATA_PATH); } AppControlCompose::OpComposeType AppControlCompose::getComposeType() const { - return m_ComposeType; + return m_ComposeType; } const AppControlCompose::RecipientList &AppControlCompose::getRecipientList() const { - return m_RecipientList; + return m_RecipientList; } bool AppControlCompose::isMms() const { - return m_isMms; + return m_isMms; } const std::string &AppControlCompose::getMessageText() const { - return m_MessageText; + return m_MessageText; } const std::string &AppControlCompose::getMessageSubject() const { - return m_Subject; + return m_Subject; } const AppControlCompose::FileList &AppControlCompose::getFileList() const { - return m_FileList; + return m_FileList; } const VcfInfo &AppControlCompose::getVcfInfo() const { - return m_VcfInfo; + return m_VcfInfo; } bool AppControlCompose::parseUriCompose(app_control_h handle) { - TRACE; - bool res = false; - char *uri = nullptr; + TRACE; + bool res = false; + char *uri = nullptr; - if (APP_CONTROL_ERROR_NONE == app_control_get_uri(handle, &uri)) { - if (uri) { - MSG_LOG("uri = ", uri); - std::string uriToParse(uri); - std::istringstream is(uriToParse); + if (APP_CONTROL_ERROR_NONE == app_control_get_uri(handle, &uri)) { + if (uri) { + MSG_LOG("uri = ", uri); + std::string uriToParse(uri); + std::istringstream is(uriToParse); - std::string cur; - std::getline(is, cur, ':'); - MSG_LOG("cur = ", cur.c_str()); + std::string cur; + std::getline(is, cur, ':'); + MSG_LOG("cur = ", cur.c_str()); - if (cur == "sms" || cur == "mmsto") { - m_isMms = (cur == "mmsto"); - for (; std::getline(is, cur, ',');) { - m_RecipientList.push_back(cur); - } - res = true; - } - } - free(uri); - } + if (cur == "sms" || cur == "mmsto") { + m_isMms = (cur == "mmsto"); + for (; std::getline(is, cur, ',');) { + m_RecipientList.push_back(cur); + } + res = true; + } + } + free(uri); + } - return res; + return res; } bool AppControlCompose::parseUriShare(app_control_h handle) { - TRACE; - bool res = false; - char *uri = nullptr; - - if (APP_CONTROL_ERROR_NONE == app_control_get_uri(handle, &uri)) { - if (uri) { - MSG_LOG("uri = ", uri); - std::string uriToParse(uri); - std::istringstream is(uriToParse); - - std::string cur; - std::getline(is, cur, ':'); - MSG_LOG("cur = ", cur.c_str()); - - if (cur == "sms" || cur == "mmsto" || cur == "file") { - m_isMms = (cur == "mmsto" || cur == "file"); - if (cur == "file" && m_FileList.empty()) { - std::string prefix("file://"); - m_FileList.push_back(uriToParse.erase(0, prefix.length())); - } - res = true; - } else { - auto it = std::find(m_FileList.begin(), m_FileList.end(), uriToParse); - if (it == m_FileList.end()) - m_FileList.push_back(uriToParse); // no prefix, uri is a path to file itself - } - } - free(uri); - } - - return res; + TRACE; + bool res = false; + char *uri = nullptr; + + if (APP_CONTROL_ERROR_NONE == app_control_get_uri(handle, &uri)) { + if (uri) { + MSG_LOG("uri = ", uri); + std::string uriToParse(uri); + std::istringstream is(uriToParse); + + std::string cur; + std::getline(is, cur, ':'); + MSG_LOG("cur = ", cur.c_str()); + + if (cur == "sms" || cur == "mmsto" || cur == "file") { + m_isMms = (cur == "mmsto" || cur == "file"); + if (cur == "file" && m_FileList.empty()) { + std::string prefix("file://"); + m_FileList.push_back(uriToParse.erase(0, prefix.length())); + } + res = true; + } else { + auto it = std::find(m_FileList.begin(), m_FileList.end(), uriToParse); + if (it == m_FileList.end()) + m_FileList.push_back(uriToParse); // no prefix, uri is a path to file itself + } + } + free(uri); + } + + return res; } diff --git a/src/Common/AppControl/src/AppControlDefault.cpp b/src/Common/AppControl/src/AppControlDefault.cpp index 429cb7c..eeae0ad 100644 --- a/src/Common/AppControl/src/AppControlDefault.cpp +++ b/src/Common/AppControl/src/AppControlDefault.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -21,19 +21,19 @@ using namespace Msg; namespace { - const char *notificationPanel = "http://tizen.org/appcontrol/data/notification"; - const char *keyType = "type"; - const char *valueNewMsg = "new_msg"; - const char *valueSendFailed = "send_failed_msg"; - const char *keyMsgId = "msgId"; + const char *notificationPanel = "http://tizen.org/appcontrol/data/notification"; + const char *keyType = "type"; + const char *valueNewMsg = "new_msg"; + const char *valueSendFailed = "send_failed_msg"; + const char *keyMsgId = "msgId"; } AppControlDefault::AppControlDefault(const std::string &opMsg, app_control_h handle) - : AppControlCommand(opMsg, OpDefault) - , m_MsgId() - , m_DefaultType(UnknownType) + : AppControlCommand(opMsg, OpDefault) + , m_MsgId() + , m_DefaultType(UnknownType) { - parse(handle); + parse(handle); } AppControlDefault::~AppControlDefault() @@ -42,70 +42,70 @@ AppControlDefault::~AppControlDefault() MsgId AppControlDefault::getMessageId() const { - return m_MsgId; + return m_MsgId; } AppControlDefault::DefaultType AppControlDefault::getDefaultType() const { - return m_DefaultType; + return m_DefaultType; } const std::string& AppControlDefault::getReplyText() const { - return m_ReplyText; + return m_ReplyText; } void AppControlDefault::parse(app_control_h handle) { - char *key = nullptr; - app_control_get_extra_data(handle, keyType, &key); - if (!key) - { - m_DefaultType = MainType; - return; - } - - std::string type = key; - free(key); - if (type == valueNewMsg) - viewMessage(handle); - 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) - return; - - m_MsgId = atoi(msgIdStr); - free(msgIdStr); + char *key = nullptr; + app_control_get_extra_data(handle, keyType, &key); + if (!key) + { + m_DefaultType = MainType; + return; + } + + std::string type = key; + free(key); + if (type == valueNewMsg) + viewMessage(handle); + 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) + return; + + m_MsgId = atoi(msgIdStr); + free(msgIdStr); } bool AppControlDefault::isNotificationPanel(app_control_h handle) const { - char *keyVal = nullptr; - app_control_get_extra_data(handle, notificationPanel, &keyVal); - if (keyVal) - { - free(keyVal); - return true; - } - - return false; + char *keyVal = nullptr; + app_control_get_extra_data(handle, notificationPanel, &keyVal); + if (keyVal) + { + free(keyVal); + return true; + } + + return false; } void AppControlDefault::viewMessage(app_control_h handle) { - makeReplyText(handle); - if (isNotificationPanel(handle)) - m_DefaultType = NotificationType; - else - m_DefaultType = m_ReplyText.empty() ? ViewType : ReplyType; + makeReplyText(handle); + if (isNotificationPanel(handle)) + m_DefaultType = NotificationType; + else + m_DefaultType = m_ReplyText.empty() ? ViewType : ReplyType; } void AppControlDefault::makeReplyText(app_control_h handle) { - m_ReplyText = AppControlUtils::getExtraData(handle, APP_CONTROL_DATA_TEXT); + m_ReplyText = AppControlUtils::getExtraData(handle, APP_CONTROL_DATA_TEXT); } diff --git a/src/Common/AppControl/src/AppControlHandle.cpp b/src/Common/AppControl/src/AppControlHandle.cpp index f6a65ff..13eed00 100644 --- a/src/Common/AppControl/src/AppControlHandle.cpp +++ b/src/Common/AppControl/src/AppControlHandle.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -22,85 +22,85 @@ using namespace Msg; AppControlHandle::AppControlHandle(app_control_launch_mode_e launchMode) - : m_Handle() + : m_Handle() { - app_control_create(&m_Handle); - if (m_Handle) - setLaunchMode(launchMode); + app_control_create(&m_Handle); + if (m_Handle) + setLaunchMode(launchMode); } AppControlHandle::~AppControlHandle() { - if (m_Handle) { - terminate(); - app_control_destroy(m_Handle); - } + if (m_Handle) { + terminate(); + app_control_destroy(m_Handle); + } } AppControlHandle::operator app_control_h() { - return m_Handle; + return m_Handle; } bool AppControlHandle::launch() { - return App::getInst().getLauncher().launch(*this); + return App::getInst().getLauncher().launch(*this); } void AppControlHandle::terminate() { - if (m_Handle && App::getInst().getLauncher().m_pHandle == this) - App::getInst().getLauncher().terminate(); + if (m_Handle && App::getInst().getLauncher().m_pHandle == this) + App::getInst().getLauncher().terminate(); } bool AppControlHandle::isGroupMode() const { - app_control_launch_mode_e mode = APP_CONTROL_LAUNCH_MODE_SINGLE; - app_control_get_launch_mode(m_Handle, &mode); - return mode == APP_CONTROL_LAUNCH_MODE_GROUP; + app_control_launch_mode_e mode = APP_CONTROL_LAUNCH_MODE_SINGLE; + app_control_get_launch_mode(m_Handle, &mode); + return mode == APP_CONTROL_LAUNCH_MODE_GROUP; } void AppControlHandle::setOperation(const char *operation) { - app_control_set_operation(m_Handle, operation); + app_control_set_operation(m_Handle, operation); } void AppControlHandle::setAppId(const char *id) { - app_control_set_app_id(m_Handle, id); + app_control_set_app_id(m_Handle, id); } void AppControlHandle::setUri(const char *uri) { - app_control_set_uri(m_Handle, uri); + app_control_set_uri(m_Handle, uri); } void AppControlHandle::setMime(const char *mime) { - app_control_set_mime(m_Handle, mime); + app_control_set_mime(m_Handle, mime); } void AppControlHandle::setLaunchMode(app_control_launch_mode_e mode) { - app_control_set_launch_mode(m_Handle, mode); + app_control_set_launch_mode(m_Handle, mode); } void AppControlHandle::addExtraData(const char *key, const char *data) { - app_control_add_extra_data(m_Handle, key, data); + app_control_add_extra_data(m_Handle, key, data); } void AppControlHandle::removeExtraData(const char *key) { - app_control_remove_extra_data(m_Handle, key); + app_control_remove_extra_data(m_Handle, key); } AppControlLauncher &AppControlHandle::getLauncher() { - return App::getInst().getLauncher(); + return App::getInst().getLauncher(); } void AppControlHandle::onReply(app_control_h request, app_control_h reply, app_control_result_e result) { - MSG_LOG(AppControlUtils::getAppId(reply), " res=", result); + MSG_LOG(AppControlUtils::getAppId(reply), " res=", result); } diff --git a/src/Common/AppControl/src/AppControlLauncher.cpp b/src/Common/AppControl/src/AppControlLauncher.cpp index 66b4a8d..bed47ae 100644 --- a/src/Common/AppControl/src/AppControlLauncher.cpp +++ b/src/Common/AppControl/src/AppControlLauncher.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -21,71 +21,71 @@ using namespace Msg; AppControlLauncher::AppControlLauncher() - : m_LaunchInProgress(false) - , m_pTimer(nullptr) - , m_pHandle(nullptr) + : m_LaunchInProgress(false) + , m_pTimer(nullptr) + , m_pHandle(nullptr) { } AppControlLauncher::~AppControlLauncher() { - if (m_pTimer) - ecore_timer_del(m_pTimer); + if (m_pTimer) + ecore_timer_del(m_pTimer); } bool AppControlLauncher::launch(AppControlHandle &handle) { - if (isLaunchInProgress() || !handle) - return false; + if (isLaunchInProgress() || !handle) + return false; - terminate(); - m_LaunchInProgress = true; - m_pHandle = &handle; - app_control_enable_app_started_result_event(handle); - int ret = app_control_send_launch_request(handle, makeCbLast(&AppControlLauncher::onReply), this); - MSG_LOG("Launch result = ", ret); - m_LaunchInProgress = ret == 0; - if (ret != 0) - m_pHandle = nullptr; - return ret == 0; + terminate(); + m_LaunchInProgress = true; + m_pHandle = &handle; + app_control_enable_app_started_result_event(handle); + int ret = app_control_send_launch_request(handle, makeCbLast(&AppControlLauncher::onReply), this); + MSG_LOG("Launch result = ", ret); + m_LaunchInProgress = ret == 0; + if (ret != 0) + m_pHandle = nullptr; + return ret == 0; } bool AppControlLauncher::isLaunchInProgress() const { - return m_LaunchInProgress; + return m_LaunchInProgress; } void AppControlLauncher::terminate() { - m_LaunchInProgress = false; - if (m_pHandle && m_pHandle->m_Handle) - app_control_send_terminate_request(*m_pHandle); - m_pHandle = nullptr; + m_LaunchInProgress = false; + if (m_pHandle && m_pHandle->m_Handle) + app_control_send_terminate_request(*m_pHandle); + m_pHandle = nullptr; } void AppControlLauncher::onReply(app_control_h request, app_control_h reply, app_control_result_e result) { - MSG_LOG("Result = ", result); + MSG_LOG("Result = ", result); - if (m_pHandle) - m_pHandle->onReply(request, reply, result); + if (m_pHandle) + m_pHandle->onReply(request, reply, result); - if (m_LaunchInProgress) { - m_pTimer = ecore_timer_add(1.2, // Extra time for application startup. - [](void *data)->Eina_Bool - { - auto *self = (AppControlLauncher*)data; - self->m_LaunchInProgress = false; - self->m_pTimer = nullptr; - return false; // Delete timer. - }, - this); - } + if (m_LaunchInProgress) { + m_pTimer = ecore_timer_add(1.2, // Extra time for application startup. + [](void *data)->Eina_Bool + { + auto *self = (AppControlLauncher*)data; + self->m_LaunchInProgress = false; + self->m_pTimer = nullptr; + return false; // Delete timer. + }, + this); + } } AppControlHandle *AppControlLauncher::getHandle() const { - return m_pHandle; + return m_pHandle; } diff --git a/src/Common/AppControl/src/AppControlParser.cpp b/src/Common/AppControl/src/AppControlParser.cpp index c8508d2..68f6113 100644 --- a/src/Common/AppControl/src/AppControlParser.cpp +++ b/src/Common/AppControl/src/AppControlParser.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -30,58 +30,58 @@ using namespace Msg; namespace { - typedef std::unordered_map OperationMap; + typedef std::unordered_map OperationMap; - const OperationMap operationMap = - { - {APP_CONTROL_OPERATION_DEFAULT, AppControlCommand::OpDefault}, - {APP_CONTROL_OPERATION_MAIN, AppControlCommand::OpDefault}, - {APP_CONTROL_OPERATION_COMPOSE, AppControlCommand::OpComposeFamily}, - {APP_CONTROL_OPERATION_SHARE, AppControlCommand::OpComposeFamily}, - {APP_CONTROL_OPERATION_MULTI_SHARE, AppControlCommand::OpComposeFamily}, - {APP_CONTROL_OPERATION_SHARE_TEXT, AppControlCommand::OpComposeFamily}, - {AppControlSettings::getOpName(), AppControlCommand::OpSettings} - }; + const OperationMap operationMap = + { + {APP_CONTROL_OPERATION_DEFAULT, AppControlCommand::OpDefault}, + {APP_CONTROL_OPERATION_MAIN, AppControlCommand::OpDefault}, + {APP_CONTROL_OPERATION_COMPOSE, AppControlCommand::OpComposeFamily}, + {APP_CONTROL_OPERATION_SHARE, AppControlCommand::OpComposeFamily}, + {APP_CONTROL_OPERATION_MULTI_SHARE, AppControlCommand::OpComposeFamily}, + {APP_CONTROL_OPERATION_SHARE_TEXT, AppControlCommand::OpComposeFamily}, + {AppControlSettings::getOpName(), AppControlCommand::OpSettings} + }; - AppControlCommand::OperationType getOperation(const char *op) - { - auto it = operationMap.find(op); - return it != operationMap.end() ? it->second : AppControlCommand::OpUnknown; - }; + AppControlCommand::OperationType getOperation(const char *op) + { + auto it = operationMap.find(op); + return it != operationMap.end() ? it->second : AppControlCommand::OpUnknown; + }; } AppControlCommandRef AppControlParser::parse(app_control_h handle) { - AppControlCommandRef cmd; - char *opStr = nullptr; + AppControlCommandRef cmd; + char *opStr = nullptr; - app_control_get_operation(handle, &opStr); + app_control_get_operation(handle, &opStr); - if (!opStr) - { - MSG_LOG_WARN("app_control operation is null"); - return cmd; - } + if (!opStr) + { + MSG_LOG_WARN("app_control operation is null"); + return cmd; + } - AppControlCommand::OperationType opType = getOperation(opStr); + AppControlCommand::OperationType opType = getOperation(opStr); - switch (opType) - { - case AppControlCommand::OpDefault: - cmd = std::make_shared(opStr, handle); - break; - case AppControlCommand::OpComposeFamily: - cmd = std::make_shared(opStr, handle); - break; - case AppControlCommand::OpSettings: - cmd = std::make_shared(opStr, handle); - break; - default: - case AppControlCommand::OpUnknown: - cmd = std::make_shared(opStr, opType); - break; - } + switch (opType) + { + case AppControlCommand::OpDefault: + cmd = std::make_shared(opStr, handle); + break; + case AppControlCommand::OpComposeFamily: + cmd = std::make_shared(opStr, handle); + break; + case AppControlCommand::OpSettings: + cmd = std::make_shared(opStr, handle); + break; + default: + case AppControlCommand::OpUnknown: + cmd = std::make_shared(opStr, opType); + break; + } - free(opStr); - return cmd; + free(opStr); + return cmd; } diff --git a/src/Common/AppControl/src/AppControlUtils.cpp b/src/Common/AppControl/src/AppControlUtils.cpp index b903dd3..7f6e055 100644 --- a/src/Common/AppControl/src/AppControlUtils.cpp +++ b/src/Common/AppControl/src/AppControlUtils.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -21,94 +21,94 @@ namespace AppControlUtils { std::string getExtraData(app_control_h handle, const std::string &key) { - std::string res; - char *val = nullptr; - if (APP_CONTROL_ERROR_NONE == app_control_get_extra_data(handle, key.c_str(), &val)) - { - if (val) - { - res = val; - free(val); - } - } - return res; + std::string res; + char *val = nullptr; + if (APP_CONTROL_ERROR_NONE == app_control_get_extra_data(handle, key.c_str(), &val)) + { + if (val) + { + res = val; + free(val); + } + } + return res; } std::list getExtraDataArray(app_control_h handle, const std::string &key) { - std::list res; + std::list res; - int arrayLength = 0; - char **pArrayVal = nullptr; - if (APP_CONTROL_ERROR_NONE == app_control_get_extra_data_array(handle, key.c_str(), &pArrayVal, &arrayLength)) { - for (int i = 0; i < arrayLength; ++i) { - if (pArrayVal[i]) { - res.push_back(pArrayVal[i]); - free(pArrayVal[i]); - } - } - free(pArrayVal); - } + int arrayLength = 0; + char **pArrayVal = nullptr; + if (APP_CONTROL_ERROR_NONE == app_control_get_extra_data_array(handle, key.c_str(), &pArrayVal, &arrayLength)) { + for (int i = 0; i < arrayLength; ++i) { + if (pArrayVal[i]) { + res.push_back(pArrayVal[i]); + free(pArrayVal[i]); + } + } + free(pArrayVal); + } - return res; + return res; } int getExtraDataInt(app_control_h handle, const std::string &key) { - char *val = nullptr; - int parsed = 0; - if (APP_CONTROL_ERROR_NONE == app_control_get_extra_data(handle, key.c_str(), &val) && val) { - parsed = atoi(val); - free(val); - } - return parsed; + char *val = nullptr; + int parsed = 0; + if (APP_CONTROL_ERROR_NONE == app_control_get_extra_data(handle, key.c_str(), &val) && val) { + parsed = atoi(val); + free(val); + } + return parsed; } std::list getExtraDataIntArray(app_control_h handle, const std::string &key) { - std::list res; - int arrayLength = 0; - char **pArrayVal = nullptr; - 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) { - if (pArrayVal[i]) { - std::string s(pArrayVal[i] ? pArrayVal[i] : ""); - free(pArrayVal[i]); - int parsed = std::stoi(s, &sz); - if (sz == s.length()) { - res.push_back(parsed); - } - } - } - free(pArrayVal); - } + std::list res; + int arrayLength = 0; + char **pArrayVal = nullptr; + 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) { + if (pArrayVal[i]) { + std::string s(pArrayVal[i] ? pArrayVal[i] : ""); + free(pArrayVal[i]); + int parsed = std::stoi(s, &sz); + if (sz == s.length()) { + res.push_back(parsed); + } + } + } + free(pArrayVal); + } - return res; + return res; } std::string getMimeType(app_control_h handle) { - char *mime = nullptr; - std::string result; - app_control_get_mime(handle, &mime); - if (mime) { - result = mime; - free(mime); - } - return result; + char *mime = nullptr; + std::string result; + app_control_get_mime(handle, &mime); + if (mime) { + result = mime; + free(mime); + } + return result; } std::string getAppId(app_control_h handle) { - char *id = nullptr; - std::string result; - app_control_get_app_id(handle, &id); - if (id) { - result = id; - free(id); - } - return result; + char *id = nullptr; + std::string result; + app_control_get_app_id(handle, &id); + if (id) { + result = id; + free(id); + } + return result; } } // AppControlUtils diff --git a/src/Common/AppControl/src/ContactEditor.cpp b/src/Common/AppControl/src/ContactEditor.cpp index 3453712..1173945 100644 --- a/src/Common/AppControl/src/ContactEditor.cpp +++ b/src/Common/AppControl/src/ContactEditor.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -23,44 +23,44 @@ using namespace Msg; namespace { - const char* mimeContact = "application/vnd.tizen.contact"; + const char* mimeContact = "application/vnd.tizen.contact"; } ContactEditor::ContactEditor() { - app_control_set_mime(m_Handle, mimeContact); + app_control_set_mime(m_Handle, mimeContact); } ContactEditor::~ContactEditor() { - terminate(); + terminate(); } bool ContactEditor::launch(const std::string &address, Operation operation) { - bool res = false; - if (!address.empty()) - { - const char *op = nullptr; - if (operation == EditOp) - op = APP_CONTROL_OPERATION_EDIT; - else if (operation == CreateOp) - op = APP_CONTROL_OPERATION_ADD; + bool res = false; + if (!address.empty()) + { + const char *op = nullptr; + if (operation == EditOp) + op = APP_CONTROL_OPERATION_EDIT; + else if (operation == CreateOp) + op = APP_CONTROL_OPERATION_ADD; - if (op) - { - if (MsgUtils::isValidNumber(address)) - res = launch(address, op, APP_CONTROL_DATA_PHONE); - else if (MsgUtils::isValidEmail(address)) - res = launch(address, op, APP_CONTROL_DATA_EMAIL); - } - } - return res; + if (op) + { + if (MsgUtils::isValidNumber(address)) + res = launch(address, op, APP_CONTROL_DATA_PHONE); + else if (MsgUtils::isValidEmail(address)) + res = launch(address, op, APP_CONTROL_DATA_EMAIL); + } + } + return res; } bool ContactEditor::launch(const std::string &address, const char *operation, const char *addressType) { - app_control_set_operation(m_Handle, operation); - app_control_add_extra_data(m_Handle, addressType, address.c_str()); - return AppControlHandle::launch(); + app_control_set_operation(m_Handle, operation); + app_control_add_extra_data(m_Handle, addressType, address.c_str()); + return AppControlHandle::launch(); } diff --git a/src/Common/AppControl/src/ContactPicker.cpp b/src/Common/AppControl/src/ContactPicker.cpp index 244ba13..b9420e7 100644 --- a/src/Common/AppControl/src/ContactPicker.cpp +++ b/src/Common/AppControl/src/ContactPicker.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -20,53 +20,53 @@ using namespace Msg; namespace { - const char* mimeContact = "application/vnd.tizen.contact"; - const char* single = "single"; - const char* multiple = "multiple"; - const std::string typePhone = "phone"; - const std::string typeEmail = "email"; + const char* mimeContact = "application/vnd.tizen.contact"; + const char* single = "single"; + const char* multiple = "multiple"; + const std::string typePhone = "phone"; + const std::string typeEmail = "email"; } ContactPicker::ContactPicker() - : m_pListener(nullptr) + : m_pListener(nullptr) { - app_control_set_operation(m_Handle, APP_CONTROL_OPERATION_PICK); - app_control_set_mime(m_Handle, mimeContact); + app_control_set_operation(m_Handle, APP_CONTROL_OPERATION_PICK); + app_control_set_mime(m_Handle, mimeContact); } void ContactPicker::setListener(IContactPickerListener *pListener) { - m_pListener = pListener; + m_pListener = pListener; } bool ContactPicker::launch(size_t howManyToPick) { - bool res = false; - if (m_Handle) { + bool res = false; + if (m_Handle) { - if (howManyToPick > 1) { - app_control_add_extra_data(m_Handle, APP_CONTROL_DATA_SELECTION_MODE, multiple); - app_control_add_extra_data(m_Handle, APP_CONTROL_DATA_TOTAL_COUNT, std::to_string(howManyToPick).c_str()); - } else { - app_control_add_extra_data(m_Handle, APP_CONTROL_DATA_SELECTION_MODE, single); - } + if (howManyToPick > 1) { + app_control_add_extra_data(m_Handle, APP_CONTROL_DATA_SELECTION_MODE, multiple); + app_control_add_extra_data(m_Handle, APP_CONTROL_DATA_TOTAL_COUNT, std::to_string(howManyToPick).c_str()); + } else { + app_control_add_extra_data(m_Handle, APP_CONTROL_DATA_SELECTION_MODE, single); + } - app_control_add_extra_data(m_Handle, APP_CONTROL_DATA_TYPE, typePhone.c_str()); - res = AppControlHandle::launch(); - } + app_control_add_extra_data(m_Handle, APP_CONTROL_DATA_TYPE, typePhone.c_str()); + res = AppControlHandle::launch(); + } - return res; + return res; } void ContactPicker::onReply(app_control_h request, app_control_h reply, app_control_result_e result) { - if (result == APP_CONTROL_RESULT_SUCCEEDED) { - std::list result; - auto addressIds = AppControlUtils::getExtraDataIntArray(reply, APP_CONTROL_DATA_SELECTED); - for (int id : addressIds) - result.push_back({IContactPickerListener::PhoneType, id}); + if (result == APP_CONTROL_RESULT_SUCCEEDED) { + std::list result; + auto addressIds = AppControlUtils::getExtraDataIntArray(reply, APP_CONTROL_DATA_SELECTED); + for (int id : addressIds) + result.push_back({IContactPickerListener::PhoneType, id}); - if (m_pListener) - m_pListener->onContactsPicked(result); - } + if (m_pListener) + m_pListener->onContactsPicked(result); + } } diff --git a/src/Common/AppControl/src/ContactViewer.cpp b/src/Common/AppControl/src/ContactViewer.cpp index c47bc61..62457cd 100644 --- a/src/Common/AppControl/src/ContactViewer.cpp +++ b/src/Common/AppControl/src/ContactViewer.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -26,11 +26,11 @@ using namespace Msg; namespace { - const char *mimeContact = "application/vnd.tizen.contact"; - const char *mimeLog = "application/vnd.tizen.phone-log"; - const char *personContactTypeStr = "person"; - const char *myProfileTypeStr = "my_profile"; - const char *contactsAppId = "org.tizen.w-contacts"; + const char *mimeContact = "application/vnd.tizen.contact"; + const char *mimeLog = "application/vnd.tizen.phone-log"; + const char *personContactTypeStr = "person"; + const char *myProfileTypeStr = "my_profile"; + const char *contactsAppId = "org.tizen.w-contacts"; } ContactViewer::ContactViewer() @@ -43,79 +43,79 @@ ContactViewer::~ContactViewer() bool ContactViewer::launchPrivate(const ContactAddress &address) { - setOperation(APP_CONTROL_OPERATION_VIEW); - bool isLog = dynamic_cast(&address); - std::string mime = isLog ? mimeLog : mimeContact; - int id = isLog ? address.getId() : address.getOwnerId(); - setMime(mime.c_str()); - addExtraData(APP_CONTROL_DATA_TYPE, toStr(address.getOwnerType())); - addExtraData(APP_CONTROL_DATA_ID, std::to_string(id).c_str()); - return AppControlHandle::launch(); + setOperation(APP_CONTROL_OPERATION_VIEW); + bool isLog = dynamic_cast(&address); + std::string mime = isLog ? mimeLog : mimeContact; + int id = isLog ? address.getId() : address.getOwnerId(); + setMime(mime.c_str()); + addExtraData(APP_CONTROL_DATA_TYPE, toStr(address.getOwnerType())); + addExtraData(APP_CONTROL_DATA_ID, std::to_string(id).c_str()); + return AppControlHandle::launch(); } bool ContactViewer::launch(const ContactAddress &address) { - if (getLauncher().isLaunchInProgress()) - return false; + if (getLauncher().isLaunchInProgress()) + return false; - clear(); - return launchPrivate(address); + clear(); + return launchPrivate(address); } bool ContactViewer::launch() { - if (getLauncher().isLaunchInProgress()) - return false; + if (getLauncher().isLaunchInProgress()) + return false; - clear(); - setAppId(contactsAppId); - return AppControlHandle::launch(); + clear(); + setAppId(contactsAppId); + return AppControlHandle::launch(); } bool ContactViewer::launch(const std::string &address) { - if (getLauncher().isLaunchInProgress()) - return false; - - clear(); - setOperation(APP_CONTROL_OPERATION_VIEW); - auto rec = App::getInst().getContactManager().getContactAddress(address); - if (rec) - return launchPrivate(*rec); - - setMime(mimeLog); - if (MsgUtils::isValidNumber(address)) - addExtraData(APP_CONTROL_DATA_PHONE, address.c_str()); - else if (MsgUtils::isValidEmail(address)) - addExtraData(APP_CONTROL_DATA_EMAIL, address.c_str()); - else - return false; - - return AppControlHandle::launch(); + if (getLauncher().isLaunchInProgress()) + return false; + + clear(); + setOperation(APP_CONTROL_OPERATION_VIEW); + auto rec = App::getInst().getContactManager().getContactAddress(address); + if (rec) + return launchPrivate(*rec); + + setMime(mimeLog); + if (MsgUtils::isValidNumber(address)) + addExtraData(APP_CONTROL_DATA_PHONE, address.c_str()); + else if (MsgUtils::isValidEmail(address)) + addExtraData(APP_CONTROL_DATA_EMAIL, address.c_str()); + else + return false; + + return AppControlHandle::launch(); } void ContactViewer::clear() { - setOperation(nullptr); - setAppId(nullptr); - setMime(nullptr); - removeExtraData(APP_CONTROL_DATA_PHONE); - removeExtraData(APP_CONTROL_DATA_EMAIL); - removeExtraData(APP_CONTROL_DATA_TYPE); - removeExtraData(APP_CONTROL_DATA_ID); + setOperation(nullptr); + setAppId(nullptr); + setMime(nullptr); + removeExtraData(APP_CONTROL_DATA_PHONE); + removeExtraData(APP_CONTROL_DATA_EMAIL); + removeExtraData(APP_CONTROL_DATA_TYPE); + removeExtraData(APP_CONTROL_DATA_ID); } const char *ContactViewer::toStr(ContactAddress::OwnerType type) { - switch (type) - { - case ContactAddress::PersonType: - return personContactTypeStr; - case ContactAddress::MyProfileType: - return myProfileTypeStr; - default: - MSG_LOG_ERROR("Unknown ContactType"); - }; - return ""; + switch (type) + { + case ContactAddress::PersonType: + return personContactTypeStr; + case ContactAddress::MyProfileType: + return myProfileTypeStr; + default: + MSG_LOG_ERROR("Unknown ContactType"); + }; + return ""; } diff --git a/src/Common/AppControl/src/FileViewer.cpp b/src/Common/AppControl/src/FileViewer.cpp index 24cb6e8..5a7ea6e 100644 --- a/src/Common/AppControl/src/FileViewer.cpp +++ b/src/Common/AppControl/src/FileViewer.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -23,52 +23,52 @@ using namespace Msg; FileViewer::FileViewer() { - app_control_set_operation(m_Handle, APP_CONTROL_OPERATION_VIEW); + app_control_set_operation(m_Handle, APP_CONTROL_OPERATION_VIEW); } FileViewer::~FileViewer() { - if (!m_FilePath.empty()) - FileUtils::remove(m_FilePath); + if (!m_FilePath.empty()) + FileUtils::remove(m_FilePath); } bool FileViewer::launch(const std::string &file) { - if (getLauncher().isLaunchInProgress()) - return false; + if (getLauncher().isLaunchInProgress()) + return false; - bool res = false; - std::string mime = FileUtils::getMimeType(file); + bool res = false; + std::string mime = FileUtils::getMimeType(file); - MSG_LOG("File path: ", file); - MSG_LOG("MIME type: ", mime); + MSG_LOG("File path: ", file); + MSG_LOG("MIME type: ", mime); - if (mime.empty() || file.empty()) - return false; + if (mime.empty() || file.empty()) + return false; - if (m_Handle) { - app_control_set_mime(m_Handle, mime.c_str()); - std::string uri = "file://" + file; - app_control_set_uri(m_Handle, uri.c_str()); - res = AppControlHandle::launch(); - } + if (m_Handle) { + app_control_set_mime(m_Handle, mime.c_str()); + std::string uri = "file://" + file; + app_control_set_uri(m_Handle, uri.c_str()); + res = AppControlHandle::launch(); + } - return res; + return res; } bool FileViewer::launchWithCopy(const std::string &file) { - bool res = false; + bool res = false; - if (!getLauncher().isLaunchInProgress()) { - // Remove previous file (correct only for APP_CONTROL_LAUNCH_MODE_GROUP) - if (!m_FilePath.empty()) - FileUtils::remove(m_FilePath); + if (!getLauncher().isLaunchInProgress()) { + // Remove previous file (correct only for APP_CONTROL_LAUNCH_MODE_GROUP) + if (!m_FilePath.empty()) + FileUtils::remove(m_FilePath); - m_FilePath = FileUtils::addFileToDataDir(file); - if (!m_FilePath.empty()) - res = launch(m_FilePath); - } - return res; + m_FilePath = FileUtils::addFileToDataDir(file); + if (!m_FilePath.empty()) + res = launch(m_FilePath); + } + return res; } diff --git a/src/Common/AppControl/src/InputSelector.cpp b/src/Common/AppControl/src/InputSelector.cpp index b65d884..17c786a 100644 --- a/src/Common/AppControl/src/InputSelector.cpp +++ b/src/Common/AppControl/src/InputSelector.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -20,11 +20,11 @@ using namespace Msg; InputSelector::InputSelector() - : m_pListener(nullptr) + : m_pListener(nullptr) { - setOperation(APP_CONTROL_OPERATION_GET_INPUT); - addExtraData("return_key_type", "DONE"); - setMime("text/plain"); + setOperation(APP_CONTROL_OPERATION_GET_INPUT); + addExtraData("return_key_type", "DONE"); + setMime("text/plain"); } InputSelector::~InputSelector() @@ -33,78 +33,78 @@ InputSelector::~InputSelector() void InputSelector::setListener(IInputSelectorListener *l) { - m_pListener = l; + m_pListener = l; } void InputSelector::setText(const std::string &text) { - addExtraData(APP_CONTROL_DATA_INPUT_DEFAULT_TEXT, text.c_str()); + addExtraData(APP_CONTROL_DATA_INPUT_DEFAULT_TEXT, text.c_str()); } void InputSelector::clear() { - removeExtraData(APP_CONTROL_DATA_INPUT_TYPE); - removeExtraData(APP_CONTROL_DATA_INPUT_DEFAULT_TEXT); + removeExtraData(APP_CONTROL_DATA_INPUT_TYPE); + removeExtraData(APP_CONTROL_DATA_INPUT_DEFAULT_TEXT); } void InputSelector::terminateHandler() { - onTerminate(); - if (m_pListener) - m_pListener->onTerminate(*this); - clear(); + onTerminate(); + if (m_pListener) + m_pListener->onTerminate(*this); + clear(); } bool InputSelector::launch(InputType type) { - terminate(); - - const char *inputStr = nullptr; - switch (type) { - case VoiceType: - inputStr = "input_voice"; - break; - case EmoticonType: - inputStr = "input_emoticon"; - break; - case KeyboardType: - inputStr = "input_keyboard"; - break; - } - if (inputStr) - addExtraData(APP_CONTROL_DATA_INPUT_TYPE, inputStr); - - return AppControlHandle::launch(); + terminate(); + + const char *inputStr = nullptr; + switch (type) { + case VoiceType: + inputStr = "input_voice"; + break; + case EmoticonType: + inputStr = "input_emoticon"; + break; + case KeyboardType: + inputStr = "input_keyboard"; + break; + } + if (inputStr) + addExtraData(APP_CONTROL_DATA_INPUT_TYPE, inputStr); + + return AppControlHandle::launch(); } bool InputSelector::launch() { - terminate(); - return AppControlHandle::launch(); + terminate(); + return AppControlHandle::launch(); } void InputSelector::onReply(app_control_h request, app_control_h reply, app_control_result_e result) { - MSG_LOG("result = ", result); - - if (result == APP_CONTROL_RESULT_SUCCEEDED) { - - std::string text = AppControlUtils::getExtraData(reply, APP_CONTROL_DATA_TEXT); - std::string replyType = AppControlUtils::getExtraData(reply, "reply_type"); - - MSG_LOG("replyType = ", replyType); - - if(replyType == "keyboard") { - onKeyboardReply(text); - } else if (replyType == "emoticon") { - onEmoticonReply(text); - } else if (replyType == "voice") { - auto fileList = AppControlUtils::getExtraDataArray(reply, APP_CONTROL_DATA_PATH); - onVoiceReply(text, fileList); - } if (replyType == "template") { - onTemplateReply(text); - } - } - if (result != APP_CONTROL_RESULT_APP_STARTED) - terminateHandler(); + MSG_LOG("result = ", result); + + if (result == APP_CONTROL_RESULT_SUCCEEDED) { + + std::string text = AppControlUtils::getExtraData(reply, APP_CONTROL_DATA_TEXT); + std::string replyType = AppControlUtils::getExtraData(reply, "reply_type"); + + MSG_LOG("replyType = ", replyType); + + if(replyType == "keyboard") { + onKeyboardReply(text); + } else if (replyType == "emoticon") { + onEmoticonReply(text); + } else if (replyType == "voice") { + auto fileList = AppControlUtils::getExtraDataArray(reply, APP_CONTROL_DATA_PATH); + onVoiceReply(text, fileList); + } if (replyType == "template") { + onTemplateReply(text); + } + } + if (result != APP_CONTROL_RESULT_APP_STARTED) + terminateHandler(); } diff --git a/src/Common/AppControl/src/SettingsLauncher.cpp b/src/Common/AppControl/src/SettingsLauncher.cpp index 59c074a..d4f2584 100644 --- a/src/Common/AppControl/src/SettingsLauncher.cpp +++ b/src/Common/AppControl/src/SettingsLauncher.cpp @@ -20,14 +20,14 @@ using namespace Msg; bool SettingsLauncher::launchConnections() { - int res = false; - if (getLauncher().isLaunchInProgress()) - return res; + int res = false; + if (getLauncher().isLaunchInProgress()) + return res; - if (m_Handle) { - app_control_set_app_id(m_Handle, "org.tizen.watch-setting"); - app_control_add_extra_data(m_Handle, "launch-type", "connections"); - res = AppControlHandle::launch(); - } - return res; + if (m_Handle) { + app_control_set_app_id(m_Handle, "org.tizen.watch-setting"); + app_control_add_extra_data(m_Handle, "launch-type", "connections"); + res = AppControlHandle::launch(); + } + return res; } diff --git a/src/Common/AppControl/src/Share.cpp b/src/Common/AppControl/src/Share.cpp index 2f5ac39..a38429d 100644 --- a/src/Common/AppControl/src/Share.cpp +++ b/src/Common/AppControl/src/Share.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -30,52 +30,52 @@ Share::Share() Share::~Share() { - removeFiles(); + removeFiles(); } void Share::removeFiles() { - for (auto &&file : m_FileList) - { - FileUtils::remove(file); - } - m_FileList.clear(); + for (auto &&file : m_FileList) + { + FileUtils::remove(file); + } + m_FileList.clear(); } void Share::addFiles(const std::list &files) { - removeFiles(); - for (auto &&file : files) - { - m_FileList.push_back(FileUtils::addFileToDataDir(file)); - } + removeFiles(); + for (auto &&file : files) + { + m_FileList.push_back(FileUtils::addFileToDataDir(file)); + } } bool Share::launch(const std::list &files) { - if (files.empty() || getLauncher().isLaunchInProgress()) - return false; + if (files.empty() || getLauncher().isLaunchInProgress()) + return false; - addFiles(files); - std::vector nativePaths; - for (const std::string &file : m_FileList) - { - if (!file.empty()) - nativePaths.push_back(file.c_str()); - } + addFiles(files); + std::vector nativePaths; + for (const std::string &file : m_FileList) + { + if (!file.empty()) + nativePaths.push_back(file.c_str()); + } - app_control_set_operation(m_Handle, APP_CONTROL_OPERATION_MULTI_SHARE); - app_control_add_extra_data_array(m_Handle, APP_CONTROL_DATA_PATH, nativePaths.data(), nativePaths.size()); - return getLauncher().launch(*this); + app_control_set_operation(m_Handle, APP_CONTROL_OPERATION_MULTI_SHARE); + app_control_add_extra_data_array(m_Handle, APP_CONTROL_DATA_PATH, nativePaths.data(), nativePaths.size()); + return getLauncher().launch(*this); } bool Share::launch(const std::string &text) { - if (text.empty() || getLauncher().isLaunchInProgress()) - return false; + if (text.empty() || getLauncher().isLaunchInProgress()) + return false; - app_control_set_operation(m_Handle, APP_CONTROL_OPERATION_SHARE_TEXT); - app_control_add_extra_data(m_Handle, APP_CONTROL_DATA_TEXT, text.c_str()); - return AppControlHandle::launch(); + app_control_set_operation(m_Handle, APP_CONTROL_OPERATION_SHARE_TEXT); + app_control_add_extra_data(m_Handle, APP_CONTROL_DATA_TEXT, text.c_str()); + return AppControlHandle::launch(); } diff --git a/src/Common/AppControl/src/VoiceCall.cpp b/src/Common/AppControl/src/VoiceCall.cpp index 9ef2813..aed8ae5 100644 --- a/src/Common/AppControl/src/VoiceCall.cpp +++ b/src/Common/AppControl/src/VoiceCall.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -22,7 +22,7 @@ using namespace Msg; namespace { - const std::string tel = "tel:"; + const std::string tel = "tel:"; } VoiceCall::VoiceCall() @@ -31,19 +31,19 @@ VoiceCall::VoiceCall() bool VoiceCall::launch(const std::string &number) { - bool res = false; - app_control_h svcHandle = nullptr; + bool res = false; + app_control_h svcHandle = nullptr; - if (APP_CONTROL_ERROR_NONE == app_control_create(&svcHandle)) - { - app_control_set_operation(svcHandle, APP_CONTROL_OPERATION_CALL); - std::string phoneNumber = tel + number; + if (APP_CONTROL_ERROR_NONE == app_control_create(&svcHandle)) + { + app_control_set_operation(svcHandle, APP_CONTROL_OPERATION_CALL); + std::string phoneNumber = tel + number; - app_control_set_uri(svcHandle, phoneNumber.c_str()); - int ret = app_control_send_launch_request(svcHandle, nullptr, nullptr); - MSG_LOG("Result code: ", ret); - res = ret == APP_CONTROL_ERROR_NONE; - app_control_destroy(svcHandle); - } - return res; + app_control_set_uri(svcHandle, phoneNumber.c_str()); + int ret = app_control_send_launch_request(svcHandle, nullptr, nullptr); + MSG_LOG("Result code: ", ret); + res = ret == APP_CONTROL_ERROR_NONE; + app_control_destroy(svcHandle); + } + return res; } diff --git a/src/Common/ContactManager/inc/Contact.h b/src/Common/ContactManager/inc/Contact.h index 65f8efd..63551f3 100644 --- a/src/Common/ContactManager/inc/Contact.h +++ b/src/Common/ContactManager/inc/Contact.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -24,61 +24,61 @@ #include namespace Msg { - class Contact; - typedef std::shared_ptr ContactRef; + class Contact; + typedef std::shared_ptr ContactRef; - class Contact - : public ContactRecord { - public: - Contact(bool release, contacts_record_h record = nullptr); + class Contact + : public ContactRecord { + public: + Contact(bool release, contacts_record_h record = nullptr); - std::string getDispName() const; - std::string getPhoneNumber() const; - std::string getEmail() const; - std::string getThumb() const; - std::string getAddress() const; - }; + std::string getDispName() const; + std::string getPhoneNumber() const; + std::string getEmail() const; + std::string getThumb() const; + std::string getAddress() const; + }; - inline Contact::Contact(bool release, contacts_record_h record) - : ContactRecord(release, record) - { - } + inline Contact::Contact(bool release, contacts_record_h record) + : ContactRecord(release, record) + { + } - inline std::string Contact::getDispName() const - { - return getStr(_contacts_contact.display_name); - } + inline std::string Contact::getDispName() const + { + return getStr(_contacts_contact.display_name); + } - inline std::string Contact::getPhoneNumber() const - { - std::string res; - int count = getChildCount(_contacts_contact.number); - if (count > 0) - res = getStr(getChildP(_contacts_contact.number, 0), _contacts_number.number); - return res; - } + inline std::string Contact::getPhoneNumber() const + { + std::string res; + int count = getChildCount(_contacts_contact.number); + if (count > 0) + res = getStr(getChildP(_contacts_contact.number, 0), _contacts_number.number); + return res; + } - inline std::string Contact::getEmail() const - { - std::string res; - int count = getChildCount(_contacts_contact.email); - if (count > 0) - res = getStr(getChildP(_contacts_contact.number, 0), _contacts_email.email); - return res; - } + inline std::string Contact::getEmail() const + { + std::string res; + int count = getChildCount(_contacts_contact.email); + if (count > 0) + res = getStr(getChildP(_contacts_contact.number, 0), _contacts_email.email); + return res; + } - inline std::string Contact::getThumb() const - { - return getStr(_contacts_contact.image_thumbnail_path); - } + inline std::string Contact::getThumb() const + { + return getStr(_contacts_contact.image_thumbnail_path); + } - inline std::string Contact::getAddress() const - { - std::string address = getPhoneNumber(); - if (address.empty()) - address = getEmail(); - return address; - } + inline std::string Contact::getAddress() const + { + std::string address = getPhoneNumber(); + if (address.empty()) + address = getEmail(); + return address; + } } #endif /* __Contact_h__ */ diff --git a/src/Common/ContactManager/inc/ContactAddress.h b/src/Common/ContactManager/inc/ContactAddress.h index 50b7f4c..031be6f 100644 --- a/src/Common/ContactManager/inc/ContactAddress.h +++ b/src/Common/ContactManager/inc/ContactAddress.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -21,39 +21,39 @@ #include "ContactRecord.h" namespace Msg { - class ContactAddress; - typedef std::shared_ptr ContactAddressRef; - - class ContactAddress - : public ContactRecord { - - public: - enum OwnerType { - PersonType, - MyProfileType, - }; - - public: - ContactAddress(); - ContactAddress(bool release, contacts_record_h record = nullptr); - virtual ~ContactAddress() {}; - virtual OwnerType getOwnerType() const = 0; - virtual int getOwnerId() const = 0; - virtual int getId() const = 0; - virtual std::string getDispName() const = 0; - virtual std::string getAddress() const = 0; // Email or Number - virtual std::string getThumbnailPath() const = 0; - }; - - inline ContactAddress::ContactAddress() - : ContactRecord() - { - } - - inline ContactAddress::ContactAddress(bool release, contacts_record_h record) - : ContactRecord(release, record) - { - } + class ContactAddress; + typedef std::shared_ptr ContactAddressRef; + + class ContactAddress + : public ContactRecord { + + public: + enum OwnerType { + PersonType, + MyProfileType, + }; + + public: + ContactAddress(); + ContactAddress(bool release, contacts_record_h record = nullptr); + virtual ~ContactAddress() {}; + virtual OwnerType getOwnerType() const = 0; + virtual int getOwnerId() const = 0; + virtual int getId() const = 0; + virtual std::string getDispName() const = 0; + virtual std::string getAddress() const = 0; // Email or Number + virtual std::string getThumbnailPath() const = 0; + }; + + inline ContactAddress::ContactAddress() + : ContactRecord() + { + } + + inline ContactAddress::ContactAddress(bool release, contacts_record_h record) + : ContactRecord(release, record) + { + } } #endif /* __ContactAddress_h__ */ diff --git a/src/Common/ContactManager/inc/ContactList.h b/src/Common/ContactManager/inc/ContactList.h index e06fbd6..7a1cf4f 100644 --- a/src/Common/ContactManager/inc/ContactList.h +++ b/src/Common/ContactManager/inc/ContactList.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -21,60 +21,60 @@ namespace Msg { - class ContactManager; + class ContactManager; - template - class ContactList - { - friend class ContactManager; + template + class ContactList + { + friend class ContactManager; - public: - ContactList(contacts_list_h list) - : m_List(list) - , m_Record(false) - { - } + public: + ContactList(contacts_list_h list) + : m_List(list) + , m_Record(false) + { + } - ~ContactList() - { - if (m_List) - contacts_list_destroy(m_List, true); - } + ~ContactList() + { + if (m_List) + contacts_list_destroy(m_List, true); + } - bool next() - { - return contacts_list_next(m_List) == 0; - } + bool next() + { + return contacts_list_next(m_List) == 0; + } - bool prev() - { - return contacts_list_prev(m_List) == 0; - } + bool prev() + { + return contacts_list_prev(m_List) == 0; + } - T &get() - { - contacts_record_h rec = nullptr; - contacts_list_get_current_record_p(m_List, &rec); - m_Record.set(rec); - return m_Record; - } + T &get() + { + contacts_record_h rec = nullptr; + contacts_list_get_current_record_p(m_List, &rec); + m_Record.set(rec); + return m_Record; + } - int getCount() const - { - int count = 0; - contacts_list_get_count(m_List, &count); - return count; - } + int getCount() const + { + int count = 0; + contacts_list_get_count(m_List, &count); + return count; + } - bool isEmpty() const - { - return getCount() <= 0; - } + bool isEmpty() const + { + return getCount() <= 0; + } - private: - contacts_list_h m_List; - T m_Record; - }; + private: + contacts_list_h m_List; + T m_Record; + }; } #endif /* __ContactList_H__ */ diff --git a/src/Common/ContactManager/inc/ContactManager.h b/src/Common/ContactManager/inc/ContactManager.h index dc685ad..f751e15 100644 --- a/src/Common/ContactManager/inc/ContactManager.h +++ b/src/Common/ContactManager/inc/ContactManager.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -34,173 +34,173 @@ #include "Contact.h" namespace Msg { - /* - *@brief A listener to be notified after contact-information will be changed in contacts-db - */ - class IContactManagerListener; - /* - *@brief Class that work with contacts database. - *@brief Search contacts, add listeners, register callback on changes in database. - */ - class ContactManager { - public: - ContactManager(); - ~ContactManager(); - ContactManager(ContactManager&) = delete; - ContactManager &operator=(ContactManager&) = delete; - - public: - /** - *@brief Return what kind of error occurred - *@param[in] error - number of error - *@return kind of error - */ - static std::string whatError(int error); - /** - * @brief Looks for contact information based on a given keyword - * @param keyword - search keyword - */ - template - std::shared_ptr> search(const std::string &keyword); - - /** - *@brief Search by email and phone and return ContactAddress record - *@param[in] address - email or number - *@return Reference to ContactAddress - */ - ContactAddressRef getContactAddress(const std::string &address); - - /** - *@brief Search for contacts-id, name, phone-number and thumbnail path based on phone-number id - *@param[in] phoneId - identifier of phone-number in contacts-database - *@return Reference to ContactPersonNumber - */ - ContactPersonNumberRef getContactPersonNumber(int phoneId); - - /** - *@brief Search for email-id, name, email and thumbnail path - *@param[in] emailId - identifier of email in contacts-database - *@return Reference to ContactPersonEmail - */ - ContactPersonEmailRef getContactPersonEmail(int emailId); - - /** - *@brief Search by email address ContactPersonEmail record - *@param[in] email - email address - *@return Reference to ContactPersonEmail - */ - ContactPersonEmailRef getContactPersonEmail(const std::string &email); - - /** - *@brief Search by number or email ContactPersonPhoneLog record - *@param[in] address - number or email address - *@return Reference to ContactPersonPhoneLog - */ - ContactPersonPhoneLogRef getContactPersonPhoneLog(const std::string &address); - - /** - *@brief Search by number address ContactMyProfileNumber record - *@param[in] number - phone number - *@return Reference to ContactMyProfileNumber - */ - ContactMyProfileNumberRef getContactMyProfileNumber(const std::string &number); - - /** - *@brief Search by email address ContactMyProfileEmailRef record - *@param[in] email - email address - *@return Reference to ContactMyProfileEmailR - */ - ContactMyProfileEmailRef getContactMyProfileEmail(const std::string &email); - - /** - *@brief Return owner's ContactPersonAddress record - *@return Reference to ContactPersonAddress - */ - ContactMyProfileRef getOwnerProfile(); - - /** - *@brief Add listener on contacts database - *@param[in] listener - */ - void addListener(IContactManagerListener &listener); - - /** - *@brief Remove listener - *@param[in] listener - listener to be remove - */ - void removeListener(IContactManagerListener &listener); - - /** - *@brief Create content of contact by it`s id - *@param[in] personId - contact id - *@param[in] myProfile - is app control my_profile data type - *@return Content with all info about one contact - */ - std::string makeVcard(const int personId, bool myProfile); - - /** -- *@brief Create content of contact by id list - *@param[in] personId - contact id - *@return Content with all info about contacts - */ - std::string makeVcard(const std::list &idList); - - /** - *@brief Parse vCard file - *@param[in] filePath Path to file - *@return list of Contacts - */ - std::list parseVcard(const std::string &filePath); - - private: - typedef std::unordered_map AddressMap; - - private: - /** - *@brief A callback passed to contacts_db_add_changed_cb() to get notifications - about contacts modifications from contact service - *@param[in] view_uri - The view URI of records whose changes are monitored - *@param[in] user_data - the user data passed from the callback registration function - */ - static void contactChangedCb(const char *view_uri, void *user_data); - static void contactDisplayOrderChangedCb(contacts_name_display_order_e name_display_order, void *user_data); - - /** - * @brief Generic search for basic contact attributes based on custom filter passed from above - * @param[in] filter to be used for db-request. DO NOT destroy filter manually, it will be destroyed insithe this method. - */ - ContactPersonNumberRef getContactPersonNumber(contacts_filter_h filter); - ContactPersonEmailRef getContactPersonEmail(contacts_filter_h filter); - ContactPersonPhoneLogRef getContactPersonPhoneLog(contacts_filter_h filter); - - /** - *@brief Search by phone number ContactPersonNumber record - *@param[in] number - phone number - *@return Reference to ContactPersonNumber - */ - ContactPersonNumberRef getContactPersonNumber(const std::string &number); - - - void invalidateCache(); - ContactAddressRef getAddress(const std::string &address); - - std::string createContactContent(contacts_record_h record, bool myProfile); - std::string createContentForContactList(int personId); - - private: - std::list m_Listeners; - AddressMap m_AddressMap; - ContactMyProfileRef m_OwnerProfile; - }; - - class IContactManagerListener { - public: - virtual ~IContactManagerListener() {} - /* - *@brief A method called when changing of some contact-record has been occurred - */ - virtual void onContactChanged() {}; - }; + /* + *@brief A listener to be notified after contact-information will be changed in contacts-db + */ + class IContactManagerListener; + /* + *@brief Class that work with contacts database. + *@brief Search contacts, add listeners, register callback on changes in database. + */ + class ContactManager { + public: + ContactManager(); + ~ContactManager(); + ContactManager(ContactManager&) = delete; + ContactManager &operator=(ContactManager&) = delete; + + public: + /** + *@brief Return what kind of error occurred + *@param[in] error - number of error + *@return kind of error + */ + static std::string whatError(int error); + /** + * @brief Looks for contact information based on a given keyword + * @param keyword - search keyword + */ + template + std::shared_ptr> search(const std::string &keyword); + + /** + *@brief Search by email and phone and return ContactAddress record + *@param[in] address - email or number + *@return Reference to ContactAddress + */ + ContactAddressRef getContactAddress(const std::string &address); + + /** + *@brief Search for contacts-id, name, phone-number and thumbnail path based on phone-number id + *@param[in] phoneId - identifier of phone-number in contacts-database + *@return Reference to ContactPersonNumber + */ + ContactPersonNumberRef getContactPersonNumber(int phoneId); + + /** + *@brief Search for email-id, name, email and thumbnail path + *@param[in] emailId - identifier of email in contacts-database + *@return Reference to ContactPersonEmail + */ + ContactPersonEmailRef getContactPersonEmail(int emailId); + + /** + *@brief Search by email address ContactPersonEmail record + *@param[in] email - email address + *@return Reference to ContactPersonEmail + */ + ContactPersonEmailRef getContactPersonEmail(const std::string &email); + + /** + *@brief Search by number or email ContactPersonPhoneLog record + *@param[in] address - number or email address + *@return Reference to ContactPersonPhoneLog + */ + ContactPersonPhoneLogRef getContactPersonPhoneLog(const std::string &address); + + /** + *@brief Search by number address ContactMyProfileNumber record + *@param[in] number - phone number + *@return Reference to ContactMyProfileNumber + */ + ContactMyProfileNumberRef getContactMyProfileNumber(const std::string &number); + + /** + *@brief Search by email address ContactMyProfileEmailRef record + *@param[in] email - email address + *@return Reference to ContactMyProfileEmailR + */ + ContactMyProfileEmailRef getContactMyProfileEmail(const std::string &email); + + /** + *@brief Return owner's ContactPersonAddress record + *@return Reference to ContactPersonAddress + */ + ContactMyProfileRef getOwnerProfile(); + + /** + *@brief Add listener on contacts database + *@param[in] listener + */ + void addListener(IContactManagerListener &listener); + + /** + *@brief Remove listener + *@param[in] listener - listener to be remove + */ + void removeListener(IContactManagerListener &listener); + + /** + *@brief Create content of contact by it`s id + *@param[in] personId - contact id + *@param[in] myProfile - is app control my_profile data type + *@return Content with all info about one contact + */ + std::string makeVcard(const int personId, bool myProfile); + + /** +- *@brief Create content of contact by id list + *@param[in] personId - contact id + *@return Content with all info about contacts + */ + std::string makeVcard(const std::list &idList); + + /** + *@brief Parse vCard file + *@param[in] filePath Path to file + *@return list of Contacts + */ + std::list parseVcard(const std::string &filePath); + + private: + typedef std::unordered_map AddressMap; + + private: + /** + *@brief A callback passed to contacts_db_add_changed_cb() to get notifications + about contacts modifications from contact service + *@param[in] view_uri - The view URI of records whose changes are monitored + *@param[in] user_data - the user data passed from the callback registration function + */ + static void contactChangedCb(const char *view_uri, void *user_data); + static void contactDisplayOrderChangedCb(contacts_name_display_order_e name_display_order, void *user_data); + + /** + * @brief Generic search for basic contact attributes based on custom filter passed from above + * @param[in] filter to be used for db-request. DO NOT destroy filter manually, it will be destroyed insithe this method. + */ + ContactPersonNumberRef getContactPersonNumber(contacts_filter_h filter); + ContactPersonEmailRef getContactPersonEmail(contacts_filter_h filter); + ContactPersonPhoneLogRef getContactPersonPhoneLog(contacts_filter_h filter); + + /** + *@brief Search by phone number ContactPersonNumber record + *@param[in] number - phone number + *@return Reference to ContactPersonNumber + */ + ContactPersonNumberRef getContactPersonNumber(const std::string &number); + + + void invalidateCache(); + ContactAddressRef getAddress(const std::string &address); + + std::string createContactContent(contacts_record_h record, bool myProfile); + std::string createContentForContactList(int personId); + + private: + std::list m_Listeners; + AddressMap m_AddressMap; + ContactMyProfileRef m_OwnerProfile; + }; + + class IContactManagerListener { + public: + virtual ~IContactManagerListener() {} + /* + *@brief A method called when changing of some contact-record has been occurred + */ + virtual void onContactChanged() {}; + }; } #endif /* __ContactManager_h__ */ diff --git a/src/Common/ContactManager/inc/ContactMyProfile.h b/src/Common/ContactManager/inc/ContactMyProfile.h index ce183e8..2c0d896 100644 --- a/src/Common/ContactManager/inc/ContactMyProfile.h +++ b/src/Common/ContactManager/inc/ContactMyProfile.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -20,37 +20,37 @@ #include "ContactRecord.h" namespace Msg { - class ContactMyProfile; - typedef std::shared_ptr ContactMyProfileRef; - - class ContactMyProfile - : public ContactRecord { - public: - ContactMyProfile(bool release, contacts_record_h record = nullptr); - int getId() const; - std::string getThumbnailPath() const; - std::string getDispName() const; - }; - - inline ContactMyProfile::ContactMyProfile(bool release, contacts_record_h record) - : ContactRecord(release, record) - { - } - - inline int ContactMyProfile::getId() const - { - return getInt(_contacts_my_profile.id); - } - - inline std::string ContactMyProfile::getThumbnailPath() const - { - return getStr(_contacts_my_profile.image_thumbnail_path); - } - - inline std::string ContactMyProfile::getDispName() const - { - return getStr(_contacts_my_profile.display_name); - } + class ContactMyProfile; + typedef std::shared_ptr ContactMyProfileRef; + + class ContactMyProfile + : public ContactRecord { + public: + ContactMyProfile(bool release, contacts_record_h record = nullptr); + int getId() const; + std::string getThumbnailPath() const; + std::string getDispName() const; + }; + + inline ContactMyProfile::ContactMyProfile(bool release, contacts_record_h record) + : ContactRecord(release, record) + { + } + + inline int ContactMyProfile::getId() const + { + return getInt(_contacts_my_profile.id); + } + + inline std::string ContactMyProfile::getThumbnailPath() const + { + return getStr(_contacts_my_profile.image_thumbnail_path); + } + + inline std::string ContactMyProfile::getDispName() const + { + return getStr(_contacts_my_profile.display_name); + } } #endif /* ContactMyProfile_h_ */ diff --git a/src/Common/ContactManager/inc/ContactMyProfileEmail.h b/src/Common/ContactManager/inc/ContactMyProfileEmail.h index 90b86aa..1c7353f 100644 --- a/src/Common/ContactManager/inc/ContactMyProfileEmail.h +++ b/src/Common/ContactManager/inc/ContactMyProfileEmail.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -22,77 +22,77 @@ #include "ContactMyProfile.h" namespace Msg { - class ContactMyProfileEmail; - typedef std::shared_ptr ContactMyProfileEmailRef; - - class ContactMyProfileEmail - : public ContactAddress { - public: - ContactMyProfileEmail(bool release, const ContactMyProfile &myProfile, contacts_record_h record = nullptr); - static const char *getUri(); - - // ContactAddress: - OwnerType getOwnerType() const override; - int getOwnerId() const override; - int getId() const override; - std::string getDispName() const override; - std::string getAddress() const override; - std::string getThumbnailPath() const override; - ContactRecordRef clone() const override; - - private: - int m_MyProfileId; - std::string m_ThumbnailPath; - std::string m_DispName; - }; - - inline ContactMyProfileEmail::ContactMyProfileEmail(bool release, const ContactMyProfile &myProfile, contacts_record_h record) - : ContactAddress(release, record) - , m_MyProfileId(myProfile.getId()) - , m_ThumbnailPath(myProfile.getThumbnailPath()) - , m_DispName(myProfile.getDispName()) - { - } - - inline int ContactMyProfileEmail::getId() const - { - return getInt(_contacts_email.id); - } - - inline int ContactMyProfileEmail::getOwnerId() const - { - return m_MyProfileId; - } - - inline std::string ContactMyProfileEmail::getDispName() const - { - return m_DispName; - } - - inline std::string ContactMyProfileEmail::getAddress() const - { - return getStr(_contacts_email.email); - } - - inline std::string ContactMyProfileEmail::getThumbnailPath() const - { - return m_ThumbnailPath; - } - - inline const char *ContactMyProfileEmail::getUri() - { - return _contacts_email._uri; - } - - inline ContactMyProfileNumber::OwnerType ContactMyProfileEmail::getOwnerType() const - { - return MyProfileType; - } - - inline ContactRecordRef ContactMyProfileEmail::clone() const - { - return cloneInternal(); - } + class ContactMyProfileEmail; + typedef std::shared_ptr ContactMyProfileEmailRef; + + class ContactMyProfileEmail + : public ContactAddress { + public: + ContactMyProfileEmail(bool release, const ContactMyProfile &myProfile, contacts_record_h record = nullptr); + static const char *getUri(); + + // ContactAddress: + OwnerType getOwnerType() const override; + int getOwnerId() const override; + int getId() const override; + std::string getDispName() const override; + std::string getAddress() const override; + std::string getThumbnailPath() const override; + ContactRecordRef clone() const override; + + private: + int m_MyProfileId; + std::string m_ThumbnailPath; + std::string m_DispName; + }; + + inline ContactMyProfileEmail::ContactMyProfileEmail(bool release, const ContactMyProfile &myProfile, contacts_record_h record) + : ContactAddress(release, record) + , m_MyProfileId(myProfile.getId()) + , m_ThumbnailPath(myProfile.getThumbnailPath()) + , m_DispName(myProfile.getDispName()) + { + } + + inline int ContactMyProfileEmail::getId() const + { + return getInt(_contacts_email.id); + } + + inline int ContactMyProfileEmail::getOwnerId() const + { + return m_MyProfileId; + } + + inline std::string ContactMyProfileEmail::getDispName() const + { + return m_DispName; + } + + inline std::string ContactMyProfileEmail::getAddress() const + { + return getStr(_contacts_email.email); + } + + inline std::string ContactMyProfileEmail::getThumbnailPath() const + { + return m_ThumbnailPath; + } + + inline const char *ContactMyProfileEmail::getUri() + { + return _contacts_email._uri; + } + + inline ContactMyProfileNumber::OwnerType ContactMyProfileEmail::getOwnerType() const + { + return MyProfileType; + } + + inline ContactRecordRef ContactMyProfileEmail::clone() const + { + return cloneInternal(); + } } diff --git a/src/Common/ContactManager/inc/ContactMyProfileNumber.h b/src/Common/ContactManager/inc/ContactMyProfileNumber.h index 79a51f5..1ba95ac 100644 --- a/src/Common/ContactManager/inc/ContactMyProfileNumber.h +++ b/src/Common/ContactManager/inc/ContactMyProfileNumber.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -22,78 +22,78 @@ #include "ContactMyProfile.h" namespace Msg { - class ContactMyProfileNumber; - typedef std::shared_ptr ContactMyProfileNumberRef; - - class ContactMyProfileNumber - : public ContactAddress { - - public: - ContactMyProfileNumber(bool release, const ContactMyProfile &myProfile, contacts_record_h record = nullptr); - static const char *getUri(); - - // ContactAddress: - OwnerType getOwnerType() const override; - int getOwnerId() const override; - int getId() const override; - std::string getDispName() const override; - std::string getAddress() const override; - std::string getThumbnailPath() const override; - ContactRecordRef clone() const override; - - private: - int m_MyProfileId; - std::string m_ThumbnailPath; - std::string m_DispName; - }; - - inline ContactMyProfileNumber::ContactMyProfileNumber(bool release, const ContactMyProfile &myProfile, contacts_record_h record) - : ContactAddress(release, record) - , m_MyProfileId(myProfile.getId()) - , m_ThumbnailPath(myProfile.getThumbnailPath()) - , m_DispName(myProfile.getDispName()) - { - } - - inline int ContactMyProfileNumber::getId() const - { - return getInt(_contacts_number.id); - } - - inline int ContactMyProfileNumber::getOwnerId() const - { - return m_MyProfileId; - } - - inline std::string ContactMyProfileNumber::getDispName() const - { - return m_DispName; - } - - inline std::string ContactMyProfileNumber::getAddress() const - { - return getStr(_contacts_number.number); - } - - inline std::string ContactMyProfileNumber::getThumbnailPath() const - { - return m_ThumbnailPath; - } - - inline const char *ContactMyProfileNumber::getUri() - { - return _contacts_number._uri; - } - - inline ContactMyProfileNumber::OwnerType ContactMyProfileNumber::getOwnerType() const - { - return MyProfileType; - } - - inline ContactRecordRef ContactMyProfileNumber::clone() const - { - return cloneInternal(); - } + class ContactMyProfileNumber; + typedef std::shared_ptr ContactMyProfileNumberRef; + + class ContactMyProfileNumber + : public ContactAddress { + + public: + ContactMyProfileNumber(bool release, const ContactMyProfile &myProfile, contacts_record_h record = nullptr); + static const char *getUri(); + + // ContactAddress: + OwnerType getOwnerType() const override; + int getOwnerId() const override; + int getId() const override; + std::string getDispName() const override; + std::string getAddress() const override; + std::string getThumbnailPath() const override; + ContactRecordRef clone() const override; + + private: + int m_MyProfileId; + std::string m_ThumbnailPath; + std::string m_DispName; + }; + + inline ContactMyProfileNumber::ContactMyProfileNumber(bool release, const ContactMyProfile &myProfile, contacts_record_h record) + : ContactAddress(release, record) + , m_MyProfileId(myProfile.getId()) + , m_ThumbnailPath(myProfile.getThumbnailPath()) + , m_DispName(myProfile.getDispName()) + { + } + + inline int ContactMyProfileNumber::getId() const + { + return getInt(_contacts_number.id); + } + + inline int ContactMyProfileNumber::getOwnerId() const + { + return m_MyProfileId; + } + + inline std::string ContactMyProfileNumber::getDispName() const + { + return m_DispName; + } + + inline std::string ContactMyProfileNumber::getAddress() const + { + return getStr(_contacts_number.number); + } + + inline std::string ContactMyProfileNumber::getThumbnailPath() const + { + return m_ThumbnailPath; + } + + inline const char *ContactMyProfileNumber::getUri() + { + return _contacts_number._uri; + } + + inline ContactMyProfileNumber::OwnerType ContactMyProfileNumber::getOwnerType() const + { + return MyProfileType; + } + + inline ContactRecordRef ContactMyProfileNumber::clone() const + { + return cloneInternal(); + } } diff --git a/src/Common/ContactManager/inc/ContactPersonEmail.h b/src/Common/ContactManager/inc/ContactPersonEmail.h index 447a68d..88fa967 100644 --- a/src/Common/ContactManager/inc/ContactPersonEmail.h +++ b/src/Common/ContactManager/inc/ContactPersonEmail.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -21,70 +21,70 @@ #include "ContactRecord.h" namespace Msg { - class ContactPersonEmail; - typedef std::shared_ptr ContactPersonEmailRef; - - class ContactPersonEmail - : public ContactAddress { - - public: - ContactPersonEmail(bool release, contacts_record_h record = nullptr); - static const char *getUri(); - - // ContactAddress: - OwnerType getOwnerType() const override; - int getOwnerId() const override; - int getId() const override; - std::string getDispName() const override; - std::string getAddress() const override; - std::string getThumbnailPath() const override; - ContactRecordRef clone() const override; - }; - - inline ContactPersonEmail::ContactPersonEmail(bool release, contacts_record_h record) - : ContactAddress(release, record) - { - } - - inline int ContactPersonEmail::getId() const - { - return getInt(_contacts_person_email.email_id); - } - - inline int ContactPersonEmail::getOwnerId() const - { - return getInt(_contacts_person_email.person_id); - } - - inline std::string ContactPersonEmail::getDispName() const - { - return getStr(_contacts_person_email.display_name); - } - - inline std::string ContactPersonEmail::getAddress() const - { - return getStr(_contacts_person_email.email); - } - - inline std::string ContactPersonEmail::getThumbnailPath() const - { - return getStr(_contacts_person_email.image_thumbnail_path); - } - - inline const char *ContactPersonEmail::getUri() - { - return _contacts_person_email._uri; - } - - inline ContactPersonEmail::OwnerType ContactPersonEmail::getOwnerType() const - { - return PersonType; - } - - inline ContactRecordRef ContactPersonEmail::clone() const - { - return cloneInternal(); - } + class ContactPersonEmail; + typedef std::shared_ptr ContactPersonEmailRef; + + class ContactPersonEmail + : public ContactAddress { + + public: + ContactPersonEmail(bool release, contacts_record_h record = nullptr); + static const char *getUri(); + + // ContactAddress: + OwnerType getOwnerType() const override; + int getOwnerId() const override; + int getId() const override; + std::string getDispName() const override; + std::string getAddress() const override; + std::string getThumbnailPath() const override; + ContactRecordRef clone() const override; + }; + + inline ContactPersonEmail::ContactPersonEmail(bool release, contacts_record_h record) + : ContactAddress(release, record) + { + } + + inline int ContactPersonEmail::getId() const + { + return getInt(_contacts_person_email.email_id); + } + + inline int ContactPersonEmail::getOwnerId() const + { + return getInt(_contacts_person_email.person_id); + } + + inline std::string ContactPersonEmail::getDispName() const + { + return getStr(_contacts_person_email.display_name); + } + + inline std::string ContactPersonEmail::getAddress() const + { + return getStr(_contacts_person_email.email); + } + + inline std::string ContactPersonEmail::getThumbnailPath() const + { + return getStr(_contacts_person_email.image_thumbnail_path); + } + + inline const char *ContactPersonEmail::getUri() + { + return _contacts_person_email._uri; + } + + inline ContactPersonEmail::OwnerType ContactPersonEmail::getOwnerType() const + { + return PersonType; + } + + inline ContactRecordRef ContactPersonEmail::clone() const + { + return cloneInternal(); + } } diff --git a/src/Common/ContactManager/inc/ContactPersonNumber.h b/src/Common/ContactManager/inc/ContactPersonNumber.h index 55b3237..04902fa 100644 --- a/src/Common/ContactManager/inc/ContactPersonNumber.h +++ b/src/Common/ContactManager/inc/ContactPersonNumber.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -21,70 +21,70 @@ #include "ContactRecord.h" namespace Msg { - class ContactPersonNumber; - typedef std::shared_ptr ContactPersonNumberRef; - - class ContactPersonNumber - : public ContactAddress { - - public: - ContactPersonNumber(bool release, contacts_record_h record = nullptr); - static const char *getUri(); - - // ContactAddress: - OwnerType getOwnerType() const override; - int getOwnerId() const override; - int getId() const override; - std::string getDispName() const override; - std::string getAddress() const override; - std::string getThumbnailPath() const override; - ContactRecordRef clone() const override; - }; - - inline ContactPersonNumber::ContactPersonNumber(bool release, contacts_record_h record) - : ContactAddress(release, record) - { - } - - inline int ContactPersonNumber::getId() const - { - return getInt(_contacts_person_number.number_id); - } - - inline int ContactPersonNumber::getOwnerId() const - { - return getInt(_contacts_person_number.person_id); - } - - inline std::string ContactPersonNumber::getDispName() const - { - return getStr(_contacts_person_number.display_name); - } - - inline std::string ContactPersonNumber::getAddress() const - { - return getStr(_contacts_person_number.number); - } - - inline std::string ContactPersonNumber::getThumbnailPath() const - { - return getStr(_contacts_person_number.image_thumbnail_path); - } - - inline const char *ContactPersonNumber::getUri() - { - return _contacts_person_number._uri; - } - - inline ContactPersonNumber::OwnerType ContactPersonNumber::getOwnerType() const - { - return PersonType; - } - - inline ContactRecordRef ContactPersonNumber::clone() const - { - return cloneInternal(); - } + class ContactPersonNumber; + typedef std::shared_ptr ContactPersonNumberRef; + + class ContactPersonNumber + : public ContactAddress { + + public: + ContactPersonNumber(bool release, contacts_record_h record = nullptr); + static const char *getUri(); + + // ContactAddress: + OwnerType getOwnerType() const override; + int getOwnerId() const override; + int getId() const override; + std::string getDispName() const override; + std::string getAddress() const override; + std::string getThumbnailPath() const override; + ContactRecordRef clone() const override; + }; + + inline ContactPersonNumber::ContactPersonNumber(bool release, contacts_record_h record) + : ContactAddress(release, record) + { + } + + inline int ContactPersonNumber::getId() const + { + return getInt(_contacts_person_number.number_id); + } + + inline int ContactPersonNumber::getOwnerId() const + { + return getInt(_contacts_person_number.person_id); + } + + inline std::string ContactPersonNumber::getDispName() const + { + return getStr(_contacts_person_number.display_name); + } + + inline std::string ContactPersonNumber::getAddress() const + { + return getStr(_contacts_person_number.number); + } + + inline std::string ContactPersonNumber::getThumbnailPath() const + { + return getStr(_contacts_person_number.image_thumbnail_path); + } + + inline const char *ContactPersonNumber::getUri() + { + return _contacts_person_number._uri; + } + + inline ContactPersonNumber::OwnerType ContactPersonNumber::getOwnerType() const + { + return PersonType; + } + + inline ContactRecordRef ContactPersonNumber::clone() const + { + return cloneInternal(); + } } diff --git a/src/Common/ContactManager/inc/ContactPersonPhoneLog.h b/src/Common/ContactManager/inc/ContactPersonPhoneLog.h index 58e254b..cace4c6 100644 --- a/src/Common/ContactManager/inc/ContactPersonPhoneLog.h +++ b/src/Common/ContactManager/inc/ContactPersonPhoneLog.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -21,70 +21,70 @@ #include "ContactAddress.h" namespace Msg { - class ContactPersonPhoneLog; - typedef std::shared_ptr ContactPersonPhoneLogRef; - - class ContactPersonPhoneLog - : public ContactAddress { - - public: - ContactPersonPhoneLog(bool release, contacts_record_h record = nullptr); - static const char *getUri(); - - // ContactAddress: - OwnerType getOwnerType() const override; - int getOwnerId() const override; - int getId() const override; - std::string getDispName() const override; - std::string getAddress() const override; - ContactRecordRef clone() const override; - std::string getThumbnailPath() const override; - }; - - inline ContactPersonPhoneLog::ContactPersonPhoneLog(bool release, contacts_record_h record) - : ContactAddress(release, record) - { - } - - inline int ContactPersonPhoneLog::getId() const - { - return getInt(_contacts_person_phone_log.log_id); - } - - inline int ContactPersonPhoneLog::getOwnerId() const - { - return getInt(_contacts_person_phone_log.person_id); - } - - inline std::string ContactPersonPhoneLog::getDispName() const - { - return getStr(_contacts_person_phone_log.display_name); - } - - inline std::string ContactPersonPhoneLog::getAddress() const - { - return getStr(_contacts_person_phone_log.address); - } - - inline std::string ContactPersonPhoneLog::getThumbnailPath() const - { - return getStr(_contacts_person_phone_log.image_thumbnail_path); - } - - inline const char *ContactPersonPhoneLog::getUri() - { - return _contacts_person_phone_log._uri; - } - - inline ContactRecordRef ContactPersonPhoneLog::clone() const - { - return cloneInternal(); - } - - inline ContactPersonPhoneLog::OwnerType ContactPersonPhoneLog::getOwnerType() const - { - return PersonType; - } + class ContactPersonPhoneLog; + typedef std::shared_ptr ContactPersonPhoneLogRef; + + class ContactPersonPhoneLog + : public ContactAddress { + + public: + ContactPersonPhoneLog(bool release, contacts_record_h record = nullptr); + static const char *getUri(); + + // ContactAddress: + OwnerType getOwnerType() const override; + int getOwnerId() const override; + int getId() const override; + std::string getDispName() const override; + std::string getAddress() const override; + ContactRecordRef clone() const override; + std::string getThumbnailPath() const override; + }; + + inline ContactPersonPhoneLog::ContactPersonPhoneLog(bool release, contacts_record_h record) + : ContactAddress(release, record) + { + } + + inline int ContactPersonPhoneLog::getId() const + { + return getInt(_contacts_person_phone_log.log_id); + } + + inline int ContactPersonPhoneLog::getOwnerId() const + { + return getInt(_contacts_person_phone_log.person_id); + } + + inline std::string ContactPersonPhoneLog::getDispName() const + { + return getStr(_contacts_person_phone_log.display_name); + } + + inline std::string ContactPersonPhoneLog::getAddress() const + { + return getStr(_contacts_person_phone_log.address); + } + + inline std::string ContactPersonPhoneLog::getThumbnailPath() const + { + return getStr(_contacts_person_phone_log.image_thumbnail_path); + } + + inline const char *ContactPersonPhoneLog::getUri() + { + return _contacts_person_phone_log._uri; + } + + inline ContactRecordRef ContactPersonPhoneLog::clone() const + { + return cloneInternal(); + } + + inline ContactPersonPhoneLog::OwnerType ContactPersonPhoneLog::getOwnerType() const + { + return PersonType; + } } diff --git a/src/Common/ContactManager/inc/ContactRecord.h b/src/Common/ContactManager/inc/ContactRecord.h index 31852b2..bca16bc 100644 --- a/src/Common/ContactManager/inc/ContactRecord.h +++ b/src/Common/ContactManager/inc/ContactRecord.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -22,112 +22,112 @@ #include namespace Msg { - class ContactRecord; - typedef std::shared_ptr ContactRecordRef; - - class ContactRecord { - public: - ContactRecord(); - ContactRecord(bool release, contacts_record_h record = nullptr); - virtual ~ContactRecord(); - ContactRecord(ContactRecord&) = delete; - ContactRecord& operator=(ContactRecord&) = delete; - - void set(contacts_record_h record); - contacts_record_h getRecord() const; - bool isValid() const; - virtual ContactRecordRef clone() const; - - protected: - - template - std::shared_ptr cloneInternal() const; - - std::string getStr(unsigned propertyId) const; - int getInt(unsigned propertyId) const; - int getChildCount(unsigned propertyId) const; - contacts_record_h getChildP(unsigned propertyId, int index) const; - - static std::string getStr(contacts_record_h rec, unsigned propertyId); - static int getInt(contacts_record_h rec, unsigned propertyId); - static int getChildCount(contacts_record_h rec, unsigned propertyId); - static contacts_record_h getChildP(contacts_record_h rec, unsigned propertyId, int index); - - private: - contacts_record_h m_Record; - bool m_Release; - }; - - inline void ContactRecord::set(contacts_record_h record) - { - m_Record = record; - } - - inline contacts_record_h ContactRecord::getRecord() const - { - return m_Record; - } - - inline std::string ContactRecord::getStr(contacts_record_h rec, unsigned propertyId) - { - char *str = nullptr; - contacts_record_get_str_p(rec, propertyId, &str); - return str ? str : std::string(); - } - - inline int ContactRecord::getChildCount(contacts_record_h rec, unsigned propertyId) - { - int count = 0; - contacts_record_get_child_record_count(rec, propertyId, &count); - return count; - } - - inline contacts_record_h ContactRecord::getChildP(contacts_record_h rec, unsigned propertyId, int index) - { - contacts_record_h res = {}; - contacts_record_get_child_record_at_p(rec, propertyId, index, &res); - return res; - } - - inline int ContactRecord::getInt(contacts_record_h rec, unsigned propertyId) - { - int val = 0; - contacts_record_get_int(rec, propertyId, &val); - return val; - } - - inline std::string ContactRecord::getStr(unsigned propertyId) const - { - return getStr(m_Record, propertyId); - } - - inline int ContactRecord::getChildCount(unsigned propertyId) const - { - return getChildCount(m_Record, propertyId); - } - - inline contacts_record_h ContactRecord::getChildP(unsigned propertyId, int index) const - { - return getChildP(m_Record, propertyId, index); - } - - inline int ContactRecord::getInt(unsigned propertyId) const - { - return getInt(m_Record, propertyId); - } - - inline bool ContactRecord::isValid() const - { - return m_Record != nullptr; - } - - template - std::shared_ptr ContactRecord::cloneInternal() const - { - contacts_record_h clonedRec = {}; - contacts_record_clone(m_Record, &clonedRec); - return std::make_shared(true, clonedRec); - } + class ContactRecord; + typedef std::shared_ptr ContactRecordRef; + + class ContactRecord { + public: + ContactRecord(); + ContactRecord(bool release, contacts_record_h record = nullptr); + virtual ~ContactRecord(); + ContactRecord(ContactRecord&) = delete; + ContactRecord& operator=(ContactRecord&) = delete; + + void set(contacts_record_h record); + contacts_record_h getRecord() const; + bool isValid() const; + virtual ContactRecordRef clone() const; + + protected: + + template + std::shared_ptr cloneInternal() const; + + std::string getStr(unsigned propertyId) const; + int getInt(unsigned propertyId) const; + int getChildCount(unsigned propertyId) const; + contacts_record_h getChildP(unsigned propertyId, int index) const; + + static std::string getStr(contacts_record_h rec, unsigned propertyId); + static int getInt(contacts_record_h rec, unsigned propertyId); + static int getChildCount(contacts_record_h rec, unsigned propertyId); + static contacts_record_h getChildP(contacts_record_h rec, unsigned propertyId, int index); + + private: + contacts_record_h m_Record; + bool m_Release; + }; + + inline void ContactRecord::set(contacts_record_h record) + { + m_Record = record; + } + + inline contacts_record_h ContactRecord::getRecord() const + { + return m_Record; + } + + inline std::string ContactRecord::getStr(contacts_record_h rec, unsigned propertyId) + { + char *str = nullptr; + contacts_record_get_str_p(rec, propertyId, &str); + return str ? str : std::string(); + } + + inline int ContactRecord::getChildCount(contacts_record_h rec, unsigned propertyId) + { + int count = 0; + contacts_record_get_child_record_count(rec, propertyId, &count); + return count; + } + + inline contacts_record_h ContactRecord::getChildP(contacts_record_h rec, unsigned propertyId, int index) + { + contacts_record_h res = {}; + contacts_record_get_child_record_at_p(rec, propertyId, index, &res); + return res; + } + + inline int ContactRecord::getInt(contacts_record_h rec, unsigned propertyId) + { + int val = 0; + contacts_record_get_int(rec, propertyId, &val); + return val; + } + + inline std::string ContactRecord::getStr(unsigned propertyId) const + { + return getStr(m_Record, propertyId); + } + + inline int ContactRecord::getChildCount(unsigned propertyId) const + { + return getChildCount(m_Record, propertyId); + } + + inline contacts_record_h ContactRecord::getChildP(unsigned propertyId, int index) const + { + return getChildP(m_Record, propertyId, index); + } + + inline int ContactRecord::getInt(unsigned propertyId) const + { + return getInt(m_Record, propertyId); + } + + inline bool ContactRecord::isValid() const + { + return m_Record != nullptr; + } + + template + std::shared_ptr ContactRecord::cloneInternal() const + { + contacts_record_h clonedRec = {}; + contacts_record_clone(m_Record, &clonedRec); + return std::make_shared(true, clonedRec); + } } #endif /* __ContactRecord_h__ */ diff --git a/src/Common/ContactManager/src/ContactManager.cpp b/src/Common/ContactManager/src/ContactManager.cpp index c5c5083..a5520cb 100644 --- a/src/Common/ContactManager/src/ContactManager.cpp +++ b/src/Common/ContactManager/src/ContactManager.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2016 Samsung Electronics Co., Ltd +* Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -24,463 +24,463 @@ namespace Msg { - const int mapReservSize = 512; - - ContactManager::ContactManager() - { - MSG_LOG(""); - m_AddressMap.reserve(mapReservSize); - int error = contacts_connect(); - if (error != 0) - { - MSG_LOG_ERROR(whatError(error)); - } - - contacts_db_add_changed_cb(_contacts_contact._uri, contactChangedCb, this); - contacts_db_add_changed_cb(_contacts_my_profile._uri, contactChangedCb, this); - contacts_setting_add_name_display_order_changed_cb(contactDisplayOrderChangedCb, this); - } - - ContactManager::~ContactManager() - { - MSG_LOG(""); - int error = contacts_db_remove_changed_cb(_contacts_contact._uri, contactChangedCb, this); - if (error != 0) - MSG_LOG_ERROR(whatError(error)); - - error = contacts_disconnect(); - if (error != 0) - MSG_LOG_ERROR(whatError(error)); - } - - std::string ContactManager::whatError(int error) - { - switch (error) - { - case CONTACTS_ERROR_NONE: - return "CONTACTS_ERROR_NONE"; - case CONTACTS_ERROR_OUT_OF_MEMORY: - return "CONTACTS_ERROR_OUT_OF_MEMORY"; - case CONTACTS_ERROR_INVALID_PARAMETER: - return "CONTACTS_ERROR_INVALID_PARAMETER"; - case CONTACTS_ERROR_FILE_NO_SPACE: - return "CONTACTS_ERROR_FILE_NO_SPACE"; - case CONTACTS_ERROR_PERMISSION_DENIED: - return "CONTACTS_ERROR_PERMISSION_DENIED"; - case CONTACTS_ERROR_NOT_SUPPORTED: - return "CONTACTS_ERROR_NOT_SUPPORTED"; - case CONTACTS_ERROR_NO_DATA: - return "CONTACTS_ERROR_NO_DATA"; - case CONTACTS_ERROR_DB_LOCKED: - return "CONTACTS_ERROR_DB_LOCKED"; - case CONTACTS_ERROR_DB: - return "CONTACTS_ERROR_DB"; - case CONTACTS_ERROR_IPC_NOT_AVALIABLE: - return "CONTACTS_ERROR_IPC_NOT_AVALIABLE"; - case CONTACTS_ERROR_IPC: - return "CONTACTS_ERROR_IPC"; - case CONTACTS_ERROR_SYSTEM: - return "CONTACTS_ERROR_SYSTEM"; - case CONTACTS_ERROR_INTERNAL: - return "CONTACTS_ERROR_INTERNAL"; - } - - return "Unknown error"; - } - - template <> - std::shared_ptr> ContactManager::search(const std::string &keyword) - { - contacts_query_h query = nullptr; - contacts_filter_h filter = nullptr; - contacts_list_h list = nullptr; - - contacts_query_create(_contacts_person_phone_log._uri, &query); - contacts_filter_create(_contacts_person_phone_log._uri, &filter); - contacts_filter_add_str(filter, _contacts_person_phone_log.address, CONTACTS_MATCH_CONTAINS, keyword.c_str()); - contacts_filter_add_operator(filter, CONTACTS_FILTER_OPERATOR_AND); - contacts_filter_add_int(filter, _contacts_person_phone_log.person_id, CONTACTS_MATCH_NONE, 0); - contacts_query_set_filter(query, filter); - - /* set projection */ - unsigned int numberProjection[] = - { - _contacts_person_phone_log.person_id, - _contacts_person_phone_log.address, - _contacts_person_phone_log.display_name - }; - - contacts_query_set_projection(query, numberProjection, sizeof(numberProjection)/sizeof(unsigned int)); - contacts_query_set_distinct(query, true); - - contacts_db_get_records_with_query(query, 0, 0, &list); - contacts_filter_destroy(filter); - contacts_query_destroy(query); - - return list ? std::make_shared>(list) : nullptr; - } - - template<> - std::shared_ptr> ContactManager::search(const std::string &keyword) - { - contacts_list_h list = nullptr; - contacts_db_search_records_with_range(ContactPersonNumber::getUri(), keyword.c_str(), - 0, 0, CONTACTS_SEARCH_RANGE_NAME | CONTACTS_SEARCH_RANGE_NUMBER, &list); - return list ? std::make_shared>(list) : nullptr; - } - - template<> - std::shared_ptr> ContactManager::search(const std::string &keyword) - { - contacts_list_h list = nullptr; - contacts_db_search_records_with_range(ContactPersonEmail::getUri(), keyword.c_str(), - 0, 0, CONTACTS_SEARCH_RANGE_NAME | CONTACTS_SEARCH_RANGE_EMAIL, &list); - return list ? std::make_shared>(list) : nullptr; - } - - ContactPersonNumberRef ContactManager::getContactPersonNumber(int phoneNumId) - { - contacts_filter_h filter = nullptr; - contacts_filter_create(_contacts_contact_number._uri, &filter); - contacts_filter_add_int(filter, _contacts_person_number.number_id, CONTACTS_MATCH_EQUAL, phoneNumId); - return filter ? getContactPersonNumber(filter) : nullptr; - } - - ContactPersonEmailRef ContactManager::getContactPersonEmail(int emailId) - { - contacts_filter_h filter = nullptr; - contacts_filter_create(_contacts_contact_email._uri, &filter); - contacts_filter_add_int(filter, _contacts_person_email.email_id, CONTACTS_MATCH_EQUAL, emailId); - return filter ? getContactPersonEmail(filter) : nullptr; - } - - ContactPersonNumberRef ContactManager::getContactPersonNumber(const std::string &number) - { - contacts_filter_h filter = nullptr; - contacts_filter_create(_contacts_contact_number._uri, &filter); - contacts_filter_add_str(filter, _contacts_person_number.number_filter, CONTACTS_MATCH_EXACTLY, number.c_str()); - return filter ? getContactPersonNumber(filter) : nullptr; - } - - ContactPersonEmailRef ContactManager::getContactPersonEmail(const std::string &email) - { - contacts_filter_h filter = nullptr; - contacts_filter_create(_contacts_contact_email._uri, &filter); - contacts_filter_add_str(filter, _contacts_person_email.email, CONTACTS_MATCH_FULLSTRING, email.c_str()); - return filter ? getContactPersonEmail(filter) : nullptr; - } - - ContactPersonPhoneLogRef ContactManager::getContactPersonPhoneLog(const std::string &address) - { - contacts_filter_h filter = nullptr; - contacts_filter_create(_contacts_person_phone_log._uri, &filter); - contacts_filter_add_str(filter, _contacts_person_phone_log.address, CONTACTS_MATCH_FULLSTRING, address.c_str()); - return filter ? getContactPersonPhoneLog(filter) : nullptr; - } - - ContactMyProfileNumberRef ContactManager::getContactMyProfileNumber(const std::string &number) - { - auto myProfile = getOwnerProfile(); - if (!myProfile) - return nullptr; - - contacts_record_h rec = myProfile->getRecord(); - - int count = 0; - 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) - { - contacts_record_h child = nullptr; - contacts_record_get_child_record_at_p(rec, _contacts_my_profile.number, i, &child); - if (child) - { - char *num = nullptr; - contacts_record_get_str_p(child, _contacts_number.number, &num); - if (num) - { - std::string curNum = PhoneNumberUtils::getInst().getNormalizedNumber(num); - if (normalizedNumber == curNum) - { - contacts_record_h clonedRec = nullptr; - contacts_record_clone(child, &clonedRec); - if (clonedRec) - return std::make_shared(true, *myProfile, clonedRec); - } - } - } - } - return nullptr; - } - - ContactMyProfileEmailRef ContactManager::getContactMyProfileEmail(const std::string &email) - { - auto myProfile = getOwnerProfile(); - 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) - { - contacts_record_h child = nullptr; - contacts_record_get_child_record_at_p(rec, _contacts_my_profile.email, i, &child); - if (child) - { - char *curEmail = nullptr; - contacts_record_get_str_p(child, _contacts_email.email, &curEmail); - if (curEmail) - { - if (strcasecmp(email.c_str(), curEmail) == 0) - { - contacts_record_h clonedRec = nullptr; - contacts_record_clone(child, &clonedRec); - if (clonedRec) - return std::make_shared(true, *myProfile, clonedRec); - } - } - } - } - return nullptr; - } - - ContactAddressRef ContactManager::getContactAddress(const std::string &address) - { - return getAddress(address); - } - - ContactMyProfileRef ContactManager::getOwnerProfile() - { - 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) - { - contacts_list_get_current_record_p(list, &myProfile); - contacts_list_destroy(list, false); - } - if (myProfile) - m_OwnerProfile.reset(new ContactMyProfile(true, myProfile)); - } - return m_OwnerProfile; - } - - void ContactManager::contactChangedCb(const char *view_uri, void *user_data) - { - ContactManager *self = static_cast(user_data); - self->invalidateCache(); - for (auto listener : self->m_Listeners) - { - listener->onContactChanged(); - } - } - - void ContactManager::contactDisplayOrderChangedCb(contacts_name_display_order_e name_display_order, void *user_data) - { - ContactManager *self = static_cast(user_data); - self->invalidateCache(); - 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()) - { - 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()) - { - m_Listeners.erase(found); - } - } - - ContactPersonNumberRef ContactManager::getContactPersonNumber(contacts_filter_h filter) - { - contacts_query_h query = nullptr; - contacts_list_h list = nullptr; - contacts_record_h crValue = nullptr; - contacts_record_h cResValue = nullptr; - - contacts_query_create(_contacts_person_number._uri, &query); - contacts_query_set_filter(query, filter); - - unsigned int numberProjection[] = - { - _contacts_person_number.person_id, - _contacts_person_number.number, - _contacts_person_number.display_name, - _contacts_person_number.image_thumbnail_path - }; - - int ctRrr = contacts_query_set_projection(query, numberProjection, sizeof(numberProjection) / sizeof(unsigned int)); - 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) - { - int contactId = 0; - - contacts_list_get_current_record_p(list, &crValue); - if (crValue) - { - contacts_record_get_int(crValue, _contacts_person_number.person_id, &contactId); - if (contactId > 0) - cResValue = crValue; - else - contacts_record_destroy(crValue, true); - } - ctRrr = contacts_list_next(list); - } - - contacts_list_destroy(list, false); - return cResValue ? std::make_shared(true, cResValue) : nullptr; - } - - ContactPersonEmailRef ContactManager::getContactPersonEmail(contacts_filter_h filter) - { - contacts_query_h query = nullptr; - contacts_list_h list = nullptr; - contacts_record_h crValue = nullptr; - contacts_record_h cResValue = nullptr; - - contacts_query_create(_contacts_person_email._uri, &query); - contacts_query_set_filter(query, filter); - - unsigned int numberProjection[] = - { - _contacts_person_email.person_id, - _contacts_person_email.email, - _contacts_person_email.display_name, - _contacts_person_email.image_thumbnail_path - }; - - int ctRrr = contacts_query_set_projection(query, numberProjection, sizeof(numberProjection) / sizeof(unsigned int)); - 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) - { - int contactId = 0; - - contacts_list_get_current_record_p(list, &crValue); - if (crValue) - { - contacts_record_get_int(crValue, _contacts_person_email.person_id, &contactId); - if (contactId > 0) - cResValue = crValue; - else - contacts_record_destroy(crValue, true); - } - ctRrr = contacts_list_next(list); - } - - contacts_list_destroy(list, false); - return cResValue ? std::make_shared(true, cResValue) : nullptr; - } - - ContactPersonPhoneLogRef ContactManager::getContactPersonPhoneLog(contacts_filter_h filter) - { - contacts_query_h query = nullptr; - contacts_list_h list = nullptr; - contacts_record_h crValue = nullptr; - contacts_record_h cResValue = nullptr; - - contacts_query_create(_contacts_person_phone_log._uri, &query); - contacts_query_set_filter(query, filter); - - unsigned int projection[] = { - _contacts_person_phone_log.person_id, - _contacts_person_phone_log.address, - _contacts_person_phone_log.display_name, - _contacts_person_phone_log.image_thumbnail_path - }; - - int ctRrr = contacts_query_set_projection(query, projection, sizeof(projection) / sizeof(unsigned int)); - 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) { - int logId = 0; - - contacts_list_get_current_record_p(list, &crValue); - if (crValue) { - contacts_record_get_int(crValue, _contacts_person_phone_log.log_id, &logId); - if (logId > 0) - cResValue = crValue; - else - contacts_record_destroy(crValue, true); - } - ctRrr = contacts_list_next(list); - } - - contacts_list_destroy(list, false); - return cResValue ? std::make_shared(true, cResValue) : nullptr; - } - - ContactAddressRef ContactManager::getAddress(const std::string &address) - { - auto it = m_AddressMap.find(address); - if (m_AddressMap.end() == it) - { - bool isNumber = MsgUtils::isValidNumber(address); - - // ContactPerson: - ContactAddressRef contactAddress; - if (isNumber) - contactAddress = getContactPersonNumber(address); - else - contactAddress = getContactPersonEmail(address); - - - // MyProfile: - #if (0) - if (!contactAddress) - { - if (isNumber) - contactAddress = getContactMyProfileNumber(address); - else - contactAddress = getContactMyProfileEmail(address); - } - #endif - - if (!contactAddress) - contactAddress = getContactPersonPhoneLog(address); - - m_AddressMap[address] = contactAddress; - return contactAddress; - } - return it->second; - } - - void ContactManager::invalidateCache() - { - MSG_LOG(""); - m_AddressMap.clear(); - m_OwnerProfile.reset(); - } + const int mapReservSize = 512; + + ContactManager::ContactManager() + { + MSG_LOG(""); + m_AddressMap.reserve(mapReservSize); + int error = contacts_connect(); + if (error != 0) + { + MSG_LOG_ERROR(whatError(error)); + } + + contacts_db_add_changed_cb(_contacts_contact._uri, contactChangedCb, this); + contacts_db_add_changed_cb(_contacts_my_profile._uri, contactChangedCb, this); + contacts_setting_add_name_display_order_changed_cb(contactDisplayOrderChangedCb, this); + } + + ContactManager::~ContactManager() + { + MSG_LOG(""); + int error = contacts_db_remove_changed_cb(_contacts_contact._uri, contactChangedCb, this); + if (error != 0) + MSG_LOG_ERROR(whatError(error)); + + error = contacts_disconnect(); + if (error != 0) + MSG_LOG_ERROR(whatError(error)); + } + + std::string ContactManager::whatError(int error) + { + switch (error) + { + case CONTACTS_ERROR_NONE: + return "CONTACTS_ERROR_NONE"; + case CONTACTS_ERROR_OUT_OF_MEMORY: + return "CONTACTS_ERROR_OUT_OF_MEMORY"; + case CONTACTS_ERROR_INVALID_PARAMETER: + return "CONTACTS_ERROR_INVALID_PARAMETER"; + case CONTACTS_ERROR_FILE_NO_SPACE: + return "CONTACTS_ERROR_FILE_NO_SPACE"; + case CONTACTS_ERROR_PERMISSION_DENIED: + return "CONTACTS_ERROR_PERMISSION_DENIED"; + case CONTACTS_ERROR_NOT_SUPPORTED: + return "CONTACTS_ERROR_NOT_SUPPORTED"; + case CONTACTS_ERROR_NO_DATA: + return "CONTACTS_ERROR_NO_DATA"; + case CONTACTS_ERROR_DB_LOCKED: + return "CONTACTS_ERROR_DB_LOCKED"; + case CONTACTS_ERROR_DB: + return "CONTACTS_ERROR_DB"; + case CONTACTS_ERROR_IPC_NOT_AVALIABLE: + return "CONTACTS_ERROR_IPC_NOT_AVALIABLE"; + case CONTACTS_ERROR_IPC: + return "CONTACTS_ERROR_IPC"; + case CONTACTS_ERROR_SYSTEM: + return "CONTACTS_ERROR_SYSTEM"; + case CONTACTS_ERROR_INTERNAL: + return "CONTACTS_ERROR_INTERNAL"; + } + + return "Unknown error"; + } + + template <> + std::shared_ptr> ContactManager::search(const std::string &keyword) + { + contacts_query_h query = nullptr; + contacts_filter_h filter = nullptr; + contacts_list_h list = nullptr; + + contacts_query_create(_contacts_person_phone_log._uri, &query); + contacts_filter_create(_contacts_person_phone_log._uri, &filter); + contacts_filter_add_str(filter, _contacts_person_phone_log.address, CONTACTS_MATCH_CONTAINS, keyword.c_str()); + contacts_filter_add_operator(filter, CONTACTS_FILTER_OPERATOR_AND); + contacts_filter_add_int(filter, _contacts_person_phone_log.person_id, CONTACTS_MATCH_NONE, 0); + contacts_query_set_filter(query, filter); + + /* set projection */ + unsigned int numberProjection[] = + { + _contacts_person_phone_log.person_id, + _contacts_person_phone_log.address, + _contacts_person_phone_log.display_name + }; + + contacts_query_set_projection(query, numberProjection, sizeof(numberProjection)/sizeof(unsigned int)); + contacts_query_set_distinct(query, true); + + contacts_db_get_records_with_query(query, 0, 0, &list); + contacts_filter_destroy(filter); + contacts_query_destroy(query); + + return list ? std::make_shared>(list) : nullptr; + } + + template<> + std::shared_ptr> ContactManager::search(const std::string &keyword) + { + contacts_list_h list = nullptr; + contacts_db_search_records_with_range(ContactPersonNumber::getUri(), keyword.c_str(), + 0, 0, CONTACTS_SEARCH_RANGE_NAME | CONTACTS_SEARCH_RANGE_NUMBER, &list); + return list ? std::make_shared>(list) : nullptr; + } + + template<> + std::shared_ptr> ContactManager::search(const std::string &keyword) + { + contacts_list_h list = nullptr; + contacts_db_search_records_with_range(ContactPersonEmail::getUri(), keyword.c_str(), + 0, 0, CONTACTS_SEARCH_RANGE_NAME | CONTACTS_SEARCH_RANGE_EMAIL, &list); + return list ? std::make_shared>(list) : nullptr; + } + + ContactPersonNumberRef ContactManager::getContactPersonNumber(int phoneNumId) + { + contacts_filter_h filter = nullptr; + contacts_filter_create(_contacts_contact_number._uri, &filter); + contacts_filter_add_int(filter, _contacts_person_number.number_id, CONTACTS_MATCH_EQUAL, phoneNumId); + return filter ? getContactPersonNumber(filter) : nullptr; + } + + ContactPersonEmailRef ContactManager::getContactPersonEmail(int emailId) + { + contacts_filter_h filter = nullptr; + contacts_filter_create(_contacts_contact_email._uri, &filter); + contacts_filter_add_int(filter, _contacts_person_email.email_id, CONTACTS_MATCH_EQUAL, emailId); + return filter ? getContactPersonEmail(filter) : nullptr; + } + + ContactPersonNumberRef ContactManager::getContactPersonNumber(const std::string &number) + { + contacts_filter_h filter = nullptr; + contacts_filter_create(_contacts_contact_number._uri, &filter); + contacts_filter_add_str(filter, _contacts_person_number.number_filter, CONTACTS_MATCH_EXACTLY, number.c_str()); + return filter ? getContactPersonNumber(filter) : nullptr; + } + + ContactPersonEmailRef ContactManager::getContactPersonEmail(const std::string &email) + { + contacts_filter_h filter = nullptr; + contacts_filter_create(_contacts_contact_email._uri, &filter); + contacts_filter_add_str(filter, _contacts_person_email.email, CONTACTS_MATCH_FULLSTRING, email.c_str()); + return filter ? getContactPersonEmail(filter) : nullptr; + } + + ContactPersonPhoneLogRef ContactManager::getContactPersonPhoneLog(const std::string &address) + { + contacts_filter_h filter = nullptr; + contacts_filter_create(_contacts_person_phone_log._uri, &filter); + contacts_filter_add_str(filter, _contacts_person_phone_log.address, CONTACTS_MATCH_FULLSTRING, address.c_str()); + return filter ? getContactPersonPhoneLog(filter) : nullptr; + } + + ContactMyProfileNumberRef ContactManager::getContactMyProfileNumber(const std::string &number) + { + auto myProfile = getOwnerProfile(); + if (!myProfile) + return nullptr; + + contacts_record_h rec = myProfile->getRecord(); + + int count = 0; + 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) + { + contacts_record_h child = nullptr; + contacts_record_get_child_record_at_p(rec, _contacts_my_profile.number, i, &child); + if (child) + { + char *num = nullptr; + contacts_record_get_str_p(child, _contacts_number.number, &num); + if (num) + { + std::string curNum = PhoneNumberUtils::getInst().getNormalizedNumber(num); + if (normalizedNumber == curNum) + { + contacts_record_h clonedRec = nullptr; + contacts_record_clone(child, &clonedRec); + if (clonedRec) + return std::make_shared(true, *myProfile, clonedRec); + } + } + } + } + return nullptr; + } + + ContactMyProfileEmailRef ContactManager::getContactMyProfileEmail(const std::string &email) + { + auto myProfile = getOwnerProfile(); + 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) + { + contacts_record_h child = nullptr; + contacts_record_get_child_record_at_p(rec, _contacts_my_profile.email, i, &child); + if (child) + { + char *curEmail = nullptr; + contacts_record_get_str_p(child, _contacts_email.email, &curEmail); + if (curEmail) + { + if (strcasecmp(email.c_str(), curEmail) == 0) + { + contacts_record_h clonedRec = nullptr; + contacts_record_clone(child, &clonedRec); + if (clonedRec) + return std::make_shared(true, *myProfile, clonedRec); + } + } + } + } + return nullptr; + } + + ContactAddressRef ContactManager::getContactAddress(const std::string &address) + { + return getAddress(address); + } + + ContactMyProfileRef ContactManager::getOwnerProfile() + { + 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) + { + contacts_list_get_current_record_p(list, &myProfile); + contacts_list_destroy(list, false); + } + if (myProfile) + m_OwnerProfile.reset(new ContactMyProfile(true, myProfile)); + } + return m_OwnerProfile; + } + + void ContactManager::contactChangedCb(const char *view_uri, void *user_data) + { + ContactManager *self = static_cast(user_data); + self->invalidateCache(); + for (auto listener : self->m_Listeners) + { + listener->onContactChanged(); + } + } + + void ContactManager::contactDisplayOrderChangedCb(contacts_name_display_order_e name_display_order, void *user_data) + { + ContactManager *self = static_cast(user_data); + self->invalidateCache(); + 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()) + { + 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()) + { + m_Listeners.erase(found); + } + } + + ContactPersonNumberRef ContactManager::getContactPersonNumber(contacts_filter_h filter) + { + contacts_query_h query = nullptr; + contacts_list_h list = nullptr; + contacts_record_h crValue = nullptr; + contacts_record_h cResValue = nullptr; + + contacts_query_create(_contacts_person_number._uri, &query); + contacts_query_set_filter(query, filter); + + unsigned int numberProjection[] = + { + _contacts_person_number.person_id, + _contacts_person_number.number, + _contacts_person_number.display_name, + _contacts_person_number.image_thumbnail_path + }; + + int ctRrr = contacts_query_set_projection(query, numberProjection, sizeof(numberProjection) / sizeof(unsigned int)); + 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) + { + int contactId = 0; + + contacts_list_get_current_record_p(list, &crValue); + if (crValue) + { + contacts_record_get_int(crValue, _contacts_person_number.person_id, &contactId); + if (contactId > 0) + cResValue = crValue; + else + contacts_record_destroy(crValue, true); + } + ctRrr = contacts_list_next(list); + } + + contacts_list_destroy(list, false); + return cResValue ? std::make_shared(true, cResValue) : nullptr; + } + + ContactPersonEmailRef ContactManager::getContactPersonEmail(contacts_filter_h filter) + { + contacts_query_h query = nullptr; + contacts_list_h list = nullptr; + contacts_record_h crValue = nullptr; + contacts_record_h cResValue = nullptr; + + contacts_query_create(_contacts_person_email._uri, &query); + contacts_query_set_filter(query, filter); + + unsigned int numberProjection[] = + { + _contacts_person_email.person_id, + _contacts_person_email.email, + _contacts_person_email.display_name, + _contacts_person_email.image_thumbnail_path + }; + + int ctRrr = contacts_query_set_projection(query, numberProjection, sizeof(numberProjection) / sizeof(unsigned int)); + 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) + { + int contactId = 0; + + contacts_list_get_current_record_p(list, &crValue); + if (crValue) + { + contacts_record_get_int(crValue, _contacts_person_email.person_id, &contactId); + if (contactId > 0) + cResValue = crValue; + else + contacts_record_destroy(crValue, true); + } + ctRrr = contacts_list_next(list); + } + + contacts_list_destroy(list, false); + return cResValue ? std::make_shared(true, cResValue) : nullptr; + } + + ContactPersonPhoneLogRef ContactManager::getContactPersonPhoneLog(contacts_filter_h filter) + { + contacts_query_h query = nullptr; + contacts_list_h list = nullptr; + contacts_record_h crValue = nullptr; + contacts_record_h cResValue = nullptr; + + contacts_query_create(_contacts_person_phone_log._uri, &query); + contacts_query_set_filter(query, filter); + + unsigned int projection[] = { + _contacts_person_phone_log.person_id, + _contacts_person_phone_log.address, + _contacts_person_phone_log.display_name, + _contacts_person_phone_log.image_thumbnail_path + }; + + int ctRrr = contacts_query_set_projection(query, projection, sizeof(projection) / sizeof(unsigned int)); + 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) { + int logId = 0; + + contacts_list_get_current_record_p(list, &crValue); + if (crValue) { + contacts_record_get_int(crValue, _contacts_person_phone_log.log_id, &logId); + if (logId > 0) + cResValue = crValue; + else + contacts_record_destroy(crValue, true); + } + ctRrr = contacts_list_next(list); + } + + contacts_list_destroy(list, false); + return cResValue ? std::make_shared(true, cResValue) : nullptr; + } + + ContactAddressRef ContactManager::getAddress(const std::string &address) + { + auto it = m_AddressMap.find(address); + if (m_AddressMap.end() == it) + { + bool isNumber = MsgUtils::isValidNumber(address); + + // ContactPerson: + ContactAddressRef contactAddress; + if (isNumber) + contactAddress = getContactPersonNumber(address); + else + contactAddress = getContactPersonEmail(address); + + + // MyProfile: + #if (0) + if (!contactAddress) + { + if (isNumber) + contactAddress = getContactMyProfileNumber(address); + else + contactAddress = getContactMyProfileEmail(address); + } + #endif + + if (!contactAddress) + contactAddress = getContactPersonPhoneLog(address); + + m_AddressMap[address] = contactAddress; + return contactAddress; + } + return it->second; + } + + void ContactManager::invalidateCache() + { + MSG_LOG(""); + m_AddressMap.clear(); + m_OwnerProfile.reset(); + } } diff --git a/src/Common/ContactManager/src/ContactRecord.cpp b/src/Common/ContactManager/src/ContactRecord.cpp index 5641c54..3d187be 100644 --- a/src/Common/ContactManager/src/ContactRecord.cpp +++ b/src/Common/ContactManager/src/ContactRecord.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2016 Samsung Electronics Co., Ltd +* Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -19,21 +19,21 @@ using namespace Msg; ContactRecord::ContactRecord(bool release, contacts_record_h record) - : m_Record(record) - , m_Release(release) + : m_Record(record) + , m_Release(release) { } ContactRecord::~ContactRecord() { - if (m_Record && m_Release) - { - contacts_record_destroy(m_Record, true); - m_Record = nullptr; - } + if (m_Record && m_Release) + { + contacts_record_destroy(m_Record, true); + m_Record = nullptr; + } } ContactRecordRef ContactRecord::clone() const { - return cloneInternal(); + return cloneInternal(); } diff --git a/src/Common/ContactManager/src/ContactVCardGenerator.cpp b/src/Common/ContactManager/src/ContactVCardGenerator.cpp index aa0630b..e57cca7 100644 --- a/src/Common/ContactManager/src/ContactVCardGenerator.cpp +++ b/src/Common/ContactManager/src/ContactVCardGenerator.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2016 Samsung Electronics Co., Ltd +* Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -25,68 +25,68 @@ using namespace Msg; namespace { - const int avgLengthOfContent = 2048; + const int avgLengthOfContent = 2048; } std::string ContactManager::makeVcard(const int personId, bool myProfile) { - contacts_record_h record = nullptr; - std::string vcardContent; + 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) - { - MSG_LOG_ERROR("contacts_db_get_record() failed"); - record = nullptr; - return std::string(); - } - vcardContent = createContactContent(record, myProfile); + 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; + return std::string(); + } + vcardContent = createContactContent(record, myProfile); - if (record) - contacts_record_destroy(record, true); + if (record) + contacts_record_destroy(record, true); - return vcardContent; + return vcardContent; } std::string ContactManager::makeVcard(const std::list &idList) { - std::string vcardContent; - vcardContent.reserve(idList.size() * avgLengthOfContent); - for (auto it : idList) - vcardContent += createContentForContactList(it); + std::string vcardContent; + vcardContent.reserve(idList.size() * avgLengthOfContent); + for (auto it : idList) + vcardContent += createContentForContactList(it); - return vcardContent; + return vcardContent; } std::string ContactManager::createContactContent(contacts_record_h record, bool myProfile) { - char *vcardBuff = nullptr; + char *vcardBuff = nullptr; - myProfile ? contacts_vcard_make_from_my_profile(record, &vcardBuff) : contacts_vcard_make_from_person(record, &vcardBuff); + myProfile ? contacts_vcard_make_from_my_profile(record, &vcardBuff) : contacts_vcard_make_from_person(record, &vcardBuff); - if (!vcardBuff) - { - MSG_LOG_ERROR("vcardBuff is NULL"); - return std::string(); - } + if (!vcardBuff) + { + MSG_LOG_ERROR("vcardBuff is NULL"); + return std::string(); + } - std::string result(vcardBuff); - free(vcardBuff); - return result; + std::string result(vcardBuff); + free(vcardBuff); + return result; } std::string ContactManager::createContentForContactList(int personId) { - contacts_record_h record = nullptr; - if (contacts_db_get_record(_contacts_person._uri, personId, &record) != CONTACTS_ERROR_NONE) - { - MSG_LOG_ERROR("contacts_db_get_record() failed!"); - record = nullptr; - return std::string(); - } - std::string result = createContactContent(record, false); - - if (record) - contacts_record_destroy(record, true); - - return result; + contacts_record_h record = nullptr; + if (contacts_db_get_record(_contacts_person._uri, personId, &record) != CONTACTS_ERROR_NONE) + { + MSG_LOG_ERROR("contacts_db_get_record() failed!"); + record = nullptr; + return std::string(); + } + std::string result = createContactContent(record, false); + + if (record) + contacts_record_destroy(record, true); + + return result; } diff --git a/src/Common/ContactManager/src/ContactVCardParser.cpp b/src/Common/ContactManager/src/ContactVCardParser.cpp index 370d053..55bbabf 100644 --- a/src/Common/ContactManager/src/ContactVCardParser.cpp +++ b/src/Common/ContactManager/src/ContactVCardParser.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2016 Samsung Electronics Co., Ltd +* Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -27,25 +27,25 @@ using namespace Msg; std::list ContactManager::parseVcard(const std::string &filePath) { - std::list res; + std::list res; - if (filePath.empty()) - return res; + if (filePath.empty()) + return res; - int parseRes = contacts_vcard_parse_to_contact_foreach - ( - filePath.c_str(), - [](contacts_record_h record, void *user_data)->bool - { - contacts_record_h recordClone = {}; - contacts_record_clone(record, &recordClone); - auto *list = (std::list*)user_data; - auto recRef = std::make_shared(true, recordClone); - list->emplace_back(recRef); - return true; - }, - &res); + int parseRes = contacts_vcard_parse_to_contact_foreach + ( + filePath.c_str(), + [](contacts_record_h record, void *user_data)->bool + { + contacts_record_h recordClone = {}; + contacts_record_clone(record, &recordClone); + auto *list = (std::list*)user_data; + auto recRef = std::make_shared(true, recordClone); + list->emplace_back(recRef); + return true; + }, + &res); - MSG_LOG("Parse result: ", parseRes); - return res; + MSG_LOG("Parse result: ", parseRes); + return res; } diff --git a/src/Common/Controller/inc/App.h b/src/Common/Controller/inc/App.h index 3a20b43..4a0272d 100644 --- a/src/Common/Controller/inc/App.h +++ b/src/Common/Controller/inc/App.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -23,91 +23,91 @@ #include namespace Msg { - class IAppListener; - class StandardWindow; - class NaviFrameController; - class PopupManager; - class MsgEngine; - class ContactManager; - class ThumbnailMaker; - class SystemSettingsManager; - class AppControlLauncher; - class MsgInputSelector; - - class App { - public: - static App &getInst(); - - void exit(); - void addListener(IAppListener &l); - void removeListener(IAppListener &l); - bool isPause() const; - bool isTerminating() const; - void updateActiveNotifPolicy(); - - Window &getWindow(); - const Window &getWindow() const; - - PopupManager &getPopupManager(); - const PopupManager &getPopupManager() const; - - MsgEngine &getMsgEngine(); - const MsgEngine &getMsgEngine() const; - - ContactManager &getContactManager(); - const ContactManager &getContactManager() const; - - ThumbnailMaker &getThumbnailMaker(); - const ThumbnailMaker &getThumbnailMaker() const; - - SystemSettingsManager &getSysSettingsManager(); - const SystemSettingsManager &getSysSettingsManager() const; - - NaviFrameController &getNavigation(); - const NaviFrameController &getNavigation() const; - - AppControlLauncher &getLauncher(); - const AppControlLauncher &getLauncher() const; - - protected: - App(); - ~App(); - void updateCharacterOrientation(); - virtual void terminate() = 0; // Close app. completely - bool onCreate(); - void onTerminate(); - void onPause(); - void onResume(); - void onAppControl(app_control_h app_control); - void onLanguageChanged(app_event_info_h appEvent); - void onLowBattery(app_event_info_h appEvent); - void onRegionChanged(app_event_info_h appEvent); - - private: - void addTheme(const std::string &themePath); - - private: - Window *m_pWindow; - MsgEngine *m_pEngine; - ContactManager *m_pContactManager; - PopupManager *m_pPopupManager; - ThumbnailMaker *m_pThumbnailMaker; - SystemSettingsManager *m_pSysSettingsManager; - std::list m_Listeners; - NaviFrameController *m_pNaviFrame; - AppControlLauncher *m_pLauncher; - bool m_IsPause; - bool m_IsTerminating; - bool m_NeedToCloseApp; - }; - - class IAppListener - { - public: - virtual ~IAppListener() {} - virtual void onAppPause() {}; - virtual void onAppResume() {}; - }; + class IAppListener; + class StandardWindow; + class NaviFrameController; + class PopupManager; + class MsgEngine; + class ContactManager; + class ThumbnailMaker; + class SystemSettingsManager; + class AppControlLauncher; + class MsgInputSelector; + + class App { + public: + static App &getInst(); + + void exit(); + void addListener(IAppListener &l); + void removeListener(IAppListener &l); + bool isPause() const; + bool isTerminating() const; + void updateActiveNotifPolicy(); + + Window &getWindow(); + const Window &getWindow() const; + + PopupManager &getPopupManager(); + const PopupManager &getPopupManager() const; + + MsgEngine &getMsgEngine(); + const MsgEngine &getMsgEngine() const; + + ContactManager &getContactManager(); + const ContactManager &getContactManager() const; + + ThumbnailMaker &getThumbnailMaker(); + const ThumbnailMaker &getThumbnailMaker() const; + + SystemSettingsManager &getSysSettingsManager(); + const SystemSettingsManager &getSysSettingsManager() const; + + NaviFrameController &getNavigation(); + const NaviFrameController &getNavigation() const; + + AppControlLauncher &getLauncher(); + const AppControlLauncher &getLauncher() const; + + protected: + App(); + ~App(); + void updateCharacterOrientation(); + virtual void terminate() = 0; // Close app. completely + bool onCreate(); + void onTerminate(); + void onPause(); + void onResume(); + void onAppControl(app_control_h app_control); + void onLanguageChanged(app_event_info_h appEvent); + void onLowBattery(app_event_info_h appEvent); + void onRegionChanged(app_event_info_h appEvent); + + private: + void addTheme(const std::string &themePath); + + private: + Window *m_pWindow; + MsgEngine *m_pEngine; + ContactManager *m_pContactManager; + PopupManager *m_pPopupManager; + ThumbnailMaker *m_pThumbnailMaker; + SystemSettingsManager *m_pSysSettingsManager; + std::list m_Listeners; + NaviFrameController *m_pNaviFrame; + AppControlLauncher *m_pLauncher; + bool m_IsPause; + bool m_IsTerminating; + bool m_NeedToCloseApp; + }; + + class IAppListener + { + public: + virtual ~IAppListener() {} + virtual void onAppPause() {}; + virtual void onAppResume() {}; + }; } #endif /* Application_h_ */ diff --git a/src/Common/Controller/inc/ConnectivityChecker.h b/src/Common/Controller/inc/ConnectivityChecker.h index 6189cb6..8a3109f 100644 --- a/src/Common/Controller/inc/ConnectivityChecker.h +++ b/src/Common/Controller/inc/ConnectivityChecker.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -21,40 +21,40 @@ namespace Msg { - class SystemSettingsManager; - class Popup; + class SystemSettingsManager; + class Popup; - class ConnectivityChecker { - public: - ConnectivityChecker(); + class ConnectivityChecker { + public: + ConnectivityChecker(); - bool isSimInserted(); - bool isFlightModeDisabled(); - bool isMobileDataEnabled(); - bool isRoamingDataEnabled(); + bool isSimInserted(); + bool isFlightModeDisabled(); + bool isMobileDataEnabled(); + bool isRoamingDataEnabled(); - bool isReadyToSendSms(); - bool isReadyToSendMms(); + bool isReadyToSendSms(); + bool isReadyToSendMms(); - private: - ConnectivityChecker(const ConnectivityChecker &) = delete; - ConnectivityChecker &operator=(const ConnectivityChecker &) = delete; + private: + ConnectivityChecker(const ConnectivityChecker &) = delete; + ConnectivityChecker &operator=(const ConnectivityChecker &) = delete; - SystemSettingsManager &getSysSettings(); + SystemSettingsManager &getSysSettings(); - void showNoSimCardPopup(); - void showDisableFlightModePopup(); - void showMobileNetworkSettingsPopup(); - void showUnableDataRoamingPopup(); + void showNoSimCardPopup(); + void showDisableFlightModePopup(); + void showMobileNetworkSettingsPopup(); + void showUnableDataRoamingPopup(); - void onTurnOffFlightModeClicked(Popup &popup); - void onAllowTransmissionTextClicked(Popup &popup); - void onMobileNetworkSettingsClicked(Popup &popup); - void onEnableDataRoamingClicked(Popup &popup); + void onTurnOffFlightModeClicked(Popup &popup); + void onAllowTransmissionTextClicked(Popup &popup); + void onMobileNetworkSettingsClicked(Popup &popup); + void onEnableDataRoamingClicked(Popup &popup); - private: - SettingsLauncher m_SettingsLauncher; - }; + private: + SettingsLauncher m_SettingsLauncher; + }; } #endif /* ConnectivityChecker_h_ */ diff --git a/src/Common/Controller/inc/FrameController.h b/src/Common/Controller/inc/FrameController.h index 5eb9770..74ffe15 100644 --- a/src/Common/Controller/inc/FrameController.h +++ b/src/Common/Controller/inc/FrameController.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -24,49 +24,49 @@ namespace Msg { - class NaviFrameController; + class NaviFrameController; - class FrameController - : public NaviFrameItem { + class FrameController + : public NaviFrameItem { - public: - typedef std::list GroupList; + public: + typedef std::list GroupList; - enum GroupType { - ComposerGroup, - MsgThreadGroup, - ConvGroup, - SettingsGroup - }; + enum GroupType { + ComposerGroup, + MsgThreadGroup, + ConvGroup, + SettingsGroup + }; - public: - FrameController(NaviFrameController &parent, GroupType groupType); - virtual ~FrameController(); + public: + FrameController(NaviFrameController &parent, GroupType groupType); + virtual ~FrameController(); - NaviFrameController &getParent(); - void pop(); - void addToGroup(FrameController &frame); - void removeFromGroup(); - const GroupList &getGroupList() const; - GroupType getGroupType() const; + NaviFrameController &getParent(); + void pop(); + void addToGroup(FrameController &frame); + void removeFromGroup(); + const GroupList &getGroupList() const; + GroupType getGroupType() const; - void pause(); - void resume(); - bool isPause() const; + void pause(); + void resume(); + bool isPause() const; - protected: - // NaviFrameItem - void onAttached(ViewItem &item) override; - virtual void onPause() {}; - virtual void onResume() {}; + protected: + // NaviFrameItem + void onAttached(ViewItem &item) override; + virtual void onPause() {}; + virtual void onResume() {}; - void newGroup(); + void newGroup(); - private: - bool m_IsPause; - std::shared_ptr m_GroupList; - GroupType m_GroupType; - }; + private: + bool m_IsPause; + std::shared_ptr m_GroupList; + GroupType m_GroupType; + }; } #endif /* FrameController */ diff --git a/src/Common/Controller/inc/InputFrame.h b/src/Common/Controller/inc/InputFrame.h index 78c0889..fb9f30a 100644 --- a/src/Common/Controller/inc/InputFrame.h +++ b/src/Common/Controller/inc/InputFrame.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -21,36 +21,36 @@ #include "InputLayout.h" namespace Msg { - class InputFrame - : public FrameController { + class InputFrame + : public FrameController { - public: - InputFrame(NaviFrameController &parent, GroupType groupType); - virtual ~InputFrame(); + public: + InputFrame(NaviFrameController &parent, GroupType groupType); + virtual ~InputFrame(); - Entry &getEntry(); - const Entry &getEntry() const; - void setPredictBar(Evas_Object *obj); - void showPredictBar(bool value); - InputLayout &getLayout(); + Entry &getEntry(); + const Entry &getEntry() const; + void setPredictBar(Evas_Object *obj); + void showPredictBar(bool value); + InputLayout &getLayout(); - protected: - virtual void onInputPanelHide() {}; + protected: + virtual void onInputPanelHide() {}; - // NaviFrameItem - void onAttached(ViewItem &item) override; + // NaviFrameItem + void onAttached(ViewItem &item) override; - private: - void onFocusChanged(Evas_Object *obj, void *event_info); - void onInputPanelEvent(Ecore_IMF_Context *ctx, int value); + private: + void onFocusChanged(Evas_Object *obj, void *event_info); + void onInputPanelEvent(Ecore_IMF_Context *ctx, int value); - void prepareLayout(); - void prepareEntry(); + void prepareLayout(); + void prepareEntry(); - private: - InputLayout *m_pLayout; - Entry *m_pEntry; - }; + private: + InputLayout *m_pLayout; + Entry *m_pEntry; + }; } #endif /* InputFrame_h_ */ diff --git a/src/Common/Controller/inc/NaviFrameController.h b/src/Common/Controller/inc/NaviFrameController.h index b8b0d62..6ff0abe 100644 --- a/src/Common/Controller/inc/NaviFrameController.h +++ b/src/Common/Controller/inc/NaviFrameController.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -31,97 +31,97 @@ namespace Msg { - class FrameController; - class MsgInputSelector; - class ConnectivityChecker; - - class NaviFrameController - : public NaviFrameView - , private IAppListener - , private IInputSelectorListener - , private IPopupManagerListener { - - public: - NaviFrameController(App &app); - virtual ~NaviFrameController(); - - /** - * @brief Pops last frame. Exit from app if frame count reaches zero. - * @param[in] frame FrameController for pop - */ - void pop(FrameController &frame); - - /** - * @brief Pops this frame and all frames exists in group. - * @param[in] frame with group items for pop - */ - void popGroup(FrameController &frame); - - /** - * @brief Pops frames by GroupType. - * @param[in] frame with group items for pop - */ - void popGroup(FrameController::GroupType type); - - /** - * @brief Executes app control command of default type. - */ - void execCmd(const AppControlDefaultRef &cmd); - - /** - * @brief Executes app control command of Settings type. - */ - void execCmd(const AppControlSettingsRef &cmd); - - /** - * @brief Executes app control command of compose type. This is Compose, Share, MultiShare, ShareText. - */ - void execCmd(const AppControlComposeRef &cmd); - - /** - * @brief Destroys naviframe. Note, than this doesn't close app. - */ - void destroy(); - - template - T *findTopFrame() const; - - FrameController *getTopFrame() const; - MsgInputSelector &getInputSelector(); - ConnectivityChecker &getConnectivityChecker(); - bool isEmpty() const; - - private: - bool prepare(const AppControlCommand &cmd); - void registerHWButtonEvent(); - bool isUnreadNotificationSingle(AppControlDefault::DefaultType type) const; - void requestExit(); - void onDeferredExit(); - - // H/W buttons: - void onHwBackButtonClicked(Evas_Object *obj, void *event_info); - - // NaviFrameView: - void onPause(NaviFrameItem &item) override; - void onResume(NaviFrameItem &item) override; - void onBeforeDelete(View &view) override; - - // App: - void onAppPause() override; - void onAppResume() override; - - // IInputSelectorListener: - void onTerminate(InputSelector &sender) override; - - // IPopupManagerListener: - void onPop(BasePopup &popup) override; - void onPush(BasePopup &popup) override; - - private: - std::unique_ptr m_InputSelector; - std::unique_ptr m_ConnectivityChecker; - Ecore_Job *m_pExitJob; - }; + class FrameController; + class MsgInputSelector; + class ConnectivityChecker; + + class NaviFrameController + : public NaviFrameView + , private IAppListener + , private IInputSelectorListener + , private IPopupManagerListener { + + public: + NaviFrameController(App &app); + virtual ~NaviFrameController(); + + /** + * @brief Pops last frame. Exit from app if frame count reaches zero. + * @param[in] frame FrameController for pop + */ + void pop(FrameController &frame); + + /** + * @brief Pops this frame and all frames exists in group. + * @param[in] frame with group items for pop + */ + void popGroup(FrameController &frame); + + /** + * @brief Pops frames by GroupType. + * @param[in] frame with group items for pop + */ + void popGroup(FrameController::GroupType type); + + /** + * @brief Executes app control command of default type. + */ + void execCmd(const AppControlDefaultRef &cmd); + + /** + * @brief Executes app control command of Settings type. + */ + void execCmd(const AppControlSettingsRef &cmd); + + /** + * @brief Executes app control command of compose type. This is Compose, Share, MultiShare, ShareText. + */ + void execCmd(const AppControlComposeRef &cmd); + + /** + * @brief Destroys naviframe. Note, than this doesn't close app. + */ + void destroy(); + + template + T *findTopFrame() const; + + FrameController *getTopFrame() const; + MsgInputSelector &getInputSelector(); + ConnectivityChecker &getConnectivityChecker(); + bool isEmpty() const; + + private: + bool prepare(const AppControlCommand &cmd); + void registerHWButtonEvent(); + bool isUnreadNotificationSingle(AppControlDefault::DefaultType type) const; + void requestExit(); + void onDeferredExit(); + + // H/W buttons: + void onHwBackButtonClicked(Evas_Object *obj, void *event_info); + + // NaviFrameView: + void onPause(NaviFrameItem &item) override; + void onResume(NaviFrameItem &item) override; + void onBeforeDelete(View &view) override; + + // App: + void onAppPause() override; + void onAppResume() override; + + // IInputSelectorListener: + void onTerminate(InputSelector &sender) override; + + // IPopupManagerListener: + void onPop(BasePopup &popup) override; + void onPush(BasePopup &popup) override; + + private: + std::unique_ptr m_InputSelector; + std::unique_ptr m_ConnectivityChecker; + Ecore_Job *m_pExitJob; + }; } #endif /* NaviFrameController_h_ */ diff --git a/src/Common/Controller/src/App.cpp b/src/Common/Controller/src/App.cpp index ee369e0..da81632 100644 --- a/src/Common/Controller/src/App.cpp +++ b/src/Common/Controller/src/App.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -45,327 +45,327 @@ using namespace Msg; namespace { - App *appInstance; + App *appInstance; } App::App() - : m_pWindow(nullptr) - , m_pEngine(nullptr) - , m_pContactManager(nullptr) - , m_pPopupManager(nullptr) - , m_pThumbnailMaker(nullptr) - , m_pSysSettingsManager(nullptr) - , m_pNaviFrame(nullptr) - , m_pLauncher(nullptr) - , m_IsPause(true) - , m_IsTerminating(false) - , m_NeedToCloseApp(true) -{ - MSG_ASSERT(!appInstance, "Previous instance of application is not null"); - if (!appInstance) - appInstance = this; + : m_pWindow(nullptr) + , m_pEngine(nullptr) + , m_pContactManager(nullptr) + , m_pPopupManager(nullptr) + , m_pThumbnailMaker(nullptr) + , m_pSysSettingsManager(nullptr) + , m_pNaviFrame(nullptr) + , m_pLauncher(nullptr) + , m_IsPause(true) + , m_IsTerminating(false) + , m_NeedToCloseApp(true) +{ + MSG_ASSERT(!appInstance, "Previous instance of application is not null"); + if (!appInstance) + appInstance = this; } App::~App() { - delete m_pThumbnailMaker; - delete m_pContactManager; - delete m_pPopupManager; - delete m_pSysSettingsManager; - delete m_pLauncher; - if (this == appInstance) - appInstance = nullptr; + delete m_pThumbnailMaker; + delete m_pContactManager; + delete m_pPopupManager; + delete m_pSysSettingsManager; + delete m_pLauncher; + if (this == appInstance) + appInstance = nullptr; } App &App::getInst() { - MSG_ASSERT(appInstance, "Instance of application is null"); - return *appInstance; + MSG_ASSERT(appInstance, "Instance of application is null"); + return *appInstance; } void App::exit() { - MSG_LOG(""); + MSG_LOG(""); - if (m_IsTerminating) - return; + if (m_IsTerminating) + return; - // TODO: Temporary solution + // TODO: Temporary solution - m_IsTerminating = true; - getWindow().show(false); // Hide window to avoid blink - terminate(); + m_IsTerminating = true; + getWindow().show(false); // Hide window to avoid blink + terminate(); /* - if (m_NeedToCloseApp) - terminate(); // Close app completely - else if (m_pWindow) - m_pWindow->lower(); // Minimize window + if (m_NeedToCloseApp) + terminate(); // Close app completely + else if (m_pWindow) + m_pWindow->lower(); // Minimize window */ } void App::updateCharacterOrientation() { - char *lang = nullptr; - system_settings_get_value_string(SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, &lang); - if (lang) - { - MSG_LOG("Language: ", lang); - elm_language_set(lang); - i18n_ulocale_layout_type_e layout = I18N_ULOCALE_LAYOUT_UNKNOWN; - if (i18n_ulocale_get_character_orientation(lang, &layout) == I18N_ERROR_NONE) { - if (layout == I18N_ULOCALE_LAYOUT_LTR) - elm_config_mirrored_set(false); - else if (layout == I18N_ULOCALE_LAYOUT_RTL) - elm_config_mirrored_set(true); - else { - MSG_LOG_ERROR("Unsupported character orientation type: ", layout); - } - } - free(lang); - } + char *lang = nullptr; + system_settings_get_value_string(SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, &lang); + if (lang) + { + MSG_LOG("Language: ", lang); + elm_language_set(lang); + i18n_ulocale_layout_type_e layout = I18N_ULOCALE_LAYOUT_UNKNOWN; + if (i18n_ulocale_get_character_orientation(lang, &layout) == I18N_ERROR_NONE) { + if (layout == I18N_ULOCALE_LAYOUT_LTR) + elm_config_mirrored_set(false); + else if (layout == I18N_ULOCALE_LAYOUT_RTL) + elm_config_mirrored_set(true); + else { + MSG_LOG_ERROR("Unsupported character orientation type: ", layout); + } + } + free(lang); + } } MsgEngine &App::getMsgEngine() { - if (!m_pEngine) { - m_pEngine = new MsgEngine; - int serviceResult = m_pEngine->openService(); - if (serviceResult != MESSAGES_ERROR_NONE) { - MSG_ENGINE_WHAT_ERROR(serviceResult); - MSG_LOG_ERROR("Service handle open error = ", serviceResult); - } - } - return *m_pEngine; + if (!m_pEngine) { + m_pEngine = new MsgEngine; + int serviceResult = m_pEngine->openService(); + if (serviceResult != MESSAGES_ERROR_NONE) { + MSG_ENGINE_WHAT_ERROR(serviceResult); + MSG_LOG_ERROR("Service handle open error = ", serviceResult); + } + } + return *m_pEngine; } const MsgEngine &App::getMsgEngine() const { - return const_cast(this)->getMsgEngine(); + return const_cast(this)->getMsgEngine(); } ContactManager &App::getContactManager() { - if (!m_pContactManager) - m_pContactManager = new ContactManager; - return *m_pContactManager; + if (!m_pContactManager) + m_pContactManager = new ContactManager; + return *m_pContactManager; } const ContactManager &App::getContactManager() const { - return const_cast(this)->getContactManager(); + return const_cast(this)->getContactManager(); } Window &App::getWindow() { - if (!m_pWindow) { - m_pWindow = new StandardWindow; - m_pWindow->show(); - } - return *m_pWindow; + if (!m_pWindow) { + m_pWindow = new StandardWindow; + m_pWindow->show(); + } + return *m_pWindow; } const Window &App::getWindow() const { - return const_cast(this)->getWindow(); + return const_cast(this)->getWindow(); } PopupManager &App::getPopupManager() { - if (!m_pPopupManager) - m_pPopupManager = new PopupManager(getWindow()); - return *m_pPopupManager; + if (!m_pPopupManager) + m_pPopupManager = new PopupManager(getWindow()); + return *m_pPopupManager; } const PopupManager &App::getPopupManager() const { - return const_cast(this)->getPopupManager(); + return const_cast(this)->getPopupManager(); } ThumbnailMaker &App::getThumbnailMaker() { - if (!m_pThumbnailMaker) - m_pThumbnailMaker = new ThumbnailMaker(*this); - return *m_pThumbnailMaker; + if (!m_pThumbnailMaker) + m_pThumbnailMaker = new ThumbnailMaker(*this); + return *m_pThumbnailMaker; } const ThumbnailMaker &App::getThumbnailMaker() const { - return const_cast(this)->getThumbnailMaker(); + return const_cast(this)->getThumbnailMaker(); } SystemSettingsManager &App::getSysSettingsManager() { - if (!m_pSysSettingsManager) - m_pSysSettingsManager = new SystemSettingsManager; - return *m_pSysSettingsManager; + if (!m_pSysSettingsManager) + m_pSysSettingsManager = new SystemSettingsManager; + return *m_pSysSettingsManager; } const SystemSettingsManager &App::getSysSettingsManager() const { - return const_cast(this)->getSysSettingsManager(); + return const_cast(this)->getSysSettingsManager(); } NaviFrameController &App::getNavigation() { - MSG_ASSERT(m_pNaviFrame, "m_pNaviFrame is null"); - return *m_pNaviFrame; + MSG_ASSERT(m_pNaviFrame, "m_pNaviFrame is null"); + return *m_pNaviFrame; } const NaviFrameController &App::getNavigation() const { - return const_cast(this)->getNavigation(); + return const_cast(this)->getNavigation(); } AppControlLauncher &App::getLauncher() { - if (!m_pLauncher) - m_pLauncher = new AppControlLauncher; - return *m_pLauncher; + if (!m_pLauncher) + m_pLauncher = new AppControlLauncher; + return *m_pLauncher; } const AppControlLauncher &App::getLauncher() const { - return const_cast(this)->getLauncher(); + return const_cast(this)->getLauncher(); } void App::addListener(IAppListener &l) { - auto found = std::find(m_Listeners.begin(), m_Listeners.end(), &l); - if (found == m_Listeners.end()) - m_Listeners.push_back(&l); + auto found = std::find(m_Listeners.begin(), m_Listeners.end(), &l); + 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()) - m_Listeners.erase(found); + auto found = std::find(m_Listeners.begin(), m_Listeners.end(), &l); + if (found != m_Listeners.end()) + m_Listeners.erase(found); } void App::updateActiveNotifPolicy() { - MsgSettings::ActiveNotifPolicy policy = isPause() ? MsgSettings::AppBackgroundPolicy :MsgSettings::AppForegroundPolicy; - getMsgEngine().getSettings().setActiveNotifPolicy(policy); + MsgSettings::ActiveNotifPolicy policy = isPause() ? MsgSettings::AppBackgroundPolicy :MsgSettings::AppForegroundPolicy; + getMsgEngine().getSettings().setActiveNotifPolicy(policy); } bool App::isPause() const { - return m_IsPause; + return m_IsPause; } bool App::isTerminating() const { - return m_IsTerminating; + return m_IsTerminating; } void App::addTheme(const std::string &themePath) { - std::string path = PathUtils::getResourcePath(themePath); - elm_theme_extension_add(nullptr, path.c_str()); + std::string path = PathUtils::getResourcePath(themePath); + elm_theme_extension_add(nullptr, path.c_str()); } bool App::onCreate() { - TRACE; - if (!appInstance) - return false; + TRACE; + if (!appInstance) + return false; - addTheme(COMMON_GENLIST_THEME_EDJ_PATH); - addTheme(CONV_GENLIST_THEME_EDJ_PATH); - addTheme(IMAGES_EDJ_PATH); - addTheme(PREVIEW_MSG_THEME_EDJ_PATH); - addTheme(THREAD_COMPOSE_LIST_VIEW_ITEM); - addTheme(SENDING_OPTION_LIST_VIEW_ITEM); + addTheme(COMMON_GENLIST_THEME_EDJ_PATH); + addTheme(CONV_GENLIST_THEME_EDJ_PATH); + addTheme(IMAGES_EDJ_PATH); + addTheme(PREVIEW_MSG_THEME_EDJ_PATH); + addTheme(THREAD_COMPOSE_LIST_VIEW_ITEM); + addTheme(SENDING_OPTION_LIST_VIEW_ITEM); - feedback_initialize(); - getWindow(); - getMsgEngine(); - getSysSettingsManager(); - getContactManager(); - getThumbnailMaker(); + feedback_initialize(); + getWindow(); + getMsgEngine(); + getSysSettingsManager(); + getContactManager(); + getThumbnailMaker(); - m_pNaviFrame = new NaviFrameController(*this); - m_pWindow->setContent(*m_pNaviFrame); + m_pNaviFrame = new NaviFrameController(*this); + m_pWindow->setContent(*m_pNaviFrame); - return true; + return true; } void App::onTerminate() { - TRACE; - m_pNaviFrame->destroy(); - m_pWindow->destroy(); - feedback_deinitialize(); + TRACE; + m_pNaviFrame->destroy(); + m_pWindow->destroy(); + feedback_deinitialize(); } void App::onPause() { - TRACE; - if (!m_IsPause) { - m_IsPause = true; - for (IAppListener *l : m_Listeners) - l->onAppPause(); - updateActiveNotifPolicy(); - getPopupManager().onPause(); - } + TRACE; + if (!m_IsPause) { + m_IsPause = true; + for (IAppListener *l : m_Listeners) + l->onAppPause(); + updateActiveNotifPolicy(); + getPopupManager().onPause(); + } } void App::onResume() { - TRACE; - getWindow().show(); - if (m_IsPause) { - m_IsPause = false; - updateActiveNotifPolicy(); - for (IAppListener *l : m_Listeners) - l->onAppResume(); - } + TRACE; + getWindow().show(); + if (m_IsPause) { + m_IsPause = false; + updateActiveNotifPolicy(); + for (IAppListener *l : m_Listeners) + l->onAppResume(); + } } void App::onAppControl(app_control_h appControl) { - TRACE; - - AppControlCommandRef cmd = AppControlParser::parse(appControl); - if (!cmd) - return; - - app_control_launch_mode_e mode = APP_CONTROL_LAUNCH_MODE_SINGLE; - app_control_get_launch_mode(appControl, &mode); - m_NeedToCloseApp = mode == APP_CONTROL_LAUNCH_MODE_GROUP; - - switch (cmd->getOperationType()) { - case AppControlCommand::OpDefault: - if (m_pNaviFrame) - m_pNaviFrame->execCmd(std::static_pointer_cast(cmd)); - break; - case AppControlCommand::OpComposeFamily: - if (m_pNaviFrame) - m_pNaviFrame->execCmd(std::static_pointer_cast(cmd)); - break; - case AppControlCommand::OpSettings: - if (m_pNaviFrame) - m_pNaviFrame->execCmd(std::static_pointer_cast(cmd)); - break; - case AppControlCommand::OpUnknown: - default: - MSG_LOG_WARN("Not supported command"); - break; - } + TRACE; + + AppControlCommandRef cmd = AppControlParser::parse(appControl); + if (!cmd) + return; + + app_control_launch_mode_e mode = APP_CONTROL_LAUNCH_MODE_SINGLE; + app_control_get_launch_mode(appControl, &mode); + m_NeedToCloseApp = mode == APP_CONTROL_LAUNCH_MODE_GROUP; + + switch (cmd->getOperationType()) { + case AppControlCommand::OpDefault: + if (m_pNaviFrame) + m_pNaviFrame->execCmd(std::static_pointer_cast(cmd)); + break; + case AppControlCommand::OpComposeFamily: + if (m_pNaviFrame) + m_pNaviFrame->execCmd(std::static_pointer_cast(cmd)); + break; + case AppControlCommand::OpSettings: + if (m_pNaviFrame) + m_pNaviFrame->execCmd(std::static_pointer_cast(cmd)); + break; + case AppControlCommand::OpUnknown: + default: + MSG_LOG_WARN("Not supported command"); + break; + } } void App::onLanguageChanged(app_event_info_h appEvent) { - TRACE; - updateCharacterOrientation(); + TRACE; + updateCharacterOrientation(); } void App::onLowBattery(app_event_info_h appEvent) { - TRACE; + TRACE; } void App::onRegionChanged(app_event_info_h appEvent) { - TRACE; + TRACE; } diff --git a/src/Common/Controller/src/ConnectivityChecker.cpp b/src/Common/Controller/src/ConnectivityChecker.cpp index 3fa3f0b..4ebbf10 100644 --- a/src/Common/Controller/src/ConnectivityChecker.cpp +++ b/src/Common/Controller/src/ConnectivityChecker.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -29,115 +29,115 @@ ConnectivityChecker::ConnectivityChecker() bool ConnectivityChecker::isSimInserted() { - if (!getSysSettings().isSimInserted()) { - showNoSimCardPopup(); - return false; - } - return true; + if (!getSysSettings().isSimInserted()) { + showNoSimCardPopup(); + return false; + } + return true; } bool ConnectivityChecker::isFlightModeDisabled() { - if (getSysSettings().isFlightModeEnabled()) { - showDisableFlightModePopup(); - return false; - } - return true; + if (getSysSettings().isFlightModeEnabled()) { + showDisableFlightModePopup(); + return false; + } + return true; } bool ConnectivityChecker::isMobileDataEnabled() { - if (!getSysSettings().isMobileDataEnabled()) { - showMobileNetworkSettingsPopup(); - return false; - } - return true; + if (!getSysSettings().isMobileDataEnabled()) { + showMobileNetworkSettingsPopup(); + return false; + } + return true; } bool ConnectivityChecker::isRoamingDataEnabled() { - if (getSysSettings().isRoaming() && !getSysSettings().isRoamingDataEnabled()) { - showUnableDataRoamingPopup(); - return false; - } - return true; + if (getSysSettings().isRoaming() && !getSysSettings().isRoamingDataEnabled()) { + showUnableDataRoamingPopup(); + return false; + } + return true; } bool ConnectivityChecker::isReadyToSendSms() { - return isSimInserted() && - isFlightModeDisabled(); + return isSimInserted() && + isFlightModeDisabled(); } bool ConnectivityChecker::isReadyToSendMms() { - return isReadyToSendSms() && - isMobileDataEnabled() && - isRoamingDataEnabled(); + return isReadyToSendSms() && + isMobileDataEnabled() && + isRoamingDataEnabled(); } SystemSettingsManager &ConnectivityChecker::getSysSettings() { - return App::getInst().getSysSettingsManager(); + return App::getInst().getSysSettingsManager(); } void ConnectivityChecker::showNoSimCardPopup() { - ToastPopup::toast(msgt("IDS_MSGF_POP_SIM_NOT_INSERTED"), FAIL_ICON); + ToastPopup::toast(msgt("IDS_MSGF_POP_SIM_NOT_INSERTED"), FAIL_ICON); } void ConnectivityChecker::showDisableFlightModePopup() { - auto *popup = new StandardPopup(StandardPopup::buttons2Style); - popup->setText(msgt("WDS_MSG_POP_UNABLE_TO_SEND_MESSAGE_TURN_OFF_FLIGHT_MODE")); - popup->addLeftButton(CANCEL_BUTTON_POPUP); - popup->addRightButton(OK_BUTTON_POPUP, makeCbLast(&ConnectivityChecker::onTurnOffFlightModeClicked), this); - popup->show(); + auto *popup = new StandardPopup(StandardPopup::buttons2Style); + popup->setText(msgt("WDS_MSG_POP_UNABLE_TO_SEND_MESSAGE_TURN_OFF_FLIGHT_MODE")); + popup->addLeftButton(CANCEL_BUTTON_POPUP); + popup->addRightButton(OK_BUTTON_POPUP, makeCbLast(&ConnectivityChecker::onTurnOffFlightModeClicked), this); + popup->show(); } void ConnectivityChecker::showMobileNetworkSettingsPopup() { - auto *popup = new StandardPopup(StandardPopup::buttons2Style); - popup->setText(msgt("WDS_MSG_POP_UNABLE_TO_SEND_MESSAGE_CHANGE_YOUR_MOBILE_NETWORKS_SETTING")); - popup->addLeftButton(CANCEL_BUTTON_POPUP); - popup->addRightButton(OK_BUTTON_POPUP, makeCbLast(&ConnectivityChecker::onMobileNetworkSettingsClicked), this); - popup->show(); + auto *popup = new StandardPopup(StandardPopup::buttons2Style); + popup->setText(msgt("WDS_MSG_POP_UNABLE_TO_SEND_MESSAGE_CHANGE_YOUR_MOBILE_NETWORKS_SETTING")); + popup->addLeftButton(CANCEL_BUTTON_POPUP); + popup->addRightButton(OK_BUTTON_POPUP, makeCbLast(&ConnectivityChecker::onMobileNetworkSettingsClicked), this); + popup->show(); } void ConnectivityChecker::showUnableDataRoamingPopup() { - auto *popup = new StandardPopup(StandardPopup::buttons2Style); - popup->setText(msgt("WDS_MSG_BODY_UNABLE_TO_SEND_MMS_ENABLE_DATA_ROAMING")); - popup->addLeftButton(CANCEL_BUTTON_POPUP); - popup->addRightButton(OK_BUTTON_POPUP, makeCbLast(&ConnectivityChecker::onEnableDataRoamingClicked), this); - popup->show(); + auto *popup = new StandardPopup(StandardPopup::buttons2Style); + popup->setText(msgt("WDS_MSG_BODY_UNABLE_TO_SEND_MMS_ENABLE_DATA_ROAMING")); + popup->addLeftButton(CANCEL_BUTTON_POPUP); + popup->addRightButton(OK_BUTTON_POPUP, makeCbLast(&ConnectivityChecker::onEnableDataRoamingClicked), this); + popup->show(); } void ConnectivityChecker::onTurnOffFlightModeClicked(Popup &popup) { - MSG_LOG(""); - m_SettingsLauncher.launchConnections(); - popup.destroy(); + MSG_LOG(""); + m_SettingsLauncher.launchConnections(); + popup.destroy(); } void ConnectivityChecker::onAllowTransmissionTextClicked(Popup &popup) { - MSG_LOG(""); - popup.destroy(); + MSG_LOG(""); + popup.destroy(); } void ConnectivityChecker::onMobileNetworkSettingsClicked(Popup &popup) { - MSG_LOG(""); - popup.destroy(); - // TODO: run network settings + MSG_LOG(""); + popup.destroy(); + // TODO: run network settings } void ConnectivityChecker::onEnableDataRoamingClicked(Popup &popup) { - MSG_LOG(""); - popup.destroy(); - // TODO: run network settings + MSG_LOG(""); + popup.destroy(); + // TODO: run network settings } diff --git a/src/Common/Controller/src/FrameController.cpp b/src/Common/Controller/src/FrameController.cpp index 0dbd3cb..dceed8f 100644 --- a/src/Common/Controller/src/FrameController.cpp +++ b/src/Common/Controller/src/FrameController.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -24,87 +24,87 @@ using namespace Msg; FrameController::FrameController(NaviFrameController &parent, GroupType groupType) - : NaviFrameItem(parent) - , m_IsPause(true) - , m_GroupType(groupType) + : NaviFrameItem(parent) + , m_IsPause(true) + , m_GroupType(groupType) { - newGroup(); + newGroup(); } FrameController::~FrameController() { - m_GroupList->remove(this); + m_GroupList->remove(this); } NaviFrameController &FrameController::getParent() { - return static_cast(NaviFrameItem::getParent()); + return static_cast(NaviFrameItem::getParent()); } void FrameController::onAttached(ViewItem &item) { - NaviFrameItem::onAttached(item); + NaviFrameItem::onAttached(item); } void FrameController::pop() { - getParent().pop(*this); + getParent().pop(*this); } void FrameController::pause() { - if (!m_IsPause) { - m_IsPause = true; - onPause(); - } + if (!m_IsPause) { + m_IsPause = true; + onPause(); + } } void FrameController::resume() { - if (m_IsPause && !App::getInst().isPause()) { - m_IsPause = false; - onResume(); - } + if (m_IsPause && !App::getInst().isPause()) { + m_IsPause = false; + onResume(); + } } bool FrameController::isPause() const { - return m_IsPause; + return m_IsPause; } void FrameController::addToGroup(FrameController &frame) { - if (this == &frame) - return; + if (this == &frame) + return; - m_GroupList->merge(*frame.m_GroupList); - m_GroupList->unique(); - frame.m_GroupList = m_GroupList; + m_GroupList->merge(*frame.m_GroupList); + m_GroupList->unique(); + frame.m_GroupList = m_GroupList; } void FrameController::newGroup() { - m_GroupList = std::make_shared(); - m_GroupList->push_back(this); + m_GroupList = std::make_shared(); + m_GroupList->push_back(this); } void FrameController::removeFromGroup() { - m_GroupList->remove(this); - newGroup(); + m_GroupList->remove(this); + newGroup(); } const FrameController::GroupList &FrameController::getGroupList() const { - if (m_GroupList) { - return *m_GroupList; - } else { - static GroupList list; - return list; - } + if (m_GroupList) { + return *m_GroupList; + } else { + static GroupList list; + return list; + } } FrameController::GroupType FrameController::getGroupType() const { - return m_GroupType; + return m_GroupType; } diff --git a/src/Common/Controller/src/InputFrame.cpp b/src/Common/Controller/src/InputFrame.cpp index ae78526..875dbc6 100644 --- a/src/Common/Controller/src/InputFrame.cpp +++ b/src/Common/Controller/src/InputFrame.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -20,89 +20,89 @@ using namespace Msg; InputFrame::InputFrame(NaviFrameController &parent, GroupType groupType) - : FrameController(parent, groupType) - , m_pLayout(nullptr) - , m_pEntry(nullptr) + : FrameController(parent, groupType) + , m_pLayout(nullptr) + , m_pEntry(nullptr) { - prepareLayout(); - prepareEntry(); + prepareLayout(); + prepareEntry(); } InputFrame::~InputFrame() { - // TODO: check this - m_pEntry->delInputPanelEventCb(ECORE_IMF_INPUT_PANEL_STATE_EVENT, makeCbFirst(&InputFrame::onInputPanelEvent)); + // TODO: check this + m_pEntry->delInputPanelEventCb(ECORE_IMF_INPUT_PANEL_STATE_EVENT, makeCbFirst(&InputFrame::onInputPanelEvent)); } void InputFrame::onAttached(ViewItem &item) { - FrameController::onAttached(item); - setContent(*m_pLayout); + FrameController::onAttached(item); + setContent(*m_pLayout); } Entry &InputFrame::getEntry() { - return *m_pEntry; + return *m_pEntry; } const Entry &InputFrame::getEntry() const { - return *m_pEntry; + return *m_pEntry; } void InputFrame::setPredictBar(Evas_Object *obj) { - m_pLayout->setPredictBar(obj); + m_pLayout->setPredictBar(obj); } void InputFrame::showPredictBar(bool value) { - m_pLayout->showPredictBar(value); + m_pLayout->showPredictBar(value); } InputLayout &InputFrame::getLayout() { - return *m_pLayout; + return *m_pLayout; } void InputFrame::prepareLayout() { - if (!m_pLayout) { - m_pLayout = new InputLayout(getParent()); - } + if (!m_pLayout) { + m_pLayout = new InputLayout(getParent()); + } } void InputFrame::prepareEntry() { - if (!m_pEntry) { - m_pEntry = new Entry(*m_pLayout); - m_pEntry->enabledInputPanel(false); - m_pEntry->setFocusAllow(true); - m_pEntry->setSingleLine(true); - m_pEntry->setFocus(true); - m_pEntry->setScrollable(true); - m_pEntry->setScrollerPolicy(ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_ON); - - m_pEntry->addFocusedCb(makeCbFirst(&InputFrame::onFocusChanged), this); - m_pEntry->addUnfocusedCb(makeCbFirst(&InputFrame::onFocusChanged), this); - m_pEntry->addInputPanelEventCb(ECORE_IMF_INPUT_PANEL_STATE_EVENT, makeCbFirst(&InputFrame::onInputPanelEvent), this); - - m_pLayout->setEntry(*m_pEntry); - } + if (!m_pEntry) { + m_pEntry = new Entry(*m_pLayout); + m_pEntry->enabledInputPanel(false); + m_pEntry->setFocusAllow(true); + m_pEntry->setSingleLine(true); + m_pEntry->setFocus(true); + m_pEntry->setScrollable(true); + m_pEntry->setScrollerPolicy(ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_ON); + + m_pEntry->addFocusedCb(makeCbFirst(&InputFrame::onFocusChanged), this); + m_pEntry->addUnfocusedCb(makeCbFirst(&InputFrame::onFocusChanged), this); + m_pEntry->addInputPanelEventCb(ECORE_IMF_INPUT_PANEL_STATE_EVENT, makeCbFirst(&InputFrame::onInputPanelEvent), this); + + m_pLayout->setEntry(*m_pEntry); + } } void InputFrame::onFocusChanged(Evas_Object *obj, void *event_info) { - m_pEntry->showInputPanel(m_pEntry->getFocus()); + m_pEntry->showInputPanel(m_pEntry->getFocus()); } void InputFrame::onInputPanelEvent(Ecore_IMF_Context *ctx, int value) { - switch (value) { - case ECORE_IMF_INPUT_PANEL_STATE_HIDE: { - onInputPanelHide(); - break; - } - } + switch (value) { + case ECORE_IMF_INPUT_PANEL_STATE_HIDE: { + onInputPanelHide(); + break; + } + } } diff --git a/src/Common/Controller/src/NaviFrameController.cpp b/src/Common/Controller/src/NaviFrameController.cpp index 6a783d0..f162e2f 100644 --- a/src/Common/Controller/src/NaviFrameController.cpp +++ b/src/Common/Controller/src/NaviFrameController.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -35,252 +35,252 @@ using namespace Msg; NaviFrameController::NaviFrameController(App &app) - : NaviFrameView(app.getWindow()) - , m_pExitJob(nullptr) + : NaviFrameView(app.getWindow()) + , m_pExitJob(nullptr) { - App::getInst().addListener(*this); - App::getInst().getPopupManager().addListener(*this); - addHwButtonEvent(EEXT_CALLBACK_BACK, makeCbFirst(&NaviFrameController::onHwBackButtonClicked), this); + App::getInst().addListener(*this); + App::getInst().getPopupManager().addListener(*this); + addHwButtonEvent(EEXT_CALLBACK_BACK, makeCbFirst(&NaviFrameController::onHwBackButtonClicked), this); } NaviFrameController::~NaviFrameController() { - MSG_LOG("Destructor: ", this); - if (m_pExitJob) - ecore_job_del(m_pExitJob); + MSG_LOG("Destructor: ", this); + if (m_pExitJob) + ecore_job_del(m_pExitJob); } void NaviFrameController::pop(FrameController &frame) { - if (frame.isPopping()) - return; - - MSG_LOG("Is Last frame: ", isLastFrame()); - MSG_LOG("PopupManager isEmpty: ", App::getInst().getPopupManager().isEmpty()); - - if (isLastFrame() && App::getInst().getPopupManager().isEmpty()) - App::getInst().exit(); - else { - App::getInst().getPopupManager().pop(&frame); - NaviFrameView::pop(frame); - } + if (frame.isPopping()) + return; + + MSG_LOG("Is Last frame: ", isLastFrame()); + MSG_LOG("PopupManager isEmpty: ", App::getInst().getPopupManager().isEmpty()); + + if (isLastFrame() && App::getInst().getPopupManager().isEmpty()) + App::getInst().exit(); + else { + App::getInst().getPopupManager().pop(&frame); + NaviFrameView::pop(frame); + } } void NaviFrameController::popGroup(FrameController &frame) { - auto count = getItemsCount(); - auto list = frame.getGroupList(); - - if (count == list.size()) { - App::getInst().exit(); - } else { - for (FrameController *item : list) { - if (item) - pop(*item); - } - } + auto count = getItemsCount(); + auto list = frame.getGroupList(); + + if (count == list.size()) { + App::getInst().exit(); + } else { + for (FrameController *item : list) { + if (item) + pop(*item); + } + } } void NaviFrameController::popGroup(FrameController::GroupType type) { - auto items = getItems(); - for (NaviFrameItem *item: items) { - auto *frame = dynamic_cast(item); - if (frame && frame->getGroupType() == type) { - pop(*frame); - } - } + auto items = getItems(); + for (NaviFrameItem *item: items) { + auto *frame = dynamic_cast(item); + if (frame && frame->getGroupType() == type) { + pop(*frame); + } + } } void NaviFrameController::destroy() { - NaviFrameView::destroy(); + NaviFrameView::destroy(); } bool NaviFrameController::prepare(const AppControlCommand &cmd) { - MSG_LOG("Execute app. control command: ", cmd.getOperationMsg()); - std::string errorMsg; - if (!App::getInst().getMsgEngine().isReady(errorMsg)) { - MSG_LOG_ERROR(errorMsg); - ToastPopup::toast(errorMsg.c_str()); - return false; - } - return true; + MSG_LOG("Execute app. control command: ", cmd.getOperationMsg()); + std::string errorMsg; + if (!App::getInst().getMsgEngine().isReady(errorMsg)) { + MSG_LOG_ERROR(errorMsg); + ToastPopup::toast(errorMsg.c_str()); + return false; + } + return true; } void NaviFrameController::requestExit() { - if (!m_pExitJob && isEmpty()) - m_pExitJob = ecore_job_add(makeCbFirst(&NaviFrameController::onDeferredExit), this); + if (!m_pExitJob && isEmpty()) + m_pExitJob = ecore_job_add(makeCbFirst(&NaviFrameController::onDeferredExit), this); } void NaviFrameController::onDeferredExit() { - MSG_LOG(""); - if (isEmpty()) - App::getInst().exit(); - m_pExitJob = nullptr; + MSG_LOG(""); + if (isEmpty()) + App::getInst().exit(); + m_pExitJob = nullptr; } void NaviFrameController::execCmd(const AppControlDefaultRef &cmd) { - if (!prepare(*cmd)) - return; - - AppControlDefault::DefaultType type = cmd->getDefaultType(); - auto *thread = findTopFrame(); // Check if thread is open - if (!thread) - insertToBottom(*new MsgThreadFrame(*this)); // Push thread list to the bottom - - if (type != AppControlDefault::MainType) { - MessageRef msg = App::getInst().getMsgEngine().getStorage().getMessage(cmd->getMessageId()); //To avoid opening conversation if MsgId is invalid - if (msg) { - auto *conv = findTopFrame(); // Check if conversation is open - if (conv) { - App::getInst().getLauncher().terminate(); - promote(*conv); - conv->execCmd(cmd); - } else if (type == AppControlDefault::ViewType || type == AppControlDefault::ReplyType || isUnreadNotificationSingle(type)) { - App::getInst().getLauncher().terminate(); - conv = new ConvFrame(*this); - push(*conv); - conv->execCmd(cmd); - } - } - } + if (!prepare(*cmd)) + return; + + AppControlDefault::DefaultType type = cmd->getDefaultType(); + auto *thread = findTopFrame(); // Check if thread is open + if (!thread) + insertToBottom(*new MsgThreadFrame(*this)); // Push thread list to the bottom + + if (type != AppControlDefault::MainType) { + MessageRef msg = App::getInst().getMsgEngine().getStorage().getMessage(cmd->getMessageId()); //To avoid opening conversation if MsgId is invalid + if (msg) { + auto *conv = findTopFrame(); // Check if conversation is open + if (conv) { + App::getInst().getLauncher().terminate(); + promote(*conv); + conv->execCmd(cmd); + } else if (type == AppControlDefault::ViewType || type == AppControlDefault::ReplyType || isUnreadNotificationSingle(type)) { + App::getInst().getLauncher().terminate(); + conv = new ConvFrame(*this); + push(*conv); + conv->execCmd(cmd); + } + } + } } void NaviFrameController::execCmd(const AppControlComposeRef &cmd) { - if (!prepare(*cmd)) - return; - - if (!getConnectivityChecker().isFlightModeDisabled()) - return; - - App::getInst().getLauncher().terminate(); - if (cmd->getRecipientList().empty()) { - auto *frame = new RecipFrame(*this); - push(*frame); - frame->execCmd(cmd); - } else { - getInputSelector().reset(); - getInputSelector().execCmd(cmd); - }; + if (!prepare(*cmd)) + return; + + if (!getConnectivityChecker().isFlightModeDisabled()) + return; + + App::getInst().getLauncher().terminate(); + if (cmd->getRecipientList().empty()) { + auto *frame = new RecipFrame(*this); + push(*frame); + frame->execCmd(cmd); + } else { + getInputSelector().reset(); + getInputSelector().execCmd(cmd); + }; } void NaviFrameController::execCmd(const AppControlSettingsRef &cmd) { - if (!prepare(*cmd)) - return; - - App::getInst().getLauncher().terminate(); - auto *frame = findTopFrame(); - if (frame) { - promote(*frame); - } else { - auto *frame = new SettingsFrame(*this); - push(*frame); - } + if (!prepare(*cmd)) + return; + + App::getInst().getLauncher().terminate(); + auto *frame = findTopFrame(); + if (frame) { + promote(*frame); + } else { + auto *frame = new SettingsFrame(*this); + push(*frame); + } } template T *NaviFrameController::findTopFrame() const { - auto items = getItems(); - for (auto item = items.rbegin(); item != items.rend(); ++item) { - T *frame = dynamic_cast(*item); - if (frame) - return frame; - } - return nullptr; + auto items = getItems(); + for (auto item = items.rbegin(); item != items.rend(); ++item) { + T *frame = dynamic_cast(*item); + if (frame) + return frame; + } + return nullptr; } FrameController *NaviFrameController::getTopFrame() const { - return static_cast(NaviFrameView::getTopFrame()); + return static_cast(NaviFrameView::getTopFrame()); } MsgInputSelector &NaviFrameController::getInputSelector() { - if (!m_InputSelector) { - m_InputSelector.reset(new MsgInputSelector); - m_InputSelector->setListener(this); - } - return *m_InputSelector; + if (!m_InputSelector) { + m_InputSelector.reset(new MsgInputSelector); + m_InputSelector->setListener(this); + } + return *m_InputSelector; } ConnectivityChecker &NaviFrameController::getConnectivityChecker() { - if (!m_ConnectivityChecker) - m_ConnectivityChecker.reset(new ConnectivityChecker); - return *m_ConnectivityChecker; + if (!m_ConnectivityChecker) + m_ConnectivityChecker.reset(new ConnectivityChecker); + return *m_ConnectivityChecker; } bool NaviFrameController::isEmpty() const { - return NaviFrameView::isEmpty() && - App::getInst().getPopupManager().isEmpty(); + return NaviFrameView::isEmpty() && + App::getInst().getPopupManager().isEmpty(); } bool NaviFrameController::isUnreadNotificationSingle(AppControlDefault::DefaultType type) const { - return type == AppControlDefault::NotificationType && App::getInst().getMsgEngine().getStorage().getUnreadThreadCount() == 1; + return type == AppControlDefault::NotificationType && App::getInst().getMsgEngine().getStorage().getUnreadThreadCount() == 1; } void NaviFrameController::onHwBackButtonClicked(Evas_Object *obj, void *event_info) { - auto *top = getTopFrame(); - top ? pop(*top) : App::getInst().exit(); + auto *top = getTopFrame(); + top ? pop(*top) : App::getInst().exit(); } void NaviFrameController::onPause(NaviFrameItem &item) { - static_cast(item).pause(); + static_cast(item).pause(); } void NaviFrameController::onResume(NaviFrameItem &item) { - static_cast(item).resume(); + static_cast(item).resume(); } void NaviFrameController::onAppPause() { - auto *top = getTopFrame(); - if (top) - top->pause(); + auto *top = getTopFrame(); + if (top) + top->pause(); } void NaviFrameController::onAppResume() { - auto *top = getTopFrame(); - if (top) - top->resume(); + auto *top = getTopFrame(); + if (top) + top->resume(); } void NaviFrameController::onBeforeDelete(View &view) { - NaviFrameView::onBeforeDelete(view); - App::getInst().removeListener(*this); - App::getInst().getPopupManager().removeListener(*this); - m_InputSelector.reset(); - m_ConnectivityChecker.reset(); + NaviFrameView::onBeforeDelete(view); + App::getInst().removeListener(*this); + App::getInst().getPopupManager().removeListener(*this); + m_InputSelector.reset(); + m_ConnectivityChecker.reset(); } void NaviFrameController::onTerminate(InputSelector &sender) { - requestExit(); + requestExit(); } void NaviFrameController::onPop(BasePopup &popup) { - MSG_LOG(""); - requestExit(); + MSG_LOG(""); + requestExit(); } void NaviFrameController::onPush(BasePopup &popup) { - MSG_LOG(""); + MSG_LOG(""); } diff --git a/src/Common/MsgEngine/inc/MediaType.h b/src/Common/MsgEngine/inc/MediaType.h index 573a31e..2249b38 100644 --- a/src/Common/MsgEngine/inc/MediaType.h +++ b/src/Common/MsgEngine/inc/MediaType.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -27,275 +27,275 @@ #include namespace Msg { - struct MediaTypeData { - MediaTypeData(const char *aMime, MsgMedia::Type aType) - : mime(aMime) - , type(aType) - { - } - std::string mime; - MsgMedia::Type type; - }; + struct MediaTypeData { + MediaTypeData(const char *aMime, MsgMedia::Type aType) + : mime(aMime) + , type(aType) + { + } + std::string mime; + MsgMedia::Type type; + }; - const std::unordered_multimap mediaTypeByExtMap = - { - // Sound: - {"aac", {"audio/aac", MsgMedia::AudioType}}, - {"amr", {"audio/amr", MsgMedia::AudioType}}, - {"amr", {"audio/x-amr", MsgMedia::AudioType}}, - {"amr", {"audio/amr-wb", MsgMedia::AudioType}}, - {"imy", {"audio/imelody", MsgMedia::AudioType}}, - {"imy", {"audio/imy", MsgMedia::AudioType}}, - {"imy", {"audio/iMelody", MsgMedia::AudioType}}, - {"imy", {"audio/melody", MsgMedia::AudioType}}, - {"imy", {"audio/x-iMelody", MsgMedia::AudioType}}, - {"imy", {"text/iMelody", MsgMedia::AudioType}}, - {"imy", {"text/x-iMelody", MsgMedia::AudioType}}, - {"imy", {"text/x-imelody", MsgMedia::AudioType}}, - {"mid", {"audio/mid", MsgMedia::AudioType}}, - {"mid", {"audio/midi", MsgMedia::AudioType}}, - {"mid", {"audio/x-mid", MsgMedia::AudioType}}, - {"mid", {"audio/x-midi", MsgMedia::AudioType}}, - {"midi", {"audio/mid", MsgMedia::AudioType}}, - {"mmf", {"application/vnd.smaf", MsgMedia::AudioType}}, - {"mmf", {"application/x-smaf", MsgMedia::AudioType}}, - {"mmf", {"audio/mmf", MsgMedia::AudioType}}, - {"mmf", {"audio/smaf", MsgMedia::AudioType}}, - {"mmf", {"audio/x-mmf", MsgMedia::AudioType}}, - {"mmf", {"audio/x-smaf", MsgMedia::AudioType}}, - {"mp3", {"audio/mpeg", MsgMedia::AudioType}}, - {"mp3", {"audio/mp3", MsgMedia::AudioType}}, - {"mp3", {"audio/mpg3", MsgMedia::AudioType}}, - {"mp3", {"audio/mpeg3", MsgMedia::AudioType}}, - {"mp3", {"audio/mpg", MsgMedia::AudioType}}, - {"mp3", {"audio/x-mp3", MsgMedia::AudioType}}, - {"mp3", {"audio/x-mpeg", MsgMedia::AudioType}}, - {"mp3", {"audio/x-mpeg3", MsgMedia::AudioType}}, - {"mp3", {"audio/x-mpegaudio", MsgMedia::AudioType}}, - {"mp3", {"audio/x-mpg", MsgMedia::AudioType}}, - {"mpg", {"audio/x-mpeg", MsgMedia::AudioType}}, - {"m4a", {"audio/m4a", MsgMedia::AudioType}}, - {"ra", {"audio/x-pn-realaudio", MsgMedia::AudioType}}, - {"rm", {"audio/vnd.rn-realaudio", MsgMedia::AudioType}}, - {"rm", {"audio/x-pn-multirate-realaudio", MsgMedia::AudioType}}, - {"rm", {"audio/x-pn-multirate-realaudio-live", MsgMedia::AudioType}}, - {"spm", {"audio/sp-midi", MsgMedia::AudioType}}, - {"wav", {"audio/wav", MsgMedia::AudioType}}, - {"wav", {"audio/wave", MsgMedia::AudioType}}, - {"wav", {"audio/x-wav", MsgMedia::AudioType}}, - {"wav", {"audio/x-wave", MsgMedia::AudioType}}, - {"wma", {"audio/wma", MsgMedia::AudioType}}, - {"wma", {"audio/x-ms-wma", MsgMedia::AudioType}}, - {"xmf", {"audio/mobile-xmf", MsgMedia::AudioType}}, - {"xmf", {"audio/xmf", MsgMedia::AudioType}}, - {"xmf", {"audio/x-xmf", MsgMedia::AudioType}}, - {"3gp", {"audio/3gpp", MsgMedia::AudioType}}, - {"mp4", {"audio/mp4", MsgMedia::AudioType}}, - {"mp4", {"audio/MP4A-LATM", MsgMedia::AudioType}}, - {"mp4", {"audio/mpeg4", MsgMedia::AudioType}}, + const std::unordered_multimap mediaTypeByExtMap = + { + // Sound: + {"aac", {"audio/aac", MsgMedia::AudioType}}, + {"amr", {"audio/amr", MsgMedia::AudioType}}, + {"amr", {"audio/x-amr", MsgMedia::AudioType}}, + {"amr", {"audio/amr-wb", MsgMedia::AudioType}}, + {"imy", {"audio/imelody", MsgMedia::AudioType}}, + {"imy", {"audio/imy", MsgMedia::AudioType}}, + {"imy", {"audio/iMelody", MsgMedia::AudioType}}, + {"imy", {"audio/melody", MsgMedia::AudioType}}, + {"imy", {"audio/x-iMelody", MsgMedia::AudioType}}, + {"imy", {"text/iMelody", MsgMedia::AudioType}}, + {"imy", {"text/x-iMelody", MsgMedia::AudioType}}, + {"imy", {"text/x-imelody", MsgMedia::AudioType}}, + {"mid", {"audio/mid", MsgMedia::AudioType}}, + {"mid", {"audio/midi", MsgMedia::AudioType}}, + {"mid", {"audio/x-mid", MsgMedia::AudioType}}, + {"mid", {"audio/x-midi", MsgMedia::AudioType}}, + {"midi", {"audio/mid", MsgMedia::AudioType}}, + {"mmf", {"application/vnd.smaf", MsgMedia::AudioType}}, + {"mmf", {"application/x-smaf", MsgMedia::AudioType}}, + {"mmf", {"audio/mmf", MsgMedia::AudioType}}, + {"mmf", {"audio/smaf", MsgMedia::AudioType}}, + {"mmf", {"audio/x-mmf", MsgMedia::AudioType}}, + {"mmf", {"audio/x-smaf", MsgMedia::AudioType}}, + {"mp3", {"audio/mpeg", MsgMedia::AudioType}}, + {"mp3", {"audio/mp3", MsgMedia::AudioType}}, + {"mp3", {"audio/mpg3", MsgMedia::AudioType}}, + {"mp3", {"audio/mpeg3", MsgMedia::AudioType}}, + {"mp3", {"audio/mpg", MsgMedia::AudioType}}, + {"mp3", {"audio/x-mp3", MsgMedia::AudioType}}, + {"mp3", {"audio/x-mpeg", MsgMedia::AudioType}}, + {"mp3", {"audio/x-mpeg3", MsgMedia::AudioType}}, + {"mp3", {"audio/x-mpegaudio", MsgMedia::AudioType}}, + {"mp3", {"audio/x-mpg", MsgMedia::AudioType}}, + {"mpg", {"audio/x-mpeg", MsgMedia::AudioType}}, + {"m4a", {"audio/m4a", MsgMedia::AudioType}}, + {"ra", {"audio/x-pn-realaudio", MsgMedia::AudioType}}, + {"rm", {"audio/vnd.rn-realaudio", MsgMedia::AudioType}}, + {"rm", {"audio/x-pn-multirate-realaudio", MsgMedia::AudioType}}, + {"rm", {"audio/x-pn-multirate-realaudio-live", MsgMedia::AudioType}}, + {"spm", {"audio/sp-midi", MsgMedia::AudioType}}, + {"wav", {"audio/wav", MsgMedia::AudioType}}, + {"wav", {"audio/wave", MsgMedia::AudioType}}, + {"wav", {"audio/x-wav", MsgMedia::AudioType}}, + {"wav", {"audio/x-wave", MsgMedia::AudioType}}, + {"wma", {"audio/wma", MsgMedia::AudioType}}, + {"wma", {"audio/x-ms-wma", MsgMedia::AudioType}}, + {"xmf", {"audio/mobile-xmf", MsgMedia::AudioType}}, + {"xmf", {"audio/xmf", MsgMedia::AudioType}}, + {"xmf", {"audio/x-xmf", MsgMedia::AudioType}}, + {"3gp", {"audio/3gpp", MsgMedia::AudioType}}, + {"mp4", {"audio/mp4", MsgMedia::AudioType}}, + {"mp4", {"audio/MP4A-LATM", MsgMedia::AudioType}}, + {"mp4", {"audio/mpeg4", MsgMedia::AudioType}}, - // Image: - {"bmp", {"image/bmp", MsgMedia::ImageType}}, - {"bmp", {"image/x-bmp", MsgMedia::ImageType}}, - {"gif", {"image/gif", MsgMedia::ImageType}}, - {"GIF", {"image/gif", MsgMedia::ImageType}}, - {"gif", {"image/vnd.tmo.my5-gif", MsgMedia::ImageType}}, - {"jpg", {"image/jpg", MsgMedia::ImageType}}, - {"jpg", {"image/jpeg", MsgMedia::ImageType}}, - {"jpg", {"image/vnd.tmo.my5-jpg", MsgMedia::ImageType}}, - {"jpeg", {"image/jpeg", MsgMedia::ImageType}}, - {"JPG", {"image/jpeg", MsgMedia::ImageType}}, - {"jpg", {"image/pjpeg", MsgMedia::ImageType}}, - {"jpe", {"image/jpeg", MsgMedia::ImageType}}, - {"png", {"image/png", MsgMedia::ImageType}}, - {"wbmp", {"image/vnd.wap.wbmp", MsgMedia::ImageType}}, - {"wbmp", {"image/wbmp", MsgMedia::ImageType}}, - {"swf", {"application/x-shockwave-flash", MsgMedia::UnknownType}}, - {"tif", {"image/tiff", MsgMedia::ImageType}}, - {"tif", {"image/tif", MsgMedia::ImageType}}, - {"pmd", {"audio/pmd", MsgMedia::ImageType}}, + // Image: + {"bmp", {"image/bmp", MsgMedia::ImageType}}, + {"bmp", {"image/x-bmp", MsgMedia::ImageType}}, + {"gif", {"image/gif", MsgMedia::ImageType}}, + {"GIF", {"image/gif", MsgMedia::ImageType}}, + {"gif", {"image/vnd.tmo.my5-gif", MsgMedia::ImageType}}, + {"jpg", {"image/jpg", MsgMedia::ImageType}}, + {"jpg", {"image/jpeg", MsgMedia::ImageType}}, + {"jpg", {"image/vnd.tmo.my5-jpg", MsgMedia::ImageType}}, + {"jpeg", {"image/jpeg", MsgMedia::ImageType}}, + {"JPG", {"image/jpeg", MsgMedia::ImageType}}, + {"jpg", {"image/pjpeg", MsgMedia::ImageType}}, + {"jpe", {"image/jpeg", MsgMedia::ImageType}}, + {"png", {"image/png", MsgMedia::ImageType}}, + {"wbmp", {"image/vnd.wap.wbmp", MsgMedia::ImageType}}, + {"wbmp", {"image/wbmp", MsgMedia::ImageType}}, + {"swf", {"application/x-shockwave-flash", MsgMedia::UnknownType}}, + {"tif", {"image/tiff", MsgMedia::ImageType}}, + {"tif", {"image/tif", MsgMedia::ImageType}}, + {"pmd", {"audio/pmd", MsgMedia::ImageType}}, - // Video: - {"3gp", {"video/3gpp", MsgMedia::VideoType}}, - {"3gp", {"video/3gp", MsgMedia::VideoType}}, - {"3gp", {"video/h263", MsgMedia::VideoType}}, - {"3gp", {"video/mp4v-es", MsgMedia::VideoType}}, - {"asf", {"audio/x-ms-asf", MsgMedia::VideoType}}, - {"asf", {"video/x-ms-asf", MsgMedia::VideoType}}, - {"asx", {"video/x-ms-asf", MsgMedia::VideoType}}, - {"avi", {"video/avi", MsgMedia::VideoType}}, - {"mp2", {"video/mpeg", MsgMedia::VideoType}}, - {"mp4", {"video/mp4", MsgMedia::VideoType}}, - {"mp4", {"video/mpeg4", MsgMedia::VideoType}}, - {"mp4", {"video/x-mp4", MsgMedia::VideoType}}, - {"mp4", {"video/x-pv-mp4", MsgMedia::VideoType}}, - {"mpg", {"video/mpeg", MsgMedia::VideoType}}, - {"mpeg", {"video/mpeg", MsgMedia::VideoType}}, - {"rm", {"video/x-pn-multirate-realvideo", MsgMedia::VideoType}}, - {"rm", {"video/vnd.rn-realmedia", MsgMedia::VideoType}}, - {"rm", {"video/vnd.rn-realvideo", MsgMedia::VideoType}}, - {"rv", {"video/x-pn-realvideo", MsgMedia::VideoType}}, - {"sdp", {"application/sdp", MsgMedia::VideoType}}, - {"sdp", {"video/sdp", MsgMedia::VideoType}}, - {"wmv", {"video/x-ms-wmv", MsgMedia::VideoType}}, + // Video: + {"3gp", {"video/3gpp", MsgMedia::VideoType}}, + {"3gp", {"video/3gp", MsgMedia::VideoType}}, + {"3gp", {"video/h263", MsgMedia::VideoType}}, + {"3gp", {"video/mp4v-es", MsgMedia::VideoType}}, + {"asf", {"audio/x-ms-asf", MsgMedia::VideoType}}, + {"asf", {"video/x-ms-asf", MsgMedia::VideoType}}, + {"asx", {"video/x-ms-asf", MsgMedia::VideoType}}, + {"avi", {"video/avi", MsgMedia::VideoType}}, + {"mp2", {"video/mpeg", MsgMedia::VideoType}}, + {"mp4", {"video/mp4", MsgMedia::VideoType}}, + {"mp4", {"video/mpeg4", MsgMedia::VideoType}}, + {"mp4", {"video/x-mp4", MsgMedia::VideoType}}, + {"mp4", {"video/x-pv-mp4", MsgMedia::VideoType}}, + {"mpg", {"video/mpeg", MsgMedia::VideoType}}, + {"mpeg", {"video/mpeg", MsgMedia::VideoType}}, + {"rm", {"video/x-pn-multirate-realvideo", MsgMedia::VideoType}}, + {"rm", {"video/vnd.rn-realmedia", MsgMedia::VideoType}}, + {"rm", {"video/vnd.rn-realvideo", MsgMedia::VideoType}}, + {"rv", {"video/x-pn-realvideo", MsgMedia::VideoType}}, + {"sdp", {"application/sdp", MsgMedia::VideoType}}, + {"sdp", {"video/sdp", MsgMedia::VideoType}}, + {"wmv", {"video/x-ms-wmv", MsgMedia::VideoType}}, - // Text: - {"txt", {"text/plain", MsgMedia::TextType}}, - {"text", {"text/plain", MsgMedia::UnknownType}}, - {"html", {"text/html", MsgMedia::UnknownType}}, - {"htm", {"text/html", MsgMedia::UnknownType}}, - {"wml", {"text/vnd.wap.wml", MsgMedia::UnknownType}}, - {"xml", {"text/xml", MsgMedia::UnknownType}}, + // Text: + {"txt", {"text/plain", MsgMedia::TextType}}, + {"text", {"text/plain", MsgMedia::UnknownType}}, + {"html", {"text/html", MsgMedia::UnknownType}}, + {"htm", {"text/html", MsgMedia::UnknownType}}, + {"wml", {"text/vnd.wap.wml", MsgMedia::UnknownType}}, + {"xml", {"text/xml", MsgMedia::UnknownType}}, - // vObject: - {"vbm", {"text/x-vbookmark", MsgMedia::UnknownType}}, - {"vcf", {"text/x-vcard", MsgMedia::UnknownType}}, - {"vcs", {"text/x-vCalendar", MsgMedia::UnknownType}}, - {"vnt", {"text/x-vnote", MsgMedia::UnknownType}}, + // vObject: + {"vbm", {"text/x-vbookmark", MsgMedia::UnknownType}}, + {"vcf", {"text/x-vcard", MsgMedia::UnknownType}}, + {"vcs", {"text/x-vCalendar", MsgMedia::UnknownType}}, + {"vnt", {"text/x-vnote", MsgMedia::UnknownType}}, - // Doc: - {"doc", {"application/msword", MsgMedia::UnknownType}}, - {"doc", {"applcation/vnd.ms-word", MsgMedia::UnknownType}}, - {"xls", {"application/vnd.ms-excel", MsgMedia::UnknownType}}, - {"xls", {"application/x-msexcel", MsgMedia::UnknownType}}, - {"ppt", {"application/vnd.ms-powerpoint", MsgMedia::UnknownType}}, - {"ppt", {"application/x-mspowerpoint", MsgMedia::UnknownType}}, - {"pdf", {"application/pdf", MsgMedia::UnknownType}}, + // Doc: + {"doc", {"application/msword", MsgMedia::UnknownType}}, + {"doc", {"applcation/vnd.ms-word", MsgMedia::UnknownType}}, + {"xls", {"application/vnd.ms-excel", MsgMedia::UnknownType}}, + {"xls", {"application/x-msexcel", MsgMedia::UnknownType}}, + {"ppt", {"application/vnd.ms-powerpoint", MsgMedia::UnknownType}}, + {"ppt", {"application/x-mspowerpoint", MsgMedia::UnknownType}}, + {"pdf", {"application/pdf", MsgMedia::UnknownType}}, - // Etc: - {"rm ", {"application/vnd.rn-realmedia", MsgMedia::UnknownType}}, - {"smi", {"application/smil", MsgMedia::UnknownType}}, - {"smil", {"application/smil", MsgMedia::UnknownType}}, - {"xml", {"application/vnd.oma.drm.roap-pdu+xml", MsgMedia::UnknownType}}, - {"xml", {"application/vnd.oma.drm.roap-trigger+xml", MsgMedia::UnknownType}}, - {"xxx", {"application/octet-stream", MsgMedia::UnknownType}}, - }; + // Etc: + {"rm ", {"application/vnd.rn-realmedia", MsgMedia::UnknownType}}, + {"smi", {"application/smil", MsgMedia::UnknownType}}, + {"smil", {"application/smil", MsgMedia::UnknownType}}, + {"xml", {"application/vnd.oma.drm.roap-pdu+xml", MsgMedia::UnknownType}}, + {"xml", {"application/vnd.oma.drm.roap-trigger+xml", MsgMedia::UnknownType}}, + {"xxx", {"application/octet-stream", MsgMedia::UnknownType}}, + }; - const std::unordered_multimap mediaTypeByMimeMap = - { - // Sound: - {"audio/aac", MsgMedia::AudioType}, - {"audio/amr", MsgMedia::AudioType}, - {"audio/x-amr", MsgMedia::AudioType}, - {"audio/amr-wb", MsgMedia::AudioType}, - {"audio/imelody", MsgMedia::AudioType}, - {"audio/imy", MsgMedia::AudioType}, - {"audio/iMelody", MsgMedia::AudioType}, - {"audio/melody", MsgMedia::AudioType}, - {"audio/x-iMelody", MsgMedia::AudioType}, - {"text/iMelody", MsgMedia::AudioType}, - {"text/x-iMelody", MsgMedia::AudioType}, - {"text/x-imelody", MsgMedia::AudioType}, - {"audio/mid", MsgMedia::AudioType}, - {"audio/midi", MsgMedia::AudioType}, - {"audio/x-mid", MsgMedia::AudioType}, - {"audio/x-midi", MsgMedia::AudioType}, - {"audio/mid", MsgMedia::AudioType}, - {"application/vnd.smaf", MsgMedia::AudioType}, - {"application/x-smaf", MsgMedia::AudioType}, - {"audio/mmf", MsgMedia::AudioType}, - {"audio/smaf", MsgMedia::AudioType}, - {"audio/x-mmf", MsgMedia::AudioType}, - {"audio/x-smaf", MsgMedia::AudioType}, - {"audio/mpeg", MsgMedia::AudioType}, - {"audio/mp3", MsgMedia::AudioType}, - {"audio/mpg3", MsgMedia::AudioType}, - {"audio/mpeg3", MsgMedia::AudioType}, - {"audio/mpg", MsgMedia::AudioType}, - {"audio/x-mp3", MsgMedia::AudioType}, - {"audio/x-mpeg", MsgMedia::AudioType}, - {"audio/x-mpeg3", MsgMedia::AudioType}, - {"audio/x-mpegaudio", MsgMedia::AudioType}, - {"audio/x-mpg", MsgMedia::AudioType}, - {"audio/x-mpeg", MsgMedia::AudioType}, - {"audio/m4a", MsgMedia::AudioType}, - {"audio/x-pn-realaudio", MsgMedia::AudioType}, - {"audio/vnd.rn-realaudio", MsgMedia::AudioType}, - {"audio/x-pn-multirate-realaudio", MsgMedia::AudioType}, - {"audio/x-pn-multirate-realaudio-live", MsgMedia::AudioType}, - {"audio/sp-midi", MsgMedia::AudioType}, - {"audio/wav", MsgMedia::AudioType}, - {"audio/wave", MsgMedia::AudioType}, - {"audio/x-wav", MsgMedia::AudioType}, - {"audio/x-wave", MsgMedia::AudioType}, - {"audio/wma", MsgMedia::AudioType}, - {"audio/x-ms-wma", MsgMedia::AudioType}, - {"audio/mobile-xmf", MsgMedia::AudioType}, - {"audio/xmf", MsgMedia::AudioType}, - {"audio/x-xmf", MsgMedia::AudioType}, - {"audio/3gpp", MsgMedia::AudioType}, - {"audio/mp4", MsgMedia::AudioType}, - {"audio/MP4A-LATM", MsgMedia::AudioType}, - {"audio/mpeg4", MsgMedia::AudioType}, + const std::unordered_multimap mediaTypeByMimeMap = + { + // Sound: + {"audio/aac", MsgMedia::AudioType}, + {"audio/amr", MsgMedia::AudioType}, + {"audio/x-amr", MsgMedia::AudioType}, + {"audio/amr-wb", MsgMedia::AudioType}, + {"audio/imelody", MsgMedia::AudioType}, + {"audio/imy", MsgMedia::AudioType}, + {"audio/iMelody", MsgMedia::AudioType}, + {"audio/melody", MsgMedia::AudioType}, + {"audio/x-iMelody", MsgMedia::AudioType}, + {"text/iMelody", MsgMedia::AudioType}, + {"text/x-iMelody", MsgMedia::AudioType}, + {"text/x-imelody", MsgMedia::AudioType}, + {"audio/mid", MsgMedia::AudioType}, + {"audio/midi", MsgMedia::AudioType}, + {"audio/x-mid", MsgMedia::AudioType}, + {"audio/x-midi", MsgMedia::AudioType}, + {"audio/mid", MsgMedia::AudioType}, + {"application/vnd.smaf", MsgMedia::AudioType}, + {"application/x-smaf", MsgMedia::AudioType}, + {"audio/mmf", MsgMedia::AudioType}, + {"audio/smaf", MsgMedia::AudioType}, + {"audio/x-mmf", MsgMedia::AudioType}, + {"audio/x-smaf", MsgMedia::AudioType}, + {"audio/mpeg", MsgMedia::AudioType}, + {"audio/mp3", MsgMedia::AudioType}, + {"audio/mpg3", MsgMedia::AudioType}, + {"audio/mpeg3", MsgMedia::AudioType}, + {"audio/mpg", MsgMedia::AudioType}, + {"audio/x-mp3", MsgMedia::AudioType}, + {"audio/x-mpeg", MsgMedia::AudioType}, + {"audio/x-mpeg3", MsgMedia::AudioType}, + {"audio/x-mpegaudio", MsgMedia::AudioType}, + {"audio/x-mpg", MsgMedia::AudioType}, + {"audio/x-mpeg", MsgMedia::AudioType}, + {"audio/m4a", MsgMedia::AudioType}, + {"audio/x-pn-realaudio", MsgMedia::AudioType}, + {"audio/vnd.rn-realaudio", MsgMedia::AudioType}, + {"audio/x-pn-multirate-realaudio", MsgMedia::AudioType}, + {"audio/x-pn-multirate-realaudio-live", MsgMedia::AudioType}, + {"audio/sp-midi", MsgMedia::AudioType}, + {"audio/wav", MsgMedia::AudioType}, + {"audio/wave", MsgMedia::AudioType}, + {"audio/x-wav", MsgMedia::AudioType}, + {"audio/x-wave", MsgMedia::AudioType}, + {"audio/wma", MsgMedia::AudioType}, + {"audio/x-ms-wma", MsgMedia::AudioType}, + {"audio/mobile-xmf", MsgMedia::AudioType}, + {"audio/xmf", MsgMedia::AudioType}, + {"audio/x-xmf", MsgMedia::AudioType}, + {"audio/3gpp", MsgMedia::AudioType}, + {"audio/mp4", MsgMedia::AudioType}, + {"audio/MP4A-LATM", MsgMedia::AudioType}, + {"audio/mpeg4", MsgMedia::AudioType}, - // Image: - {"image/bmp", MsgMedia::ImageType}, - {"image/x-bmp", MsgMedia::ImageType}, - {"image/gif", MsgMedia::ImageType}, - {"image/gif", MsgMedia::ImageType}, - {"image/vnd.tmo.my5-gif", MsgMedia::ImageType}, - {"image/jpg", MsgMedia::ImageType}, - {"image/jpeg", MsgMedia::ImageType}, - {"image/vnd.tmo.my5-jpg", MsgMedia::ImageType}, - {"image/jpeg", MsgMedia::ImageType}, - {"image/jpeg", MsgMedia::ImageType}, - {"image/pjpeg", MsgMedia::ImageType}, - {"image/jpeg", MsgMedia::ImageType}, - {"image/png", MsgMedia::ImageType}, - {"image/vnd.wap.wbmp", MsgMedia::ImageType}, - {"image/wbmp", MsgMedia::ImageType}, - {"application/x-shockwave-flash", MsgMedia::UnknownType}, - {"image/tiff", MsgMedia::ImageType}, - {"image/tif", MsgMedia::ImageType}, - {"audio/pmd", MsgMedia::ImageType}, + // Image: + {"image/bmp", MsgMedia::ImageType}, + {"image/x-bmp", MsgMedia::ImageType}, + {"image/gif", MsgMedia::ImageType}, + {"image/gif", MsgMedia::ImageType}, + {"image/vnd.tmo.my5-gif", MsgMedia::ImageType}, + {"image/jpg", MsgMedia::ImageType}, + {"image/jpeg", MsgMedia::ImageType}, + {"image/vnd.tmo.my5-jpg", MsgMedia::ImageType}, + {"image/jpeg", MsgMedia::ImageType}, + {"image/jpeg", MsgMedia::ImageType}, + {"image/pjpeg", MsgMedia::ImageType}, + {"image/jpeg", MsgMedia::ImageType}, + {"image/png", MsgMedia::ImageType}, + {"image/vnd.wap.wbmp", MsgMedia::ImageType}, + {"image/wbmp", MsgMedia::ImageType}, + {"application/x-shockwave-flash", MsgMedia::UnknownType}, + {"image/tiff", MsgMedia::ImageType}, + {"image/tif", MsgMedia::ImageType}, + {"audio/pmd", MsgMedia::ImageType}, - // Video: - {"video/3gpp", MsgMedia::VideoType}, - {"video/3gp", MsgMedia::VideoType}, - {"video/h263", MsgMedia::VideoType}, - {"video/mp4v-es", MsgMedia::VideoType}, - {"audio/x-ms-asf", MsgMedia::VideoType}, - {"video/x-ms-asf", MsgMedia::VideoType}, - {"video/x-ms-asf", MsgMedia::VideoType}, - {"video/avi", MsgMedia::VideoType}, - {"video/mpeg", MsgMedia::VideoType}, - {"video/mp4", MsgMedia::VideoType}, - {"video/mpeg4", MsgMedia::VideoType}, - {"video/x-mp4", MsgMedia::VideoType}, - {"video/x-pv-mp4", MsgMedia::VideoType}, - {"video/mpeg", MsgMedia::VideoType}, - {"video/mpeg", MsgMedia::VideoType}, - {"video/x-pn-multirate-realvideo", MsgMedia::VideoType}, - {"video/vnd.rn-realmedia", MsgMedia::VideoType}, - {"video/vnd.rn-realvideo", MsgMedia::VideoType}, - {"video/x-pn-realvideo", MsgMedia::VideoType}, - {"application/sdp", MsgMedia::VideoType}, - {"video/sdp", MsgMedia::VideoType}, - {"video/x-ms-wmv", MsgMedia::VideoType}, + // Video: + {"video/3gpp", MsgMedia::VideoType}, + {"video/3gp", MsgMedia::VideoType}, + {"video/h263", MsgMedia::VideoType}, + {"video/mp4v-es", MsgMedia::VideoType}, + {"audio/x-ms-asf", MsgMedia::VideoType}, + {"video/x-ms-asf", MsgMedia::VideoType}, + {"video/x-ms-asf", MsgMedia::VideoType}, + {"video/avi", MsgMedia::VideoType}, + {"video/mpeg", MsgMedia::VideoType}, + {"video/mp4", MsgMedia::VideoType}, + {"video/mpeg4", MsgMedia::VideoType}, + {"video/x-mp4", MsgMedia::VideoType}, + {"video/x-pv-mp4", MsgMedia::VideoType}, + {"video/mpeg", MsgMedia::VideoType}, + {"video/mpeg", MsgMedia::VideoType}, + {"video/x-pn-multirate-realvideo", MsgMedia::VideoType}, + {"video/vnd.rn-realmedia", MsgMedia::VideoType}, + {"video/vnd.rn-realvideo", MsgMedia::VideoType}, + {"video/x-pn-realvideo", MsgMedia::VideoType}, + {"application/sdp", MsgMedia::VideoType}, + {"video/sdp", MsgMedia::VideoType}, + {"video/x-ms-wmv", MsgMedia::VideoType}, - // Text: - {"text/plain", MsgMedia::TextType} - }; + // Text: + {"text/plain", MsgMedia::TextType} + }; - inline static const MediaTypeData getMsgMediaTypeByFileExt(const std::string &filePath) - { - std::string base; - std::string name; - std::string ext; + inline static const MediaTypeData getMsgMediaTypeByFileExt(const std::string &filePath) + { + std::string base; + std::string name; + std::string ext; - FileUtils::splitPath(filePath, base, name, ext); - std::transform(ext.begin(), ext.end(), ext.begin(), ::tolower); - auto it = mediaTypeByExtMap.find(ext); - return it != mediaTypeByExtMap.end() ? it->second : MediaTypeData("", MsgMedia::UnknownType); - } + FileUtils::splitPath(filePath, base, name, ext); + std::transform(ext.begin(), ext.end(), ext.begin(), ::tolower); + auto it = mediaTypeByExtMap.find(ext); + return it != mediaTypeByExtMap.end() ? it->second : MediaTypeData("", MsgMedia::UnknownType); + } - inline static MsgMedia::Type getMsgMediaTypeByMime(std::string mime) - { - std::transform(mime.begin(), mime.end(), mime.begin(), ::tolower); + inline static MsgMedia::Type getMsgMediaTypeByMime(std::string mime) + { + std::transform(mime.begin(), mime.end(), mime.begin(), ::tolower); - auto it = mediaTypeByMimeMap.find(mime); - return it != mediaTypeByMimeMap.end() ? it->second : MsgMedia::UnknownType; - } + auto it = mediaTypeByMimeMap.find(mime); + return it != mediaTypeByMimeMap.end() ? it->second : MsgMedia::UnknownType; + } } #endif /* BodyMediaType_h_ */ diff --git a/src/Common/MsgEngine/inc/Message.h b/src/Common/MsgEngine/inc/Message.h index 19edc85..da01df4 100644 --- a/src/Common/MsgEngine/inc/Message.h +++ b/src/Common/MsgEngine/inc/Message.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -25,167 +25,167 @@ #include "MsgList.h" namespace Msg { - class Message; - typedef std::shared_ptr MessageRef; - typedef MsgList MessageList; - typedef std::shared_ptr> MessageListRef; - - /** - * @brief An abstraction that represents message-entity stored in message-service. - */ - class Message { - public: - /** - * @brief Each message can be sent or received, and this enum is used to distinguish the kind of every message. - */ - enum Direction { - MD_Sent = 0, /**< Outgoing message.*/ - MD_Received /**< Incoming message.*/ - }; - - /** - * @brief A type of every message. - */ - enum Type { - MT_Unknown, /**< Unknown type of message. If you got it something bad has happened.*/ - MT_SMS, /**< Text message - sms.*/ - MT_MMS, /**< Multimedia message - mms.*/ - MT_MMS_Noti /**< Depending on message-settings mms can be downloaded by demand. This type of message is aimed to notify user about new incoming mms is available to download.*/ - }; - - /** - * @brief Status of every message. - */ - enum NetworkStatus { - NS_Unknown = -1, /**< Attempt to get message status has failed.*/ - NS_Not_Send, /**< Message is a draft for now.*/ - NS_Sending, /**< message is in progress of sending.*/ - NS_Send_Success, /**< Message was successfully sent.*/ - NS_Send_Fail, /**< Message was failed to sent.*/ - NS_Deliver_Success, /**< Status of successfully sent delivery report.*/ - NS_Deliver_Fail, /**< Status of delivery report sending failure.*/ - NS_Received, /**< Incoming message.*/ - NS_Req_Cancelled, /**< Message network status request canceled.*/ - NS_Retrieving, /**< Message is in progress of retrieving. */ - NS_Retrieve_Success,/**< Message was successfully retrieved.*/ - NS_Retrieve_Fail, /**< Message was failed to retrieve.*/ - NS_Deliver_Pending, /**< Message delivery is pending.*/ - NS_Deliver_Expired, /**< Message delivery is expired.*/ - NS_Send_Pending /**< Message send is pending. */ - }; - - /** - * @brief Defines a storage for messages. - */ - enum MessageStorageType { - MS_Unknown, /**< Unknown storage.*/ - MS_Phone, /**< Phone's internal storage used for regular messages.*/ - MS_Sim /**< Sim-card storage used for messages on SIM.*/ - }; - - public: - virtual ~Message(); - - /** - * @brief Gets type of message. - * @return message type. - */ - virtual Type getType() const = 0; - - /** - * @brief Gets id of message. - * @return message id. - */ - virtual MsgId getId() const = 0; - - /** - * @brief Gets id of thread this message belongs to. - * @return thread id. - */ - virtual ThreadId getThreadId() const = 0; - - /** - * @brief Gets time when message was send\received. - * @return time. - */ - virtual time_t getTime() const = 0; - - /** - * @brief Gets list of addresses this message should be delivered to. - * @return recipients - */ - virtual const MsgAddressList &getAddressList() const = 0; - - /** - * @brief Adds one more recipient address into message. - * @return address added. - */ - virtual MsgAddress &addAddress() = 0; - - /** - * @brief Adds multiple recipient addresses into message. - */ - virtual void addAddresses(const MsgAddressList &list) = 0; - - /** - * @brief Gets message text. - * @return text. - */ - virtual std::string getText() const = 0; - - /** - * @brief Figures out whether message is outgoing or incoming. - * @return direction(in\out). - */ - virtual Message::Direction getDirection() const = 0; - - /** - * @brief Gets message network status. - * @return network status. - */ - virtual NetworkStatus getNetworkStatus() const = 0; - - /** - * @brief Returns message size, - * @return size. - */ - virtual int getSize() const = 0; - - /** - * @brief Gets message's subject if there's any. - * @return a subject string. - */ - virtual std::string getSubject() const = 0; - - /** - * @brief Adds subject-string into a message or replacing old one if message the subject. - * @param[in] text a new subject - */ - virtual void setSubject(const std::string &text) = 0; - - /** - * @brief Changes message's storage type. - * @param[in] msgStorage new storage type. - */ - virtual void setMessageStorageType(Message::MessageStorageType msgStorage) = 0; - - /** - * @brief Gets type of storage that contains this message. - */ - virtual Message::MessageStorageType getMessageStorageType() const = 0; - - /** - * @brief Checks whether this message is mms or not. - * @return true in case of mms, false otherwise. - */ - virtual bool isMms() const = 0; - - /** - * @brief Checks whether this message is restricted by DPM policy. - * @return true in case of restriction, false otherwise. - */ - virtual bool isRestrictedByDpm() const = 0; - }; + class Message; + typedef std::shared_ptr MessageRef; + typedef MsgList MessageList; + typedef std::shared_ptr> MessageListRef; + + /** + * @brief An abstraction that represents message-entity stored in message-service. + */ + class Message { + public: + /** + * @brief Each message can be sent or received, and this enum is used to distinguish the kind of every message. + */ + enum Direction { + MD_Sent = 0, /**< Outgoing message.*/ + MD_Received /**< Incoming message.*/ + }; + + /** + * @brief A type of every message. + */ + enum Type { + MT_Unknown, /**< Unknown type of message. If you got it something bad has happened.*/ + MT_SMS, /**< Text message - sms.*/ + MT_MMS, /**< Multimedia message - mms.*/ + MT_MMS_Noti /**< Depending on message-settings mms can be downloaded by demand. This type of message is aimed to notify user about new incoming mms is available to download.*/ + }; + + /** + * @brief Status of every message. + */ + enum NetworkStatus { + NS_Unknown = -1, /**< Attempt to get message status has failed.*/ + NS_Not_Send, /**< Message is a draft for now.*/ + NS_Sending, /**< message is in progress of sending.*/ + NS_Send_Success, /**< Message was successfully sent.*/ + NS_Send_Fail, /**< Message was failed to sent.*/ + NS_Deliver_Success, /**< Status of successfully sent delivery report.*/ + NS_Deliver_Fail, /**< Status of delivery report sending failure.*/ + NS_Received, /**< Incoming message.*/ + NS_Req_Cancelled, /**< Message network status request canceled.*/ + NS_Retrieving, /**< Message is in progress of retrieving. */ + NS_Retrieve_Success,/**< Message was successfully retrieved.*/ + NS_Retrieve_Fail, /**< Message was failed to retrieve.*/ + NS_Deliver_Pending, /**< Message delivery is pending.*/ + NS_Deliver_Expired, /**< Message delivery is expired.*/ + NS_Send_Pending /**< Message send is pending. */ + }; + + /** + * @brief Defines a storage for messages. + */ + enum MessageStorageType { + MS_Unknown, /**< Unknown storage.*/ + MS_Phone, /**< Phone's internal storage used for regular messages.*/ + MS_Sim /**< Sim-card storage used for messages on SIM.*/ + }; + + public: + virtual ~Message(); + + /** + * @brief Gets type of message. + * @return message type. + */ + virtual Type getType() const = 0; + + /** + * @brief Gets id of message. + * @return message id. + */ + virtual MsgId getId() const = 0; + + /** + * @brief Gets id of thread this message belongs to. + * @return thread id. + */ + virtual ThreadId getThreadId() const = 0; + + /** + * @brief Gets time when message was send\received. + * @return time. + */ + virtual time_t getTime() const = 0; + + /** + * @brief Gets list of addresses this message should be delivered to. + * @return recipients + */ + virtual const MsgAddressList &getAddressList() const = 0; + + /** + * @brief Adds one more recipient address into message. + * @return address added. + */ + virtual MsgAddress &addAddress() = 0; + + /** + * @brief Adds multiple recipient addresses into message. + */ + virtual void addAddresses(const MsgAddressList &list) = 0; + + /** + * @brief Gets message text. + * @return text. + */ + virtual std::string getText() const = 0; + + /** + * @brief Figures out whether message is outgoing or incoming. + * @return direction(in\out). + */ + virtual Message::Direction getDirection() const = 0; + + /** + * @brief Gets message network status. + * @return network status. + */ + virtual NetworkStatus getNetworkStatus() const = 0; + + /** + * @brief Returns message size, + * @return size. + */ + virtual int getSize() const = 0; + + /** + * @brief Gets message's subject if there's any. + * @return a subject string. + */ + virtual std::string getSubject() const = 0; + + /** + * @brief Adds subject-string into a message or replacing old one if message the subject. + * @param[in] text a new subject + */ + virtual void setSubject(const std::string &text) = 0; + + /** + * @brief Changes message's storage type. + * @param[in] msgStorage new storage type. + */ + virtual void setMessageStorageType(Message::MessageStorageType msgStorage) = 0; + + /** + * @brief Gets type of storage that contains this message. + */ + virtual Message::MessageStorageType getMessageStorageType() const = 0; + + /** + * @brief Checks whether this message is mms or not. + * @return true in case of mms, false otherwise. + */ + virtual bool isMms() const = 0; + + /** + * @brief Checks whether this message is restricted by DPM policy. + * @return true in case of restriction, false otherwise. + */ + virtual bool isRestrictedByDpm() const = 0; + }; } #endif /* __MESSAGE_H__ */ diff --git a/src/Common/MsgEngine/inc/MessageMms.h b/src/Common/MsgEngine/inc/MessageMms.h index c4f18c2..bb5592f 100644 --- a/src/Common/MsgEngine/inc/MessageMms.h +++ b/src/Common/MsgEngine/inc/MessageMms.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -25,23 +25,23 @@ #include namespace Msg { - class MessageMms; - typedef std::shared_ptr MessageMmsRef; - typedef MsgList MessageMmsList; - typedef std::shared_ptr> MessageMmsListRef; + class MessageMms; + typedef std::shared_ptr MessageMmsRef; + typedef MsgList MessageMmsList; + typedef std::shared_ptr> MessageMmsListRef; - class MessageMms : - public virtual Message { - public: - virtual ~MessageMms(); + class MessageMms : + public virtual Message { + public: + virtual ~MessageMms(); - virtual const MsgPageList &getPageList() const = 0; - virtual MsgPage &addPage() = 0; - virtual const MsgAttachmentList &getAttachmentList() const = 0; - virtual MsgAttachment &addAttachment() = 0; - virtual int getMediaCount() const = 0; - virtual time_t getExpired() const = 0; - }; + virtual const MsgPageList &getPageList() const = 0; + virtual MsgPage &addPage() = 0; + virtual const MsgAttachmentList &getAttachmentList() const = 0; + virtual MsgAttachment &addAttachment() = 0; + virtual int getMediaCount() const = 0; + virtual time_t getExpired() const = 0; + }; } #endif /* _MESSAGE_MMS_H__ */ diff --git a/src/Common/MsgEngine/inc/MessageSMS.h b/src/Common/MsgEngine/inc/MessageSMS.h index f69888d..d96c39b 100644 --- a/src/Common/MsgEngine/inc/MessageSMS.h +++ b/src/Common/MsgEngine/inc/MessageSMS.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -23,23 +23,23 @@ #include namespace Msg { - class MessageSMS; - typedef std::shared_ptr MessageSMSRef; - typedef MsgList MessageSMSList; - typedef std::shared_ptr> MessageSMSListRef; + class MessageSMS; + typedef std::shared_ptr MessageSMSRef; + typedef MsgList MessageSMSList; + typedef std::shared_ptr> MessageSMSListRef; - class MessageSMS: - public virtual Message { - public: - MessageSMS(); - virtual ~MessageSMS(); + class MessageSMS: + public virtual Message { + public: + MessageSMS(); + virtual ~MessageSMS(); - /** - * @brief Sets text into message - * @param[in] text message text. - */ - virtual void setText(const std::string &text) = 0; - }; + /** + * @brief Sets text into message + * @param[in] text message text. + */ + virtual void setText(const std::string &text) = 0; + }; } #endif /* _MESSAGE_SMS_H__ */ diff --git a/src/Common/MsgEngine/inc/MsgAddress.h b/src/Common/MsgEngine/inc/MsgAddress.h index c63f4d7..b0d1b39 100644 --- a/src/Common/MsgEngine/inc/MsgAddress.h +++ b/src/Common/MsgEngine/inc/MsgAddress.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -23,75 +23,75 @@ #include namespace Msg { - class MsgAddress; - typedef MsgList MsgAddressList; - typedef std::shared_ptr> MsgAddressListRef; + class MsgAddress; + typedef MsgList MsgAddressList; + typedef std::shared_ptr> MsgAddressListRef; - /** - * @brief Basic abstraction that represents a recipient's address message should be delivered to. - */ - class MsgAddress { - public: - /** - * @brief Type of address. - */ - enum AddressType - { - Phone, /**< Phone number*/ - Email, /**< Email address*/ - UnknownAddressType /**< Unknown address, you get it if phone number format or email-format validations has failed to parce address.*/ - }; + /** + * @brief Basic abstraction that represents a recipient's address message should be delivered to. + */ + class MsgAddress { + public: + /** + * @brief Type of address. + */ + enum AddressType + { + Phone, /**< Phone number*/ + Email, /**< Email address*/ + UnknownAddressType /**< Unknown address, you get it if phone number format or email-format validations has failed to parce address.*/ + }; - /** - * @brief A kind of recipient that defines a way how message should be delivered to this address. - */ - enum RecipientType - { - To, /**< Primary recipient, messages are sent directly to this address.*/ - Cc, /**< "Carbon copy", secondary recipient. This address gets a message as a copy of original message sent to other "TO"-recipient.*/ - Bcc, /**< "Blind carbon copy" to tertiary recipients who receive the message. The primary and secondary recipients cannot see the tertiary recipients.*/ - UnknownRecipientType - }; + /** + * @brief A kind of recipient that defines a way how message should be delivered to this address. + */ + enum RecipientType + { + To, /**< Primary recipient, messages are sent directly to this address.*/ + Cc, /**< "Carbon copy", secondary recipient. This address gets a message as a copy of original message sent to other "TO"-recipient.*/ + Bcc, /**< "Blind carbon copy" to tertiary recipients who receive the message. The primary and secondary recipients cannot see the tertiary recipients.*/ + UnknownRecipientType + }; - public: - virtual ~MsgAddress() {}; + public: + virtual ~MsgAddress() {}; - /** - * @brief Gets address string. - * @return address string. - **/ - virtual std::string getAddress() const = 0; + /** + * @brief Gets address string. + * @return address string. + **/ + virtual std::string getAddress() const = 0; - /** - * @brief Gets address type. - * @return address type. - **/ - virtual AddressType getAddressType() const = 0; + /** + * @brief Gets address type. + * @return address type. + **/ + virtual AddressType getAddressType() const = 0; - /** - * @brief Gets recipient type. - * @return recipient type. - **/ - virtual RecipientType getRecipientType() const = 0; + /** + * @brief Gets recipient type. + * @return recipient type. + **/ + virtual RecipientType getRecipientType() const = 0; - /** - * @brief Sets address-string. - * @param[in] address address string. - */ - virtual void setAddress(const std::string &address) = 0; + /** + * @brief Sets address-string. + * @param[in] address address string. + */ + virtual void setAddress(const std::string &address) = 0; - /** - * @brief Sets type of address. - * @param[in] type address type. - */ - virtual void setAddressType(AddressType type) = 0; + /** + * @brief Sets type of address. + * @param[in] type address type. + */ + virtual void setAddressType(AddressType type) = 0; - /** - * @brief Sets recipient type. - * @param[in] type recipient type. - */ - virtual void setRecipientType(RecipientType type) = 0; - }; + /** + * @brief Sets recipient type. + * @param[in] type recipient type. + */ + virtual void setRecipientType(RecipientType type) = 0; + }; } #endif /* MsgAddress_h_ */ diff --git a/src/Common/MsgEngine/inc/MsgAttachment.h b/src/Common/MsgEngine/inc/MsgAttachment.h index 6e314bb..cff5e13 100644 --- a/src/Common/MsgEngine/inc/MsgAttachment.h +++ b/src/Common/MsgEngine/inc/MsgAttachment.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -21,20 +21,20 @@ #include namespace Msg { - class MsgAttachment; - typedef std::shared_ptr MsgAttachmentRef; - typedef MsgList MsgAttachmentList; - typedef std::shared_ptr> MsgAttachmentListRef; + class MsgAttachment; + typedef std::shared_ptr MsgAttachmentRef; + typedef MsgList MsgAttachmentList; + typedef std::shared_ptr> MsgAttachmentListRef; - class MsgAttachment { - public: - virtual ~MsgAttachment() {}; - virtual std::string getFilePath() const = 0; - 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; - }; + class MsgAttachment { + public: + virtual ~MsgAttachment() {}; + virtual std::string getFilePath() const = 0; + 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; + }; } #endif /* _MSG_ATTACHMENT_H__ */ diff --git a/src/Common/MsgEngine/inc/MsgComposer.h b/src/Common/MsgEngine/inc/MsgComposer.h index 7bf4d48..628bd05 100644 --- a/src/Common/MsgEngine/inc/MsgComposer.h +++ b/src/Common/MsgEngine/inc/MsgComposer.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -26,36 +26,36 @@ #include namespace Msg { - class MsgComposer { - public: - virtual ~MsgComposer() {}; - - virtual MessageSMSRef createSms() = 0; - virtual MessageMmsRef createMms() = 0; - - /** - * @brief Calculates input text length by encode type. - * @param[in] text input text. - * @param[out] text metric. - **/ - virtual void calculateTextMetric(const std::string &text, MsgTextMetric &textMetric) = 0; - - MessageRef createMessage(Message::Type type); - }; - - inline MessageRef MsgComposer::createMessage(Message::Type type) - { - MessageRef msg; - - if (MsgUtils::isSms(type)) - msg = createSms(); - else if (MsgUtils::isMms(type)) - msg = createMms(); - else - MSG_LOG_WARN("Unknown message type"); - - return msg; - } + class MsgComposer { + public: + virtual ~MsgComposer() {}; + + virtual MessageSMSRef createSms() = 0; + virtual MessageMmsRef createMms() = 0; + + /** + * @brief Calculates input text length by encode type. + * @param[in] text input text. + * @param[out] text metric. + **/ + virtual void calculateTextMetric(const std::string &text, MsgTextMetric &textMetric) = 0; + + MessageRef createMessage(Message::Type type); + }; + + inline MessageRef MsgComposer::createMessage(Message::Type type) + { + MessageRef msg; + + if (MsgUtils::isSms(type)) + msg = createSms(); + else if (MsgUtils::isMms(type)) + msg = createMms(); + else + MSG_LOG_WARN("Unknown message type"); + + return msg; + } } #endif /* __MSG_COMPOSER_H__ */ diff --git a/src/Common/MsgEngine/inc/MsgConvMedia.h b/src/Common/MsgEngine/inc/MsgConvMedia.h index 9f6be5f..10037cb 100644 --- a/src/Common/MsgEngine/inc/MsgConvMedia.h +++ b/src/Common/MsgEngine/inc/MsgConvMedia.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -23,21 +23,21 @@ #include namespace Msg { - class MsgConvMedia; - typedef MsgList MsgConvMediaList; - typedef std::shared_ptr> MsgConvMediaListRef; + class MsgConvMedia; + typedef MsgList MsgConvMediaList; + typedef std::shared_ptr> MsgConvMediaListRef; - class MsgConvMedia { - public: - virtual ~MsgConvMedia() {}; + class MsgConvMedia { + public: + virtual ~MsgConvMedia() {}; - virtual std::string getMime() const = 0; - virtual std::string getName() const = 0; - virtual std::string getPath() const = 0; - virtual std::string getThumbPath() const = 0; - virtual std::string getContentId() const = 0; - virtual std::string getContentLocation() const = 0; - }; + virtual std::string getMime() const = 0; + virtual std::string getName() const = 0; + virtual std::string getPath() const = 0; + virtual std::string getThumbPath() const = 0; + virtual std::string getContentId() const = 0; + virtual std::string getContentLocation() const = 0; + }; } #endif /* MSGCONVMEDIA_H_ */ diff --git a/src/Common/MsgEngine/inc/MsgConversationItem.h b/src/Common/MsgEngine/inc/MsgConversationItem.h index 95f55cf..74ffb52 100644 --- a/src/Common/MsgEngine/inc/MsgConversationItem.h +++ b/src/Common/MsgEngine/inc/MsgConversationItem.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -26,101 +26,101 @@ #include namespace Msg { - class MsgConversationItem; - typedef std::shared_ptr MsgConversationItemRef; - typedef std::shared_ptr> MsgConversationListRef; - - /** - * @brief An interface that provides basic information about conversation-list item. - */ - class MsgConversationItem { - public: - virtual ~MsgConversationItem(); - - /** - * @brief Gets id of thread this conversation-item belongs to. - * @return thread id. - */ - virtual ThreadId getThreadId() const = 0; - - /** - * @brief Gets id of message this conversation-item is related with. - * @return message id. - */ - virtual MsgId getMsgId() const = 0; - - /** - * @brief Gets message-text displayed in conversation-item. - * @return message text. - */ - virtual std::string getText() const = 0; - - /** - * @brief Gets subject-string. - * @brief subject. - */ - virtual std::string getSubject() const = 0; - - /** - * @brief Gets a time when message status was updated last time(it could happen after sending\receiving\editing draft/etc). - * @return time. - */ - virtual time_t getTime() const = 0; - - /** - * @brief Gets message direction. - * @return direction: Outgoing or Incoming - */ - virtual Message::Direction getDirection() const = 0; - - /** - * @brief Gets message type. - * @return message type. - */ - virtual Message::Type getType() const = 0; - - /** - * @brief Gets message network status. - * @return message network status. - */ - virtual Message::NetworkStatus getNetworkStatus() const = 0; - - /** - * @brief Checks whether conversation-item is related to draft message or not. - * @return true if message is draft, false otherwise. - */ - virtual bool isDraft() const = 0; - - /** - * @brief Checks whether conversation-item is related to read message or not. - * @return true if message is read, false otherwise. - */ - virtual bool isRead() const = 0; - - /** - * @brief Gets the count of pages message related to this conversation item contains. - * @return number of pages. - */ - virtual int getPagesCount() const = 0; - - /** - * @brief Gets the count of attachments message related to this conversation item contains. - * @return number of attachments. - */ - virtual int getAttachCount() const = 0; - - /** - * @brief Gets media-files list. - * @return media-files list. - */ - virtual const MsgConvMediaList &getMediaList() const = 0; - - /** - * @brief Checks whether this message is restricted by DPM policy. - * @return true in case of restriction, false otherwise. - */ - virtual bool isRestrictedByDpm() const = 0; - }; + class MsgConversationItem; + typedef std::shared_ptr MsgConversationItemRef; + typedef std::shared_ptr> MsgConversationListRef; + + /** + * @brief An interface that provides basic information about conversation-list item. + */ + class MsgConversationItem { + public: + virtual ~MsgConversationItem(); + + /** + * @brief Gets id of thread this conversation-item belongs to. + * @return thread id. + */ + virtual ThreadId getThreadId() const = 0; + + /** + * @brief Gets id of message this conversation-item is related with. + * @return message id. + */ + virtual MsgId getMsgId() const = 0; + + /** + * @brief Gets message-text displayed in conversation-item. + * @return message text. + */ + virtual std::string getText() const = 0; + + /** + * @brief Gets subject-string. + * @brief subject. + */ + virtual std::string getSubject() const = 0; + + /** + * @brief Gets a time when message status was updated last time(it could happen after sending\receiving\editing draft/etc). + * @return time. + */ + virtual time_t getTime() const = 0; + + /** + * @brief Gets message direction. + * @return direction: Outgoing or Incoming + */ + virtual Message::Direction getDirection() const = 0; + + /** + * @brief Gets message type. + * @return message type. + */ + virtual Message::Type getType() const = 0; + + /** + * @brief Gets message network status. + * @return message network status. + */ + virtual Message::NetworkStatus getNetworkStatus() const = 0; + + /** + * @brief Checks whether conversation-item is related to draft message or not. + * @return true if message is draft, false otherwise. + */ + virtual bool isDraft() const = 0; + + /** + * @brief Checks whether conversation-item is related to read message or not. + * @return true if message is read, false otherwise. + */ + virtual bool isRead() const = 0; + + /** + * @brief Gets the count of pages message related to this conversation item contains. + * @return number of pages. + */ + virtual int getPagesCount() const = 0; + + /** + * @brief Gets the count of attachments message related to this conversation item contains. + * @return number of attachments. + */ + virtual int getAttachCount() const = 0; + + /** + * @brief Gets media-files list. + * @return media-files list. + */ + virtual const MsgConvMediaList &getMediaList() const = 0; + + /** + * @brief Checks whether this message is restricted by DPM policy. + * @return true in case of restriction, false otherwise. + */ + virtual bool isRestrictedByDpm() const = 0; + }; } #endif /* __MSG_CONVERSATION_ITEM_H__ */ diff --git a/src/Common/MsgEngine/inc/MsgEngine.h b/src/Common/MsgEngine/inc/MsgEngine.h index 00fb908..23bf9f5 100644 --- a/src/Common/MsgEngine/inc/MsgEngine.h +++ b/src/Common/MsgEngine/inc/MsgEngine.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -34,67 +34,67 @@ #include "MsgTypes.h" namespace Msg { - /** - * @brief Core-instance of whole mechanism that interacts with message-service. - */ - class MsgEngine { - public: - MsgEngine(); - ~MsgEngine(); - - /** - * @brief Initiates connection to message-service. - * @returns msg-service specific success code in case of success, otherwise returns error-code. - */ - int openService(); - - /** - * @brief Closes connection to message-service. - * @returns msg-service specific success code in case of success, otherwise returns error-code. - */ - int closeService(); - - /** - * @brief Checks whether message-service opened is ready to operate(was openService() called before or not). - * @param[out] error-message string filled if no connection to message service was opened. - * @result true if message-service is already opened, otherwise false. - */ - bool isReady(std::string &errorMsg) const; - - MsgStorage &getStorage(); - const MsgStorage &getStorage() const; - - MsgTransport &getTransport(); - const MsgTransport &getTransport() const; - - MsgSettings &getSettings(); - const MsgSettings &getSettings() const; - - MsgComposer &getComposer(); - const MsgComposer &getComposer() const; - - /** - * @brief Converts msg-service error codes into a string representation. - * @param[in] error an msg-service side error code - * @result msg-service define name string, e.g "MESSAGES_ERROR_NONE" for MESSAGES_ERROR_NONE code. - */ - static std::string whatError(int error); - - private: - std::unique_ptr m_Storage; - std::unique_ptr m_Transport; - std::unique_ptr m_Settings; - std::unique_ptr m_Composer; - #ifdef MSG_PRIVATE_API - msg_handle_t m_MsgHandle; - #elif MSG_PUBLIC_API - messages_service_h m_MsgHandle; - #endif - }; + /** + * @brief Core-instance of whole mechanism that interacts with message-service. + */ + class MsgEngine { + public: + MsgEngine(); + ~MsgEngine(); + + /** + * @brief Initiates connection to message-service. + * @returns msg-service specific success code in case of success, otherwise returns error-code. + */ + int openService(); + + /** + * @brief Closes connection to message-service. + * @returns msg-service specific success code in case of success, otherwise returns error-code. + */ + int closeService(); + + /** + * @brief Checks whether message-service opened is ready to operate(was openService() called before or not). + * @param[out] error-message string filled if no connection to message service was opened. + * @result true if message-service is already opened, otherwise false. + */ + bool isReady(std::string &errorMsg) const; + + MsgStorage &getStorage(); + const MsgStorage &getStorage() const; + + MsgTransport &getTransport(); + const MsgTransport &getTransport() const; + + MsgSettings &getSettings(); + const MsgSettings &getSettings() const; + + MsgComposer &getComposer(); + const MsgComposer &getComposer() const; + + /** + * @brief Converts msg-service error codes into a string representation. + * @param[in] error an msg-service side error code + * @result msg-service define name string, e.g "MESSAGES_ERROR_NONE" for MESSAGES_ERROR_NONE code. + */ + static std::string whatError(int error); + + private: + std::unique_ptr m_Storage; + std::unique_ptr m_Transport; + std::unique_ptr m_Settings; + std::unique_ptr m_Composer; + #ifdef MSG_PRIVATE_API + msg_handle_t m_MsgHandle; + #elif MSG_PUBLIC_API + messages_service_h m_MsgHandle; + #endif + }; } #define MSG_ENGINE_WHAT_ERROR(error)\ - MSG_LOG_INFO("Error = ", MsgEngine::whatError(error)) + MSG_LOG_INFO("Error = ", MsgEngine::whatError(error)) #endif /* __MSG_ENGINE_H__ */ diff --git a/src/Common/MsgEngine/inc/MsgList.h b/src/Common/MsgEngine/inc/MsgList.h index 39b0041..9204a38 100644 --- a/src/Common/MsgEngine/inc/MsgList.h +++ b/src/Common/MsgEngine/inc/MsgList.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -19,56 +19,56 @@ namespace Msg { - /** - * @brief Generic container for message-objects. - */ - template - class MsgList { - public: - typedef T Type; + /** + * @brief Generic container for message-objects. + */ + template + class MsgList { + public: + typedef T Type; - public: - virtual ~MsgList() {} + public: + virtual ~MsgList() {} - /** - * @brief Constant getter by index.. - * @param[in] i index. - * @return message-object. - */ - virtual const T &at(int i) const = 0; + /** + * @brief Constant getter by index.. + * @param[in] i index. + * @return message-object. + */ + virtual const T &at(int i) const = 0; - /** - * @brief Nonconstant getter by index.. - * @param[in] i index. - * @return message-object. - */ - virtual T &at(int i) = 0; + /** + * @brief Nonconstant getter by index.. + * @param[in] i index. + * @return message-object. + */ + virtual T &at(int i) = 0; - /** - * @brief Gets count of message-objects list contains. - * @return list size. - */ - virtual int getLength() const = 0; + /** + * @brief Gets count of message-objects list contains. + * @return list size. + */ + virtual int getLength() const = 0; - inline const T &operator[](int i) const - { - return at(i); - } + inline const T &operator[](int i) const + { + return at(i); + } - inline const T &operator[](int i) - { - return at(i); - } + inline const T &operator[](int i) + { + return at(i); + } - /** - * @brief Checks if list is empty or not. - * @return true if list is empty, false otherwise. - */ - inline bool isEmpty() const - { - return getLength() <= 0; - } - }; + /** + * @brief Checks if list is empty or not. + * @return true if list is empty, false otherwise. + */ + inline bool isEmpty() const + { + return getLength() <= 0; + } + }; } #endif /* MsgList_H_ */ diff --git a/src/Common/MsgEngine/inc/MsgMedia.h b/src/Common/MsgEngine/inc/MsgMedia.h index f336aed..e0ae493 100644 --- a/src/Common/MsgEngine/inc/MsgMedia.h +++ b/src/Common/MsgEngine/inc/MsgMedia.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -21,55 +21,55 @@ #include namespace Msg { - class MsgMedia; - typedef std::shared_ptr MsgMediaRef; - typedef MsgList MsgMediaList; - typedef std::shared_ptr> MsgMediaListRef; + class MsgMedia; + typedef std::shared_ptr MsgMediaRef; + typedef MsgList MsgMediaList; + typedef std::shared_ptr> MsgMediaListRef; - /** - * @brief represents a file to be attached to message. - */ - class MsgMedia { - public: - /** - * @brief Attacment-type. - */ - enum Type - { - UnknownType = 0, /**< File type unsupported by smil-player, can't be played by smil-player. Attached as unknown filetype.*/ - ImageType, /**< Image file. Can be played with smil-player.*/ - AudioType, /**< Audio file. Can be played with smil-player.*/ - VideoType, /**< Video file. Can be played with smil-player.*/ - TextType, /**< Text-section of page.*/ - }; + /** + * @brief represents a file to be attached to message. + */ + class MsgMedia { + public: + /** + * @brief Attacment-type. + */ + enum Type + { + UnknownType = 0, /**< File type unsupported by smil-player, can't be played by smil-player. Attached as unknown filetype.*/ + ImageType, /**< Image file. Can be played with smil-player.*/ + AudioType, /**< Audio file. Can be played with smil-player.*/ + VideoType, /**< Video file. Can be played with smil-player.*/ + TextType, /**< Text-section of page.*/ + }; - public: - virtual ~MsgMedia() {}; + public: + virtual ~MsgMedia() {}; - /** - * @brief Gets type of media. - * @return media type. - */ - virtual Type getType() const = 0; + /** + * @brief Gets type of media. + * @return media type. + */ + virtual Type getType() const = 0; - /** - * @brief Gets path to file. - * @return path. - */ - virtual std::string getFilePath() const = 0; + /** + * @brief Gets path to file. + * @return path. + */ + virtual std::string getFilePath() const = 0; - /** - * @brief Gets filename. - * @return filename. - */ - virtual std::string getFileName() const = 0; + /** + * @brief Gets filename. + * @return filename. + */ + virtual std::string getFileName() const = 0; - /** - * @brief Sets path to file. - * @param[in] path. - */ - virtual void setFilePath(const std::string &path) = 0; - }; + /** + * @brief Sets path to file. + * @param[in] path. + */ + virtual void setFilePath(const std::string &path) = 0; + }; } #endif /* _MSG_MEDIA_H__ */ diff --git a/src/Common/MsgEngine/inc/MsgPage.h b/src/Common/MsgEngine/inc/MsgPage.h index a327971..7d9f57c 100644 --- a/src/Common/MsgEngine/inc/MsgPage.h +++ b/src/Common/MsgEngine/inc/MsgPage.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -20,49 +20,49 @@ #include "MsgMedia.h" namespace Msg { - class MsgPage; - typedef std::shared_ptr MsgPageRef; - typedef MsgList MsgPageList; - typedef std::shared_ptr> MsgPageListRef; + class MsgPage; + typedef std::shared_ptr MsgPageRef; + typedef MsgList MsgPageList; + typedef std::shared_ptr> MsgPageListRef; - /** - * @brief An abstraction that represents a concept of "page". - * This is a part of MMS that contains one previewable attachment(video or image) and a number of attachments that have no preview(documents, audio-files etc). - */ - class MsgPage { - public: - virtual ~MsgPage(); + /** + * @brief An abstraction that represents a concept of "page". + * This is a part of MMS that contains one previewable attachment(video or image) and a number of attachments that have no preview(documents, audio-files etc). + */ + class MsgPage { + public: + virtual ~MsgPage(); - /** - * @brief Non-constant getter of media-attachment list. - * @return list of media-attachments. - */ - virtual MsgMediaList &getMediaList() = 0; + /** + * @brief Non-constant getter of media-attachment list. + * @return list of media-attachments. + */ + virtual MsgMediaList &getMediaList() = 0; - /** - * @brief Constant getter of media-attachment list. - * @return read-only media-attachment list. - */ - const MsgMediaList &getMediaList() const; + /** + * @brief Constant getter of media-attachment list. + * @return read-only media-attachment list. + */ + const MsgMediaList &getMediaList() const; - /** - * @brief Adds media to pages. - * @return media-structure that was added. - */ - virtual MsgMedia &addMedia() = 0; + /** + * @brief Adds media to pages. + * @return media-structure that was added. + */ + virtual MsgMedia &addMedia() = 0; - /** - * @brief Sets page duration. - * @param[in] duration page duration in milliseconds. - */ - virtual void setPageDuration(int duration) = 0; + /** + * @brief Sets page duration. + * @param[in] duration page duration in milliseconds. + */ + virtual void setPageDuration(int duration) = 0; - /** - * @brief Gets page duration. - * @return duration page duration in milliseconds. - */ - virtual int getPageDuration() const = 0; - }; + /** + * @brief Gets page duration. + * @return duration page duration in milliseconds. + */ + virtual int getPageDuration() const = 0; + }; } #endif /* _MSG_PAGE_H__ */ diff --git a/src/Common/MsgEngine/inc/MsgReport.h b/src/Common/MsgEngine/inc/MsgReport.h index 7a2f029..0819db2 100644 --- a/src/Common/MsgEngine/inc/MsgReport.h +++ b/src/Common/MsgEngine/inc/MsgReport.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -23,41 +23,41 @@ #include namespace Msg { - class MsgReport; - typedef MsgList MsgReportList; - typedef std::shared_ptr> MsgReportListRef; + class MsgReport; + typedef MsgList MsgReportList; + typedef std::shared_ptr> MsgReportListRef; - class MsgReport { - public: - enum DeliveryStatus { - StatusNone, - StatusExpired, - StatusSuccess, - StatusRejected - }; + class MsgReport { + public: + enum DeliveryStatus { + StatusNone, + StatusExpired, + StatusSuccess, + StatusRejected + }; - enum ReadStatus { - ReadStatusNone, - ReadStatusIsRead, - ReadStatusIsDeleted, - ReadStatusRejectByUser - }; + enum ReadStatus { + ReadStatusNone, + ReadStatusIsRead, + ReadStatusIsDeleted, + ReadStatusRejectByUser + }; - enum Type { - TypeDelivery, - TypeRead, - TypeReadReportSent - }; + enum Type { + TypeDelivery, + TypeRead, + TypeReadReportSent + }; - public: - virtual ~MsgReport() {}; + public: + virtual ~MsgReport() {}; - virtual std::string getAddress() const = 0; - virtual DeliveryStatus getDeliveryStatus() const = 0; - virtual ReadStatus getReadStatus() const = 0; - virtual Type getType() const = 0; - virtual time_t getTime() const = 0; - }; + virtual std::string getAddress() const = 0; + virtual DeliveryStatus getDeliveryStatus() const = 0; + virtual ReadStatus getReadStatus() const = 0; + virtual Type getType() const = 0; + virtual time_t getTime() const = 0; + }; } diff --git a/src/Common/MsgEngine/inc/MsgSentStatus.h b/src/Common/MsgEngine/inc/MsgSentStatus.h index 19767a9..fd59a6c 100644 --- a/src/Common/MsgEngine/inc/MsgSentStatus.h +++ b/src/Common/MsgEngine/inc/MsgSentStatus.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -22,13 +22,13 @@ #include "Message.h" namespace Msg { - class MsgSentStatus { - public: - virtual ~MsgSentStatus() {}; + class MsgSentStatus { + public: + virtual ~MsgSentStatus() {}; - virtual RequestId getId() const = 0; - virtual Message::NetworkStatus getNetworkStatus() const = 0; - }; + virtual RequestId getId() const = 0; + virtual Message::NetworkStatus getNetworkStatus() const = 0; + }; } diff --git a/src/Common/MsgEngine/inc/MsgSettings.h b/src/Common/MsgEngine/inc/MsgSettings.h index 2f75e6a..b441807 100644 --- a/src/Common/MsgEngine/inc/MsgSettings.h +++ b/src/Common/MsgEngine/inc/MsgSettings.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -23,92 +23,92 @@ #include namespace Msg { - class IMsgSettingsListener; - - class MsgSettings { - public: - enum ActiveNotifPolicy { - AppBackgroundPolicy, // App is not running or on background. - AppForegroundPolicy // App is running and on foreground, but not in conversation. - }; - - enum RingtoneType { - DefaultRingtone, - SilentRingtone, - UserRingtone - }; - - public: - MsgSettings(); - virtual ~MsgSettings(); - - void addListener(IMsgSettingsListener &listener); - void removeListener(IMsgSettingsListener &listener); - - int getMessageTextMaxChar() const; - int getMessageMaxPage() const; - int getAttachmentsMaxCount() const; - virtual int getAddressMaxLen() const = 0; - virtual int getPhoneNumberMaxLen() const = 0; - virtual int getAddressMaxCount() const = 0; - virtual int getSubjectMaxLen() const = 0; - virtual int getDisplayNameMaxLen() const = 0; - virtual int getMaxRecipientCount() const = 0; - virtual int getMaxMmsSize() const = 0; - virtual int getMaxMsgTextLen() const = 0; - - virtual void setAlerts(bool value) = 0; - virtual bool getAlerts() const = 0; - - virtual void setRingtoneType(RingtoneType type) = 0; - virtual RingtoneType getRingtoneType() const = 0; - virtual void setRingtone(const std::string &soundPath) = 0; - virtual std::string getRingtone() const = 0; - - virtual void setVibration(bool value) = 0; - virtual bool getVibration() const = 0; - - virtual void setSmsDelivReport(bool value) = 0; - virtual bool getSmsDelivReport() const = 0; - - virtual void setMmsDelivReport(bool value) = 0; - virtual bool getMmsDelivReport() const = 0; - - virtual void setMmsReadReport(bool value) = 0; - virtual bool getMmsReadReport() const = 0; - - virtual void setMmsAutoRetr(bool value) = 0; - virtual bool getMmsAutoRetr() const = 0; - - virtual void setMmsAutoRetrRoaming(bool value) = 0; - virtual bool getMmsAutoRetrRoaming() const = 0; - - virtual void setActiveNotifPolicy(ActiveNotifPolicy type) = 0; - virtual void setActiveNotifPolicy(ThreadId id) = 0; - - void setSendAsAudio(bool value); - bool getSendAsAudio() const; - - protected: - typedef std::vector MsgSettingsListeners; - - protected: - MsgSettingsListeners m_Listeners; - - private: - MsgSettings(MsgSettings&) = delete; - MsgSettings& operator=(MsgSettings&) = delete; - - void onSendAsAudioChanged(const char *key); - void prepareSendAsAudio(); - }; - - class IMsgSettingsListener { - public: - virtual ~IMsgSettingsListener() {} - virtual void onRingtoneChanged(MsgSettings &msgSetting) {}; - virtual void onSendAsAudioChanged(MsgSettings &msgSetting) {}; - }; + class IMsgSettingsListener; + + class MsgSettings { + public: + enum ActiveNotifPolicy { + AppBackgroundPolicy, // App is not running or on background. + AppForegroundPolicy // App is running and on foreground, but not in conversation. + }; + + enum RingtoneType { + DefaultRingtone, + SilentRingtone, + UserRingtone + }; + + public: + MsgSettings(); + virtual ~MsgSettings(); + + void addListener(IMsgSettingsListener &listener); + void removeListener(IMsgSettingsListener &listener); + + int getMessageTextMaxChar() const; + int getMessageMaxPage() const; + int getAttachmentsMaxCount() const; + virtual int getAddressMaxLen() const = 0; + virtual int getPhoneNumberMaxLen() const = 0; + virtual int getAddressMaxCount() const = 0; + virtual int getSubjectMaxLen() const = 0; + virtual int getDisplayNameMaxLen() const = 0; + virtual int getMaxRecipientCount() const = 0; + virtual int getMaxMmsSize() const = 0; + virtual int getMaxMsgTextLen() const = 0; + + virtual void setAlerts(bool value) = 0; + virtual bool getAlerts() const = 0; + + virtual void setRingtoneType(RingtoneType type) = 0; + virtual RingtoneType getRingtoneType() const = 0; + virtual void setRingtone(const std::string &soundPath) = 0; + virtual std::string getRingtone() const = 0; + + virtual void setVibration(bool value) = 0; + virtual bool getVibration() const = 0; + + virtual void setSmsDelivReport(bool value) = 0; + virtual bool getSmsDelivReport() const = 0; + + virtual void setMmsDelivReport(bool value) = 0; + virtual bool getMmsDelivReport() const = 0; + + virtual void setMmsReadReport(bool value) = 0; + virtual bool getMmsReadReport() const = 0; + + virtual void setMmsAutoRetr(bool value) = 0; + virtual bool getMmsAutoRetr() const = 0; + + virtual void setMmsAutoRetrRoaming(bool value) = 0; + virtual bool getMmsAutoRetrRoaming() const = 0; + + virtual void setActiveNotifPolicy(ActiveNotifPolicy type) = 0; + virtual void setActiveNotifPolicy(ThreadId id) = 0; + + void setSendAsAudio(bool value); + bool getSendAsAudio() const; + + protected: + typedef std::vector MsgSettingsListeners; + + protected: + MsgSettingsListeners m_Listeners; + + private: + MsgSettings(MsgSettings&) = delete; + MsgSettings& operator=(MsgSettings&) = delete; + + void onSendAsAudioChanged(const char *key); + void prepareSendAsAudio(); + }; + + class IMsgSettingsListener { + public: + virtual ~IMsgSettingsListener() {} + virtual void onRingtoneChanged(MsgSettings &msgSetting) {}; + virtual void onSendAsAudioChanged(MsgSettings &msgSetting) {}; + }; } diff --git a/src/Common/MsgEngine/inc/MsgStorage.h b/src/Common/MsgEngine/inc/MsgStorage.h index 65ba1cc..f8596f6 100644 --- a/src/Common/MsgEngine/inc/MsgStorage.h +++ b/src/Common/MsgEngine/inc/MsgStorage.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -29,267 +29,267 @@ #include "MsgReport.h" namespace Msg { - class IMsgStorageListener; - class MsgDataContainer; - - /** - * @brief Instance responsible for interaction with message-service internal message-storage. - */ - class MsgStorage { - public: - /** - * @brief Possible results message storage could cause to. - */ - enum StorageResult - { - StorageSuccess = 0, /**< Storage successful.*/ - StorageFail = -1, /**< Storage failure.*/ - StorageSimFull = -2, /**< SIM storage is full.*/ - }; - - public: - MsgStorage(); - virtual ~MsgStorage(); - - /** - * @brief Adds a subscriber to be notified about message-storage events. - * @param[in] listener object listening message-storage events. - */ - void addListener(IMsgStorageListener &listener); - - /** - * @brief Removes a subscriber if it was added before. If no such subscriber was added nothing happens. - * @param[in] listener a subscriber to be removed. - */ - void removeListener(IMsgStorageListener &listener); - - // Thread: - /** - * @brief Gets list of threads existing in message-storage. - * @return list of threads - */ - virtual MsgThreadListRef getThreadList() = 0; - - /** - * @brief Gets thread by a specified id. - * @param[in] id a thread-id - * @return thread with id specified - */ - virtual MsgThreadItemRef getThread(ThreadId id) = 0; - - /** - * @brief Gets thread by a specified address-list. - * @param[in] addressList a list of recipient-addresses unique for each thread - * @return thread with id specified - */ - virtual ThreadId getThreadId(const MsgAddressList &addressList) = 0; - - /** - * @brief Gets thread by a specified address-list. - * @param[in] list of recipient-addresses unique for each thread packed packed in std::list. - * @return thread with id specified - */ - virtual ThreadId getThreadId(const std::list &addressList) = 0; - - /** - * @brief Gets thread by a specified message-id. - * @param[in] id unique message-id this thread contains. - * @return thread with id specified - */ - virtual ThreadId getThreadId(MsgId id) = 0; - - /** - * @brief Deletes thread with specified id. - * @param[in] id id of thread to be removed. - * @return true in case of success, otherwise false. - */ - virtual bool deleteThread(ThreadId id) = 0; - - /** - * @brief Gets address-list of a thread with specified id. - * @param[in] id id of thread that contains address list to be removed. - * @return list of addresses for specified thread. - */ - virtual MsgAddressListRef getAddressList(ThreadId id) = 0; - - /** - * @brief Performs a search by specified keyword. - * @param[in] word a search keyword. - * @return list of threads that contain messages with text matched with a keyword. - */ - virtual MsgThreadListRef searchThread(const std::string &word) = 0; - - /** - * @brief Marks thread with specified id as read. - * @param[in] id id of thread to mark as read. - */ - virtual void setReadStatus(ThreadId id) = 0; - - /** - * @brief Gets number of threads with unread messages. - * @return number of unread threads. - */ - virtual int getUnreadThreadCount() const = 0; - - /** - * @brief Checks whether thread with specified id has email in it's address-list. - * @param[in] id an id of thread. - * @return true if thread has email in it's address-list, otharwise false. - */ - bool hasEmail(ThreadId id); - - // Message: - /** - * @brief Gets a list of messages on SIM. - * @return list messages on SIM. - */ - virtual MessageSMSListRef getSimMsgList() = 0; - - /** - * @brief Gets message by specified message-id. - * @param[in] id id of message to be found. - * @return found message if it's exists or empty MessageRef if search fails. - */ - virtual MessageRef getMessage(MsgId id) = 0; - - /** - * @brief Commits edited message into message-storage in two optional way: - * -# save existing message - * -# create a copy of source message - * @param[in] msg message to be saved. - * @param[in] a updateExisting flag that defines a saving strategy. If true the existing message is saved, otherwise a new message-copy is created. - * @param[out] result of storage operation. - * @return id of saved message. - */ - virtual MsgId saveMessage(Message &msg, bool updateExisting, StorageResult *result = nullptr) = 0; - - /** - * @brief Deletes single message with specified id. - * @param[in] id an id of message to be removed. - * @return true in case of successful deletion, otherwise false. - */ - virtual bool deleteMessage(MsgId id) = 0; - - /** - * @brief Deletes multiple messages with specified ids. - * @param[in] idList list of message-id to be removed. - * @return true in case of successful deletion, otherwise false. Also returns false if idList is empty. - */ - virtual bool deleteMessages(const MsgIdList &idList) = 0; - - /** - * @brief Performs search of a message based on a keyword. - * @param[in] word a search keyword. - * @return list of messages with text matched with a keyword. - */ - virtual MessageListRef searchMessage(const std::string &word) = 0; - - /** - * @brief Marks message with specified id as read. - * @param[in] id id of message to mark as read - * @param[in] new read-status a status of message. Set @c true if the message is read, otherwise set @c false if the message is not read - */ - virtual void setReadStatus(MsgId id, bool status) = 0; - - /** - * @brief Gets list of reports(Delivery/Read) relevand for mwssage with specified id. - * @param[in] msgId message-id. - * @return list of reports. - */ - virtual MsgReportListRef getMsgReportList(MsgId msgId) = 0; - - /** - * @brief Gets whether it requests read report or not - * @param[in] msgId message-id. - * @return true requests, false otherwise. - */ - virtual bool isReadReportChecked(MsgId msgId) = 0; - - /** - * @brief Gets whether it requests delivery report or not - * @param[in] msgId message-id. - * @return true requests, false otherwise. - */ - virtual bool isDeliverReportChecked(MsgId msgId) = 0; - - // Conversation: - /** - * @brief Gets conversation-list that belongs to thread with specified id. - * @param[in] id thread id. - * @return List of messages from thread. - */ - virtual MsgConversationListRef getConversationList(ThreadId id) = 0; - - /** - * @brief Gets an item from conversation-list corresponded to message with specified id. - * @param[in] id message id. - * @return Conversation-list item. - */ - virtual MsgConversationItemRef getConversationItem(MsgId id) = 0; - - protected: - typedef std::vector MsgStorageListeners; - - protected: - MsgStorageListeners m_Listeners; - }; - - - /** - * @brief A listener aimed to notify subscribers about message-storage events. - */ - class IMsgStorageListener { - public: - virtual ~IMsgStorageListener() {}; - - /** - * @brief Message-storage updates for the given messages. - * @param[in] msgIdList list of message identifiers relevant to this notification. - */ - virtual void onMsgStorageUpdate(const MsgIdList &msgIdList) {}; - - /** - * @brief Notification about new messages addition. - * @param[in] msgIdList list of message identifiers relevant to this notification. - */ - virtual void onMsgStorageInsert(const MsgIdList &msgIdList) {}; - - /** - * @brief Notification about new messages deletion. - * @param[in] msgIdList list of message identifiers relevant to this notification. - */ - virtual void onMsgStorageDelete(const MsgIdList &msgIdList) {}; - - /** - * @brief Notifies that recipient stored in contacts was updated. - * @param[in] msgIdList list of message identifiers relevant to this notification. - */ - virtual void onMsgStorageContact(const MsgIdList &msgIdList) {}; - - /** - * @brief Message-storage updates for the given thread. - * @param[in] threadId Id of updated conversation. - */ - virtual void onMsgStorageThreadUpdate(const ThreadId &threadId) {}; - - /** - * @brief Notification about new thread addition. - * @param[in] threadId Id of created conversation. - */ - virtual void onMsgStorageThreadInsert(const ThreadId &threadId) {}; - - /** - * @brief Notification about thread deletion. - * @param[in] threadId Id of deleted conversation. - */ - virtual void onMsgStorageThreadDelete(const ThreadId &threadId) {}; - - /** - * @brief Notifies that recipient stored in contacts was updated. - * @param[in] threadId Id of conversation identifier relevant to this notification. - */ - virtual void onMsgStorageThreadContact(const ThreadId &threadId) {}; - }; + class IMsgStorageListener; + class MsgDataContainer; + + /** + * @brief Instance responsible for interaction with message-service internal message-storage. + */ + class MsgStorage { + public: + /** + * @brief Possible results message storage could cause to. + */ + enum StorageResult + { + StorageSuccess = 0, /**< Storage successful.*/ + StorageFail = -1, /**< Storage failure.*/ + StorageSimFull = -2, /**< SIM storage is full.*/ + }; + + public: + MsgStorage(); + virtual ~MsgStorage(); + + /** + * @brief Adds a subscriber to be notified about message-storage events. + * @param[in] listener object listening message-storage events. + */ + void addListener(IMsgStorageListener &listener); + + /** + * @brief Removes a subscriber if it was added before. If no such subscriber was added nothing happens. + * @param[in] listener a subscriber to be removed. + */ + void removeListener(IMsgStorageListener &listener); + + // Thread: + /** + * @brief Gets list of threads existing in message-storage. + * @return list of threads + */ + virtual MsgThreadListRef getThreadList() = 0; + + /** + * @brief Gets thread by a specified id. + * @param[in] id a thread-id + * @return thread with id specified + */ + virtual MsgThreadItemRef getThread(ThreadId id) = 0; + + /** + * @brief Gets thread by a specified address-list. + * @param[in] addressList a list of recipient-addresses unique for each thread + * @return thread with id specified + */ + virtual ThreadId getThreadId(const MsgAddressList &addressList) = 0; + + /** + * @brief Gets thread by a specified address-list. + * @param[in] list of recipient-addresses unique for each thread packed packed in std::list. + * @return thread with id specified + */ + virtual ThreadId getThreadId(const std::list &addressList) = 0; + + /** + * @brief Gets thread by a specified message-id. + * @param[in] id unique message-id this thread contains. + * @return thread with id specified + */ + virtual ThreadId getThreadId(MsgId id) = 0; + + /** + * @brief Deletes thread with specified id. + * @param[in] id id of thread to be removed. + * @return true in case of success, otherwise false. + */ + virtual bool deleteThread(ThreadId id) = 0; + + /** + * @brief Gets address-list of a thread with specified id. + * @param[in] id id of thread that contains address list to be removed. + * @return list of addresses for specified thread. + */ + virtual MsgAddressListRef getAddressList(ThreadId id) = 0; + + /** + * @brief Performs a search by specified keyword. + * @param[in] word a search keyword. + * @return list of threads that contain messages with text matched with a keyword. + */ + virtual MsgThreadListRef searchThread(const std::string &word) = 0; + + /** + * @brief Marks thread with specified id as read. + * @param[in] id id of thread to mark as read. + */ + virtual void setReadStatus(ThreadId id) = 0; + + /** + * @brief Gets number of threads with unread messages. + * @return number of unread threads. + */ + virtual int getUnreadThreadCount() const = 0; + + /** + * @brief Checks whether thread with specified id has email in it's address-list. + * @param[in] id an id of thread. + * @return true if thread has email in it's address-list, otharwise false. + */ + bool hasEmail(ThreadId id); + + // Message: + /** + * @brief Gets a list of messages on SIM. + * @return list messages on SIM. + */ + virtual MessageSMSListRef getSimMsgList() = 0; + + /** + * @brief Gets message by specified message-id. + * @param[in] id id of message to be found. + * @return found message if it's exists or empty MessageRef if search fails. + */ + virtual MessageRef getMessage(MsgId id) = 0; + + /** + * @brief Commits edited message into message-storage in two optional way: + * -# save existing message + * -# create a copy of source message + * @param[in] msg message to be saved. + * @param[in] a updateExisting flag that defines a saving strategy. If true the existing message is saved, otherwise a new message-copy is created. + * @param[out] result of storage operation. + * @return id of saved message. + */ + virtual MsgId saveMessage(Message &msg, bool updateExisting, StorageResult *result = nullptr) = 0; + + /** + * @brief Deletes single message with specified id. + * @param[in] id an id of message to be removed. + * @return true in case of successful deletion, otherwise false. + */ + virtual bool deleteMessage(MsgId id) = 0; + + /** + * @brief Deletes multiple messages with specified ids. + * @param[in] idList list of message-id to be removed. + * @return true in case of successful deletion, otherwise false. Also returns false if idList is empty. + */ + virtual bool deleteMessages(const MsgIdList &idList) = 0; + + /** + * @brief Performs search of a message based on a keyword. + * @param[in] word a search keyword. + * @return list of messages with text matched with a keyword. + */ + virtual MessageListRef searchMessage(const std::string &word) = 0; + + /** + * @brief Marks message with specified id as read. + * @param[in] id id of message to mark as read + * @param[in] new read-status a status of message. Set @c true if the message is read, otherwise set @c false if the message is not read + */ + virtual void setReadStatus(MsgId id, bool status) = 0; + + /** + * @brief Gets list of reports(Delivery/Read) relevand for mwssage with specified id. + * @param[in] msgId message-id. + * @return list of reports. + */ + virtual MsgReportListRef getMsgReportList(MsgId msgId) = 0; + + /** + * @brief Gets whether it requests read report or not + * @param[in] msgId message-id. + * @return true requests, false otherwise. + */ + virtual bool isReadReportChecked(MsgId msgId) = 0; + + /** + * @brief Gets whether it requests delivery report or not + * @param[in] msgId message-id. + * @return true requests, false otherwise. + */ + virtual bool isDeliverReportChecked(MsgId msgId) = 0; + + // Conversation: + /** + * @brief Gets conversation-list that belongs to thread with specified id. + * @param[in] id thread id. + * @return List of messages from thread. + */ + virtual MsgConversationListRef getConversationList(ThreadId id) = 0; + + /** + * @brief Gets an item from conversation-list corresponded to message with specified id. + * @param[in] id message id. + * @return Conversation-list item. + */ + virtual MsgConversationItemRef getConversationItem(MsgId id) = 0; + + protected: + typedef std::vector MsgStorageListeners; + + protected: + MsgStorageListeners m_Listeners; + }; + + + /** + * @brief A listener aimed to notify subscribers about message-storage events. + */ + class IMsgStorageListener { + public: + virtual ~IMsgStorageListener() {}; + + /** + * @brief Message-storage updates for the given messages. + * @param[in] msgIdList list of message identifiers relevant to this notification. + */ + virtual void onMsgStorageUpdate(const MsgIdList &msgIdList) {}; + + /** + * @brief Notification about new messages addition. + * @param[in] msgIdList list of message identifiers relevant to this notification. + */ + virtual void onMsgStorageInsert(const MsgIdList &msgIdList) {}; + + /** + * @brief Notification about new messages deletion. + * @param[in] msgIdList list of message identifiers relevant to this notification. + */ + virtual void onMsgStorageDelete(const MsgIdList &msgIdList) {}; + + /** + * @brief Notifies that recipient stored in contacts was updated. + * @param[in] msgIdList list of message identifiers relevant to this notification. + */ + virtual void onMsgStorageContact(const MsgIdList &msgIdList) {}; + + /** + * @brief Message-storage updates for the given thread. + * @param[in] threadId Id of updated conversation. + */ + virtual void onMsgStorageThreadUpdate(const ThreadId &threadId) {}; + + /** + * @brief Notification about new thread addition. + * @param[in] threadId Id of created conversation. + */ + virtual void onMsgStorageThreadInsert(const ThreadId &threadId) {}; + + /** + * @brief Notification about thread deletion. + * @param[in] threadId Id of deleted conversation. + */ + virtual void onMsgStorageThreadDelete(const ThreadId &threadId) {}; + + /** + * @brief Notifies that recipient stored in contacts was updated. + * @param[in] threadId Id of conversation identifier relevant to this notification. + */ + virtual void onMsgStorageThreadContact(const ThreadId &threadId) {}; + }; } #endif /* __MSG_STORAGE_H__ */ diff --git a/src/Common/MsgEngine/inc/MsgThreadItem.h b/src/Common/MsgEngine/inc/MsgThreadItem.h index e624007..91b8ae2 100644 --- a/src/Common/MsgEngine/inc/MsgThreadItem.h +++ b/src/Common/MsgEngine/inc/MsgThreadItem.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -24,65 +24,65 @@ #include namespace Msg { - class MsgThreadItem; - typedef std::shared_ptr MsgThreadItemRef; - typedef std::shared_ptr> MsgThreadListRef; + class MsgThreadItem; + typedef std::shared_ptr MsgThreadItemRef; + typedef std::shared_ptr> MsgThreadListRef; - /** - * @brief An interface that should be implemented by data-structure responsible for accessing basic thread information. - */ - class MsgThreadItem { - public: - virtual ~MsgThreadItem(); + /** + * @brief An interface that should be implemented by data-structure responsible for accessing basic thread information. + */ + class MsgThreadItem { + public: + virtual ~MsgThreadItem(); - /** - * @brief Gets thread-id. - * @return thread-id. - */ - virtual ThreadId getId() const = 0; + /** + * @brief Gets thread-id. + * @return thread-id. + */ + virtual ThreadId getId() const = 0; - /** - * @brief Gets thread-name. - * @return thread-name. - */ - virtual std::string getName() const = 0; + /** + * @brief Gets thread-name. + * @return thread-name. + */ + virtual std::string getName() const = 0; - /** - * @brief Gets text of the latest message in the thread. - * @return text of last message. - */ - virtual std::string getLastMessage() const = 0; + /** + * @brief Gets text of the latest message in the thread. + * @return text of last message. + */ + virtual std::string getLastMessage() const = 0; - /** - * @brief Gets time when last message was updated\sent\received. - * @return thread's last message update/send/received time. - */ - virtual time_t getTime() const = 0; + /** + * @brief Gets time when last message was updated\sent\received. + * @return thread's last message update/send/received time. + */ + virtual time_t getTime() const = 0; - /** - * @brief Checks whether thread has draft message or not. - * @return true if there's draft message, otherwise false. - */ - virtual bool hasDraftMessage() const = 0; + /** + * @brief Checks whether thread has draft message or not. + * @return true if there's draft message, otherwise false. + */ + virtual bool hasDraftMessage() const = 0; - /** - * @brief Checks whether thread has failed message or not. - * @return true if there's failed message, otherwise false. - */ - virtual bool hasFailedMessage() const = 0; + /** + * @brief Checks whether thread has failed message or not. + * @return true if there's failed message, otherwise false. + */ + virtual bool hasFailedMessage() const = 0; - /** - * @brief Checks whether thread has message in progress of sending or not. - * @return false if no message from thread is sending now, otherwise true. - */ - virtual bool isSending() const = 0; + /** + * @brief Checks whether thread has message in progress of sending or not. + * @return false if no message from thread is sending now, otherwise true. + */ + virtual bool isSending() const = 0; - /** - * @brief Gets number of unread messages in thread. - * @return number of unread messages. - */ - virtual int getUnreadCount() const = 0; - }; + /** + * @brief Gets number of unread messages in thread. + * @return number of unread messages. + */ + virtual int getUnreadCount() const = 0; + }; } #endif /* __IMSG_THREAD_ITEM_H__ */ diff --git a/src/Common/MsgEngine/inc/MsgTransport.h b/src/Common/MsgEngine/inc/MsgTransport.h index 0c5ecaf..95aabb6 100644 --- a/src/Common/MsgEngine/inc/MsgTransport.h +++ b/src/Common/MsgEngine/inc/MsgTransport.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -25,103 +25,103 @@ namespace Msg { - class IMsgTransportListener; - - /** - * @brief Manages sending(receiving) messages activity. - */ - class MsgTransport { - public: - /** - * @brief Possible results message sending could cause to. - */ - enum SendResult { - SendSuccess = 0, /**< Sending successful.*/ - SendFail = -1, /**< Sending failure.*/ - SendNoSIM = -2, /**< No SIM was found.*/ - SendDPMRestricted = -3, /**< Sending message is restricted by DPM.*/ - SendReadReportNotReq = -4, /**< Read report not requested.*/ - SendReadReportAlreadySent = -5, /**< Read report already dent.*/ - }; - - public: - MsgTransport(); - virtual ~MsgTransport(); - - /** - * @brief Adds a subscriber to be notified about message-transport events. - * @param[in] listener object listening message-storage events. - */ - void addListener(IMsgTransportListener &listener); - - /** - * @brief Removes a subscriber if it was added before. If no such subscriber was added nothing happens. - * @param[in] listener a subscriber to be removed. - */ - void removeListener(IMsgTransportListener &listener); - - /** - * @brief Message-service specific implementation of sending message of any type(sms or mms). - * @param[in, out] msg a message to be sent. - * @param[out] threadId an id of thread the sent message belongs to. - * @param[out] requestId id of sent request - * @return result-code. - */ - virtual SendResult sendMessage(Message &msg, ThreadId *threadId = nullptr, RequestId *requestId = nullptr) = 0; - - /** - * @brief General(for calling by client) implementation of sending message of any type(sms or mms). - * @param[in, out] msg a message to be sent. - * @param[out] threadId an id of thread the sent message belongs to. - * @param[out] requestId id of sent request - * @return result-code. - */ - SendResult sendMessage(MessageRef &msg, ThreadId *threadId = nullptr, RequestId *requestId = nullptr); - - /** - * @brief Sending MMS. - * @param[in, out] msg a message to be sent. - * @param[out] threadId an id of thread the sent message belongs to. - * @param[out] requestId id of sent request - * @return result-code. - */ - SendResult sendMessage(MessageMmsRef &msg, ThreadId *threadId = nullptr, RequestId *requestId = nullptr); - - /** - * @brief Sending SMS. - * @param[in, out] msg a message to be sent. - * @param[out] threadId an id of thread the sent message belongs to. - * @param[out] requestId id of sent request - * @return result-code. - */ - SendResult sendMessage(MessageSMSRef &msg, ThreadId *threadId = nullptr, RequestId *requestId = nullptr); - - /** - * @brief Manually downloads MMS by demand. - * @param[in] msgId id of message to be downloaded. - * @param[out] requestId id of retrieve request - */ - virtual SendResult retrieveMessage(MsgId msgId, RequestId *requestId = nullptr) = 0; - - /** - * @brief Send read report (for MMS only) - * @param[in] msgId id of message (MMS) - */ - virtual SendResult sendReadReport(MsgId msgId, MsgReport::ReadStatus status) = 0; - - protected: - typedef std::vector Listeners; - void notifyListenersOnSentStatus(const MsgSentStatus &status); - - private: - Listeners m_Listeners; - }; - - class IMsgTransportListener { - public: - virtual ~IMsgTransportListener() {} - virtual void onMsgTransportSentStatus(const MsgSentStatus &status) {}; - }; + class IMsgTransportListener; + + /** + * @brief Manages sending(receiving) messages activity. + */ + class MsgTransport { + public: + /** + * @brief Possible results message sending could cause to. + */ + enum SendResult { + SendSuccess = 0, /**< Sending successful.*/ + SendFail = -1, /**< Sending failure.*/ + SendNoSIM = -2, /**< No SIM was found.*/ + SendDPMRestricted = -3, /**< Sending message is restricted by DPM.*/ + SendReadReportNotReq = -4, /**< Read report not requested.*/ + SendReadReportAlreadySent = -5, /**< Read report already dent.*/ + }; + + public: + MsgTransport(); + virtual ~MsgTransport(); + + /** + * @brief Adds a subscriber to be notified about message-transport events. + * @param[in] listener object listening message-storage events. + */ + void addListener(IMsgTransportListener &listener); + + /** + * @brief Removes a subscriber if it was added before. If no such subscriber was added nothing happens. + * @param[in] listener a subscriber to be removed. + */ + void removeListener(IMsgTransportListener &listener); + + /** + * @brief Message-service specific implementation of sending message of any type(sms or mms). + * @param[in, out] msg a message to be sent. + * @param[out] threadId an id of thread the sent message belongs to. + * @param[out] requestId id of sent request + * @return result-code. + */ + virtual SendResult sendMessage(Message &msg, ThreadId *threadId = nullptr, RequestId *requestId = nullptr) = 0; + + /** + * @brief General(for calling by client) implementation of sending message of any type(sms or mms). + * @param[in, out] msg a message to be sent. + * @param[out] threadId an id of thread the sent message belongs to. + * @param[out] requestId id of sent request + * @return result-code. + */ + SendResult sendMessage(MessageRef &msg, ThreadId *threadId = nullptr, RequestId *requestId = nullptr); + + /** + * @brief Sending MMS. + * @param[in, out] msg a message to be sent. + * @param[out] threadId an id of thread the sent message belongs to. + * @param[out] requestId id of sent request + * @return result-code. + */ + SendResult sendMessage(MessageMmsRef &msg, ThreadId *threadId = nullptr, RequestId *requestId = nullptr); + + /** + * @brief Sending SMS. + * @param[in, out] msg a message to be sent. + * @param[out] threadId an id of thread the sent message belongs to. + * @param[out] requestId id of sent request + * @return result-code. + */ + SendResult sendMessage(MessageSMSRef &msg, ThreadId *threadId = nullptr, RequestId *requestId = nullptr); + + /** + * @brief Manually downloads MMS by demand. + * @param[in] msgId id of message to be downloaded. + * @param[out] requestId id of retrieve request + */ + virtual SendResult retrieveMessage(MsgId msgId, RequestId *requestId = nullptr) = 0; + + /** + * @brief Send read report (for MMS only) + * @param[in] msgId id of message (MMS) + */ + virtual SendResult sendReadReport(MsgId msgId, MsgReport::ReadStatus status) = 0; + + protected: + typedef std::vector Listeners; + void notifyListenersOnSentStatus(const MsgSentStatus &status); + + private: + Listeners m_Listeners; + }; + + class IMsgTransportListener { + public: + virtual ~IMsgTransportListener() {} + virtual void onMsgTransportSentStatus(const MsgSentStatus &status) {}; + }; } #endif /* _BASE_MSG_TRANSPORT_H__ */ diff --git a/src/Common/MsgEngine/inc/MsgTypes.h b/src/Common/MsgEngine/inc/MsgTypes.h index f9073cd..e43aa66 100644 --- a/src/Common/MsgEngine/inc/MsgTypes.h +++ b/src/Common/MsgEngine/inc/MsgTypes.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -20,94 +20,94 @@ #include namespace Msg { - class BaseMsgId { - public: - typedef unsigned Type; - static const Type invalidId = 0; - - BaseMsgId() - : value(invalidId) - { - } - - BaseMsgId(Type id) - : value(id) - { - } - - BaseMsgId(const BaseMsgId &obj) - : value(obj.value) - { - } - - operator Type() const - { - return value; - } - - BaseMsgId &operator=(Type id) - { - value = id; - return *this; - } - - bool isValid() const - { - return value > 0; - } - - void reset() - { - value = 0; - } - - Type value; // implementation - }; - - class ThreadId - : public BaseMsgId { - using BaseMsgId::BaseMsgId; - }; - - class MsgId - : public BaseMsgId { - using BaseMsgId::BaseMsgId; - }; - - class RequestId - : public BaseMsgId { - using BaseMsgId::BaseMsgId; - }; - - typedef std::vector MsgIdList; - - struct MsgTextMetric { - MsgTextMetric(); - void reset(); - unsigned maxSmsLen; - unsigned maxLen; // In chars for SMS, in bytes for MMS. - unsigned textLen; - unsigned bytes; - bool isMms; - }; - - inline MsgTextMetric::MsgTextMetric() - : maxSmsLen(0) - , maxLen(0) - , textLen(0) - , bytes(0) - , isMms(false) - { - } - - inline void MsgTextMetric::reset() - { - maxSmsLen = 0; - maxLen = 0; - textLen = 0; - bytes = 0; - isMms = false; - } + class BaseMsgId { + public: + typedef unsigned Type; + static const Type invalidId = 0; + + BaseMsgId() + : value(invalidId) + { + } + + BaseMsgId(Type id) + : value(id) + { + } + + BaseMsgId(const BaseMsgId &obj) + : value(obj.value) + { + } + + operator Type() const + { + return value; + } + + BaseMsgId &operator=(Type id) + { + value = id; + return *this; + } + + bool isValid() const + { + return value > 0; + } + + void reset() + { + value = 0; + } + + Type value; // implementation + }; + + class ThreadId + : public BaseMsgId { + using BaseMsgId::BaseMsgId; + }; + + class MsgId + : public BaseMsgId { + using BaseMsgId::BaseMsgId; + }; + + class RequestId + : public BaseMsgId { + using BaseMsgId::BaseMsgId; + }; + + typedef std::vector MsgIdList; + + struct MsgTextMetric { + MsgTextMetric(); + void reset(); + unsigned maxSmsLen; + unsigned maxLen; // In chars for SMS, in bytes for MMS. + unsigned textLen; + unsigned bytes; + bool isMms; + }; + + inline MsgTextMetric::MsgTextMetric() + : maxSmsLen(0) + , maxLen(0) + , textLen(0) + , bytes(0) + , isMms(false) + { + } + + inline void MsgTextMetric::reset() + { + maxSmsLen = 0; + maxLen = 0; + textLen = 0; + bytes = 0; + isMms = false; + } } #endif /* MSGTYPES_H_ */ diff --git a/src/Common/MsgEngine/inc/MsgUtils.h b/src/Common/MsgEngine/inc/MsgUtils.h index fed4669..c2edd4a 100644 --- a/src/Common/MsgEngine/inc/MsgUtils.h +++ b/src/Common/MsgEngine/inc/MsgUtils.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -26,33 +26,33 @@ #include namespace Msg { - namespace MsgUtils { - - struct TokenizedRecipients { - std::list> validResults; - std::string invalidResult; - }; - - TokenizedRecipients tokenizeRecipients(const std::string &inputText); - bool isValidNumber(const std::string &address); - bool isValidEmail(const std::string &address); - bool isValidAddress(const std::string &address); - MsgAddress::AddressType getAddressType(const std::string &address); - std::string makeNormalizedNumber(const std::string &number); - std::string makeCleanedNumber(const std::string &number); - bool isMms(Message::Type type); - bool isSms(Message::Type type); - std::string makeKbStr(long long bytes); - - /** - * @brief Split UTF-8 string on sub-string <= maxSizeInBytes - * param[in] str Input string - * param[in] maxSize Maximum size in bytes. (Warning! limitation, maxSize must be >= 4) - * return list of splitted string. - */ - std::list splitUtf8String(const std::string &str, unsigned maxSize); - - }; + namespace MsgUtils { + + struct TokenizedRecipients { + std::list> validResults; + std::string invalidResult; + }; + + TokenizedRecipients tokenizeRecipients(const std::string &inputText); + bool isValidNumber(const std::string &address); + bool isValidEmail(const std::string &address); + bool isValidAddress(const std::string &address); + MsgAddress::AddressType getAddressType(const std::string &address); + std::string makeNormalizedNumber(const std::string &number); + std::string makeCleanedNumber(const std::string &number); + bool isMms(Message::Type type); + bool isSms(Message::Type type); + std::string makeKbStr(long long bytes); + + /** + * @brief Split UTF-8 string on sub-string <= maxSizeInBytes + * param[in] str Input string + * param[in] maxSize Maximum size in bytes. (Warning! limitation, maxSize must be >= 4) + * return list of splitted string. + */ + std::list splitUtf8String(const std::string &str, unsigned maxSize); + + }; } #endif /* MsgUtils_H_ */ diff --git a/src/Common/MsgEngine/src/Message.cpp b/src/Common/MsgEngine/src/Message.cpp index e082e6f..d657fd7 100644 --- a/src/Common/MsgEngine/src/Message.cpp +++ b/src/Common/MsgEngine/src/Message.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/Common/MsgEngine/src/MessageMms.cpp b/src/Common/MsgEngine/src/MessageMms.cpp index 4d8c6e5..319cfb4 100644 --- a/src/Common/MsgEngine/src/MessageMms.cpp +++ b/src/Common/MsgEngine/src/MessageMms.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/Common/MsgEngine/src/MessageSMS.cpp b/src/Common/MsgEngine/src/MessageSMS.cpp index 8f43a0c..1f19402 100644 --- a/src/Common/MsgEngine/src/MessageSMS.cpp +++ b/src/Common/MsgEngine/src/MessageSMS.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/Common/MsgEngine/src/MsgConversationItem.cpp b/src/Common/MsgEngine/src/MsgConversationItem.cpp index 240b27b..88b7743 100644 --- a/src/Common/MsgEngine/src/MsgConversationItem.cpp +++ b/src/Common/MsgEngine/src/MsgConversationItem.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/Common/MsgEngine/src/MsgEngine.cpp b/src/Common/MsgEngine/src/MsgEngine.cpp index 0e45d49..834b591 100644 --- a/src/Common/MsgEngine/src/MsgEngine.cpp +++ b/src/Common/MsgEngine/src/MsgEngine.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -40,394 +40,394 @@ const std::string notImplPublicStr = "Msg. public API is not implemented"; MsgEngine::MsgEngine() #if defined(MSG_PRIVATE_API) || defined(MSG_PUBLIC_API) - : m_MsgHandle(nullptr) + : m_MsgHandle(nullptr) #endif { } MsgEngine::~MsgEngine() { - closeService(); + closeService(); } int MsgEngine::openService() { - TRACE; - int result = 0; + TRACE; + int result = 0; #ifdef MSG_PRIVATE_API - if (m_MsgHandle) - { - MSG_LOG_ERROR("Handle already has been opened"); - return 0; - } + if (m_MsgHandle) + { + MSG_LOG_ERROR("Handle already has been opened"); + return 0; + } - result = msg_open_msg_handle(&m_MsgHandle); - MSG_LOG("handle open error = ", result); + result = msg_open_msg_handle(&m_MsgHandle); + MSG_LOG("handle open error = ", result); - m_Storage.reset(new MsgStoragePrivate(m_MsgHandle)); - m_Transport.reset(new MsgTransportPrivate(m_MsgHandle)); - m_Composer.reset(new MsgComposerPrivate(*this)); + m_Storage.reset(new MsgStoragePrivate(m_MsgHandle)); + m_Transport.reset(new MsgTransportPrivate(m_MsgHandle)); + m_Composer.reset(new MsgComposerPrivate(*this)); #elif MSG_PUBLIC_API - // TODO: impl for public API + // TODO: impl for public API - if (m_MsgHandle) - { - MSG_LOG_ERROR("Handle already has been opened"); - return 0; - } + if (m_MsgHandle) + { + MSG_LOG_ERROR("Handle already has been opened"); + return 0; + } - result = messages_open_service(&m_MsgHandle); + result = messages_open_service(&m_MsgHandle); - /* if (result == MESSAGES_ERROR_NONE) - { - m_Storage.reset(new MsgStorage(m_ServiceHandle)); - }*/ + /* if (result == MESSAGES_ERROR_NONE) + { + m_Storage.reset(new MsgStorage(m_ServiceHandle)); + }*/ #else - m_Storage.reset(new MsgStorageDummy); - m_Transport.reset(new MsgTransportDummy); - m_Composer.reset(new MsgComposerDummy); - m_Settings.reset(new MsgSettingsDummy); + m_Storage.reset(new MsgStorageDummy); + m_Transport.reset(new MsgTransportDummy); + m_Composer.reset(new MsgComposerDummy); + m_Settings.reset(new MsgSettingsDummy); #endif - return result; + return result; } int MsgEngine::closeService() { - int result = 0; + int result = 0; #ifdef MSG_PRIVATE_API - if (m_MsgHandle) - { - result = msg_close_msg_handle(&m_MsgHandle); - } + if (m_MsgHandle) + { + result = msg_close_msg_handle(&m_MsgHandle); + } #elif MSG_PUBLIC_API - if (m_MsgHandle) - { - result = messages_close_service(m_MsgHandle); - m_MsgHandle = nullptr; - } + if (m_MsgHandle) + { + result = messages_close_service(m_MsgHandle); + m_MsgHandle = nullptr; + } #endif - return result; + return result; } bool MsgEngine::isReady(std::string &errorMsg) const { #ifdef MSG_PRIVATE_API - if (!m_MsgHandle) - { - errorMsg = handleIsNullStr; - return false; - } + if (!m_MsgHandle) + { + errorMsg = handleIsNullStr; + return false; + } #elif MSG_PUBLIC_API - errorMsg = notImplPublicStr; - return false; + errorMsg = notImplPublicStr; + return false; #endif - return true; + return true; } MsgStorage &MsgEngine::getStorage() { - assert(m_Storage.get()); - return *m_Storage; + assert(m_Storage.get()); + return *m_Storage; } const MsgStorage &MsgEngine::getStorage() const { - assert(m_Storage.get()); - return *m_Storage; + assert(m_Storage.get()); + return *m_Storage; } MsgTransport &MsgEngine::getTransport() { - assert(m_Transport.get()); - return *m_Transport; + assert(m_Transport.get()); + return *m_Transport; } const MsgTransport &MsgEngine::getTransport() const { - assert(m_Transport.get()); - return *m_Transport; + assert(m_Transport.get()); + return *m_Transport; } MsgSettings &MsgEngine::getSettings() { #ifdef MSG_PRIVATE_API - if (!m_Settings.get()) - m_Settings.reset(new MsgSettingsPrivate(m_MsgHandle)); + if (!m_Settings.get()) + m_Settings.reset(new MsgSettingsPrivate(m_MsgHandle)); #endif - return *m_Settings; + return *m_Settings; } const MsgSettings &MsgEngine::getSettings() const { - return const_cast(this)->getSettings(); + return const_cast(this)->getSettings(); } MsgComposer &MsgEngine::getComposer() { - assert(m_Composer.get()); - return *m_Composer; + assert(m_Composer.get()); + return *m_Composer; } const MsgComposer &MsgEngine::getComposer() const { - assert(m_Composer.get()); - return *m_Composer; + assert(m_Composer.get()); + return *m_Composer; } std::string MsgEngine::whatError(int error) { #ifdef MSG_PRIVATE_API - switch (error) - { - case MSG_SUCCESS: - return "MSG_SUCCESS"; - break; - case MSG_ERR_NULL_MSGHANDLE: - return "MSG_ERR_NULL_MSGHANDLE"; - break; - case MSG_ERR_NULL_POINTER: - return "MSG_ERR_NULL_POINTER"; - break; - case MSG_ERR_NULL_MESSAGE: - return "MSG_ERR_NULL_MESSAGE"; - break; - case MSG_ERR_INVALID_STORAGE_ID: - return "MSG_ERR_INVALID_STORAGE_ID"; - break; - case MSG_ERR_INVALID_MSG_TYPE: - return "MSG_ERR_INVALID_MSG_TYPE"; - break; - case MSG_ERR_INVALID_STORAGE_REG: - return "MSG_ERR_INVALID_STORAGE_REG"; - break; - case MSG_ERR_INVALID_MESSAGE_ID: - return "MSG_ERR_INVALID_MESSAGE_ID"; - break; - case MSG_ERR_INVALID_MSGHANDLE: - return "MSG_ERR_INVALID_MSGHANDLE"; - break; - case MSG_ERR_INVALID_PARAMETER: - return "MSG_ERR_INVALID_PARAMETER"; - break; - case MSG_ERR_INVALID_MESSAGE: - return "MSG_ERR_INVALID_MESSAGE"; - break; - case MSG_ERR_INVALID_PLUGIN_HANDLE: - return "MSG_ERR_INVALID_PLUGIN_HANDLE"; - break; - case MSG_ERR_MEMORY_ERROR: - return "MSG_ERR_MEMORY_ERROR"; - break; - case MSG_ERR_COMMUNICATION_ERROR: - return "MSG_ERR_COMMUNICATION_ERROR"; - break; - case MSG_ERR_SIM_STORAGE_FULL: - return "MSG_ERR_SIM_STORAGE_FULL"; - break; - case MSG_ERR_TRANSPORT_ERROR: - return "MSG_ERR_TRANSPORT_ERROR"; - break; - case MSG_ERR_CALLBACK_ERROR: - return "MSG_ERR_CALLBACK_ERROR"; - break; - case MSG_ERR_STORAGE_ERROR: - return "MSG_ERR_STORAGE_ERROR"; - break; - case MSG_ERR_FILTER_ERROR: - return "MSG_ERR_FILTER_ERROR"; - break; - case MSG_ERR_MMS_ERROR: - return "MSG_ERR_MMS_ERROR"; - break; - case MSG_ERR_MMPLAYER_CREATE: - return "MSG_ERR_MMPLAYER_CREATE"; - break; - case MSG_ERR_MMPLAYER_SET_ATTRS: - return "MSG_ERR_MMPLAYER_SET_ATTRS"; - break; - case MSG_ERR_MMPLAYER_REALIZE: - return "MSG_ERR_MMPLAYER_REALIZE"; - break; - case MSG_ERR_MMPLAYER_PLAY: - return "MSG_ERR_MMPLAYER_PLAY"; - break; - case MSG_ERR_MMPLAYER_STOP: - return "MSG_ERR_MMPLAYER_STOP"; - break; - case MSG_ERR_MMPLAYER_DESTROY: - return "MSG_ERR_MMPLAYER_DESTROY"; - break; - case MSG_ERR_UNKNOWN: - return "MSG_ERR_UNKNOWN"; - break; - case MSG_ERR_DB_CONNECT: - return "MSG_ERR_DB_CONNECT"; - break; - case MSG_ERR_DB_DISCONNECT: - return "MSG_ERR_DB_DISCONNECT"; - break; - case MSG_ERR_DB_EXEC: - return "MSG_ERR_DB_EXEC"; - break; - case MSG_ERR_DB_GETTABLE: - return "MSG_ERR_DB_GETTABLE"; - break; - case MSG_ERR_DB_PREPARE: - return "MSG_ERR_DB_PREPARE"; - break; - case MSG_ERR_DB_STEP: - return "MSG_ERR_DB_STEP"; - break; - case MSG_ERR_DB_NORECORD: - return "MSG_ERR_DB_NORECORD"; - break; - case MSG_ERR_DB_STORAGE_INIT: - return "MSG_ERR_DB_STORAGE_INIT"; - break; - case MSG_ERR_DB_MAKE_DIR: - return "MSG_ERR_DB_MAKE_DIR"; - break; - case MSG_ERR_DB_ROW: - return "MSG_ERR_DB_ROW"; - break; - case MSG_ERR_DB_DONE: - return "MSG_ERR_DB_DONE"; - break; - case MSG_ERR_DB_GENERIC: - return "MSG_ERR_DB_GENERIC"; - break; - case MSG_ERR_DB_END: - return "MSG_ERR_DB_END"; - break; - case MSG_ERR_SET_SETTING: - return "MSG_ERR_SET_SETTING"; - break; - case MSG_ERR_SET_SIM_SET: - return "MSG_ERR_SET_SIM_SET"; - break; - case MSG_ERR_SET_READ_ERROR: - return "MSG_ERR_SET_READ_ERROR"; - break; - case MSG_ERR_SET_WRITE_ERROR: - return "MSG_ERR_SET_WRITE_ERROR"; - break; - case MSG_ERR_SET_DELETE_ERROR: - return "MSG_ERR_SET_DELETE_ERROR"; - break; - case MSG_ERR_PLUGIN_TAPIINIT: - return "MSG_ERR_PLUGIN_TAPIINIT"; - break; - case MSG_ERR_PLUGIN_REGEVENT: - return "MSG_ERR_PLUGIN_REGEVENT"; - break; - case MSG_ERR_PLUGIN_TRANSPORT: - return "MSG_ERR_PLUGIN_TRANSPORT"; - break; - case MSG_ERR_PLUGIN_STORAGE: - return "MSG_ERR_PLUGIN_STORAGE"; - break; - case MSG_ERR_PLUGIN_SETTING: - return "MSG_ERR_PLUGIN_SETTING"; - break; - case MSG_ERR_PLUGIN_WAPDECODE: - return "MSG_ERR_PLUGIN_WAPDECODE"; - break; - case MSG_ERR_PLUGIN_TAPI_FAILED: - return "MSG_ERR_PLUGIN_TAPI_FAILED"; - break; - case MSG_ERR_PLUGIN_SIM_MSG_FULL: - return "MSG_ERR_PLUGIN_SIM_MSG_FULL"; - break; - case MSG_ERR_MESSAGE_COUNT_FULL: - return "MSG_ERR_MESSAGE_COUNT_FULL"; - break; - case MSG_ERR_READREPORT_NOT_REQUESTED: - return "MSG_ERR_READREPORT_NOT_REQUESTED"; - break; - case MSG_ERR_READREPORT_ALEADY_SENT: - return "MSG_ERR_READREPORT_ALEADY_SENT"; - break; - case MSG_ERR_FILTER_DUPLICATED: - return "MSG_ERR_FILTER_DUPLICATED"; - break; - case MSG_ERR_PERMISSION_DENIED: - return "MSG_ERR_PERMISSION_DENIED"; - break; - case MSG_ERR_NO_SIM: - return "MSG_ERR_NO_SIM"; - break; - case MSG_ERR_SERVER_NOT_READY: - return "MSG_ERR_SERVER_NOT_READY"; - break; - case MSG_ERR_STORE_RESTRICT: - return "MSG_ERR_STORE_RESTRICT"; - break; - case MSG_ERR_DB_BUSY: - return "MSG_ERR_DB_BUSY"; - break; - case MSG_ERR_NOT_SUPPORTED: - return "MSG_ERR_NOT_SUPPORTED"; - break; - case MSG_ERR_NOT_ALLOWED_ZONE: - return "MSG_ERR_NOT_ALLOWED_ZONE"; - break; - case MSG_ERR_DPM_RESTRICT: - return "MSG_ERR_DPM_RESTRICT"; - break; - default: - return "SOME ANOTHER ERROR"; - break; - } + switch (error) + { + case MSG_SUCCESS: + return "MSG_SUCCESS"; + break; + case MSG_ERR_NULL_MSGHANDLE: + return "MSG_ERR_NULL_MSGHANDLE"; + break; + case MSG_ERR_NULL_POINTER: + return "MSG_ERR_NULL_POINTER"; + break; + case MSG_ERR_NULL_MESSAGE: + return "MSG_ERR_NULL_MESSAGE"; + break; + case MSG_ERR_INVALID_STORAGE_ID: + return "MSG_ERR_INVALID_STORAGE_ID"; + break; + case MSG_ERR_INVALID_MSG_TYPE: + return "MSG_ERR_INVALID_MSG_TYPE"; + break; + case MSG_ERR_INVALID_STORAGE_REG: + return "MSG_ERR_INVALID_STORAGE_REG"; + break; + case MSG_ERR_INVALID_MESSAGE_ID: + return "MSG_ERR_INVALID_MESSAGE_ID"; + break; + case MSG_ERR_INVALID_MSGHANDLE: + return "MSG_ERR_INVALID_MSGHANDLE"; + break; + case MSG_ERR_INVALID_PARAMETER: + return "MSG_ERR_INVALID_PARAMETER"; + break; + case MSG_ERR_INVALID_MESSAGE: + return "MSG_ERR_INVALID_MESSAGE"; + break; + case MSG_ERR_INVALID_PLUGIN_HANDLE: + return "MSG_ERR_INVALID_PLUGIN_HANDLE"; + break; + case MSG_ERR_MEMORY_ERROR: + return "MSG_ERR_MEMORY_ERROR"; + break; + case MSG_ERR_COMMUNICATION_ERROR: + return "MSG_ERR_COMMUNICATION_ERROR"; + break; + case MSG_ERR_SIM_STORAGE_FULL: + return "MSG_ERR_SIM_STORAGE_FULL"; + break; + case MSG_ERR_TRANSPORT_ERROR: + return "MSG_ERR_TRANSPORT_ERROR"; + break; + case MSG_ERR_CALLBACK_ERROR: + return "MSG_ERR_CALLBACK_ERROR"; + break; + case MSG_ERR_STORAGE_ERROR: + return "MSG_ERR_STORAGE_ERROR"; + break; + case MSG_ERR_FILTER_ERROR: + return "MSG_ERR_FILTER_ERROR"; + break; + case MSG_ERR_MMS_ERROR: + return "MSG_ERR_MMS_ERROR"; + break; + case MSG_ERR_MMPLAYER_CREATE: + return "MSG_ERR_MMPLAYER_CREATE"; + break; + case MSG_ERR_MMPLAYER_SET_ATTRS: + return "MSG_ERR_MMPLAYER_SET_ATTRS"; + break; + case MSG_ERR_MMPLAYER_REALIZE: + return "MSG_ERR_MMPLAYER_REALIZE"; + break; + case MSG_ERR_MMPLAYER_PLAY: + return "MSG_ERR_MMPLAYER_PLAY"; + break; + case MSG_ERR_MMPLAYER_STOP: + return "MSG_ERR_MMPLAYER_STOP"; + break; + case MSG_ERR_MMPLAYER_DESTROY: + return "MSG_ERR_MMPLAYER_DESTROY"; + break; + case MSG_ERR_UNKNOWN: + return "MSG_ERR_UNKNOWN"; + break; + case MSG_ERR_DB_CONNECT: + return "MSG_ERR_DB_CONNECT"; + break; + case MSG_ERR_DB_DISCONNECT: + return "MSG_ERR_DB_DISCONNECT"; + break; + case MSG_ERR_DB_EXEC: + return "MSG_ERR_DB_EXEC"; + break; + case MSG_ERR_DB_GETTABLE: + return "MSG_ERR_DB_GETTABLE"; + break; + case MSG_ERR_DB_PREPARE: + return "MSG_ERR_DB_PREPARE"; + break; + case MSG_ERR_DB_STEP: + return "MSG_ERR_DB_STEP"; + break; + case MSG_ERR_DB_NORECORD: + return "MSG_ERR_DB_NORECORD"; + break; + case MSG_ERR_DB_STORAGE_INIT: + return "MSG_ERR_DB_STORAGE_INIT"; + break; + case MSG_ERR_DB_MAKE_DIR: + return "MSG_ERR_DB_MAKE_DIR"; + break; + case MSG_ERR_DB_ROW: + return "MSG_ERR_DB_ROW"; + break; + case MSG_ERR_DB_DONE: + return "MSG_ERR_DB_DONE"; + break; + case MSG_ERR_DB_GENERIC: + return "MSG_ERR_DB_GENERIC"; + break; + case MSG_ERR_DB_END: + return "MSG_ERR_DB_END"; + break; + case MSG_ERR_SET_SETTING: + return "MSG_ERR_SET_SETTING"; + break; + case MSG_ERR_SET_SIM_SET: + return "MSG_ERR_SET_SIM_SET"; + break; + case MSG_ERR_SET_READ_ERROR: + return "MSG_ERR_SET_READ_ERROR"; + break; + case MSG_ERR_SET_WRITE_ERROR: + return "MSG_ERR_SET_WRITE_ERROR"; + break; + case MSG_ERR_SET_DELETE_ERROR: + return "MSG_ERR_SET_DELETE_ERROR"; + break; + case MSG_ERR_PLUGIN_TAPIINIT: + return "MSG_ERR_PLUGIN_TAPIINIT"; + break; + case MSG_ERR_PLUGIN_REGEVENT: + return "MSG_ERR_PLUGIN_REGEVENT"; + break; + case MSG_ERR_PLUGIN_TRANSPORT: + return "MSG_ERR_PLUGIN_TRANSPORT"; + break; + case MSG_ERR_PLUGIN_STORAGE: + return "MSG_ERR_PLUGIN_STORAGE"; + break; + case MSG_ERR_PLUGIN_SETTING: + return "MSG_ERR_PLUGIN_SETTING"; + break; + case MSG_ERR_PLUGIN_WAPDECODE: + return "MSG_ERR_PLUGIN_WAPDECODE"; + break; + case MSG_ERR_PLUGIN_TAPI_FAILED: + return "MSG_ERR_PLUGIN_TAPI_FAILED"; + break; + case MSG_ERR_PLUGIN_SIM_MSG_FULL: + return "MSG_ERR_PLUGIN_SIM_MSG_FULL"; + break; + case MSG_ERR_MESSAGE_COUNT_FULL: + return "MSG_ERR_MESSAGE_COUNT_FULL"; + break; + case MSG_ERR_READREPORT_NOT_REQUESTED: + return "MSG_ERR_READREPORT_NOT_REQUESTED"; + break; + case MSG_ERR_READREPORT_ALEADY_SENT: + return "MSG_ERR_READREPORT_ALEADY_SENT"; + break; + case MSG_ERR_FILTER_DUPLICATED: + return "MSG_ERR_FILTER_DUPLICATED"; + break; + case MSG_ERR_PERMISSION_DENIED: + return "MSG_ERR_PERMISSION_DENIED"; + break; + case MSG_ERR_NO_SIM: + return "MSG_ERR_NO_SIM"; + break; + case MSG_ERR_SERVER_NOT_READY: + return "MSG_ERR_SERVER_NOT_READY"; + break; + case MSG_ERR_STORE_RESTRICT: + return "MSG_ERR_STORE_RESTRICT"; + break; + case MSG_ERR_DB_BUSY: + return "MSG_ERR_DB_BUSY"; + break; + case MSG_ERR_NOT_SUPPORTED: + return "MSG_ERR_NOT_SUPPORTED"; + break; + case MSG_ERR_NOT_ALLOWED_ZONE: + return "MSG_ERR_NOT_ALLOWED_ZONE"; + break; + case MSG_ERR_DPM_RESTRICT: + return "MSG_ERR_DPM_RESTRICT"; + break; + default: + return "SOME ANOTHER ERROR"; + break; + } #elif MSG_PUBLIC_API - switch (error) - { - case MESSAGES_ERROR_NONE: - return "MESSAGES_ERROR_NONE"; - break; - case MESSAGES_ERROR_OUT_OF_MEMORY: - return "MESSAGES_ERROR_OUT_OF_MEMORY"; - break; - case MESSAGES_ERROR_INVALID_PARAMETER: - return "MESSAGES_ERROR_INVALID_PARAMETER"; - break; - case MESSAGES_ERROR_SERVER_NOT_READY: - return "MESSAGES_ERROR_SERVER_NOT_READY"; - break; - case MESSAGES_ERROR_COMMUNICATION_WITH_SERVER_FAILED: - return "MESSAGES_ERROR_COMMUNICATION_WITH_SERVER_FAILED"; - break; - case MESSAGES_ERROR_OUT_OF_RANGE: - return "MESSAGES_ERROR_OUT_OF_RANGE"; - break; - case MESSAGES_ERROR_SENDING_FAILED: - return "MESSAGES_ERROR_SENDING_FAILED"; - break; - case MESSAGES_ERROR_OPERATION_FAILED: - return "MESSAGES_ERROR_OPERATION_FAILED"; - break; - case MESSAGES_ERROR_NO_SIM_CARD: - return "MESSAGES_ERROR_NO_SIM_CARD"; - break; - case MESSAGES_ERROR_NO_DATA: - return "MESSAGES_ERROR_NO_DATA"; - break; - case MESSAGES_ERROR_PERMISSION_DENIED: - return "MESSAGES_ERROR_PERMISSION_DENIED"; - break; - case MESSAGES_ERROR_NOT_SUPPORTED: - return "MESSAGES_ERROR_NOT_SUPPORTED"; - break; - default: - return "SOME ANOTHER ERROR"; - break; - } + switch (error) + { + case MESSAGES_ERROR_NONE: + return "MESSAGES_ERROR_NONE"; + break; + case MESSAGES_ERROR_OUT_OF_MEMORY: + return "MESSAGES_ERROR_OUT_OF_MEMORY"; + break; + case MESSAGES_ERROR_INVALID_PARAMETER: + return "MESSAGES_ERROR_INVALID_PARAMETER"; + break; + case MESSAGES_ERROR_SERVER_NOT_READY: + return "MESSAGES_ERROR_SERVER_NOT_READY"; + break; + case MESSAGES_ERROR_COMMUNICATION_WITH_SERVER_FAILED: + return "MESSAGES_ERROR_COMMUNICATION_WITH_SERVER_FAILED"; + break; + case MESSAGES_ERROR_OUT_OF_RANGE: + return "MESSAGES_ERROR_OUT_OF_RANGE"; + break; + case MESSAGES_ERROR_SENDING_FAILED: + return "MESSAGES_ERROR_SENDING_FAILED"; + break; + case MESSAGES_ERROR_OPERATION_FAILED: + return "MESSAGES_ERROR_OPERATION_FAILED"; + break; + case MESSAGES_ERROR_NO_SIM_CARD: + return "MESSAGES_ERROR_NO_SIM_CARD"; + break; + case MESSAGES_ERROR_NO_DATA: + return "MESSAGES_ERROR_NO_DATA"; + break; + case MESSAGES_ERROR_PERMISSION_DENIED: + return "MESSAGES_ERROR_PERMISSION_DENIED"; + break; + case MESSAGES_ERROR_NOT_SUPPORTED: + return "MESSAGES_ERROR_NOT_SUPPORTED"; + break; + default: + return "SOME ANOTHER ERROR"; + break; + } #endif - return "SOME ANOTHER ERROR"; + return "SOME ANOTHER ERROR"; } diff --git a/src/Common/MsgEngine/src/MsgPage.cpp b/src/Common/MsgEngine/src/MsgPage.cpp index 0ef3fbf..eefde49 100644 --- a/src/Common/MsgEngine/src/MsgPage.cpp +++ b/src/Common/MsgEngine/src/MsgPage.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -25,5 +25,5 @@ MsgPage::~MsgPage() const MsgMediaList &MsgPage::getMediaList() const { - return const_cast(*this).getMediaList(); + return const_cast(*this).getMediaList(); } diff --git a/src/Common/MsgEngine/src/MsgSettings.cpp b/src/Common/MsgEngine/src/MsgSettings.cpp index f4a85fd..80ee0ef 100644 --- a/src/Common/MsgEngine/src/MsgSettings.cpp +++ b/src/Common/MsgEngine/src/MsgSettings.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -30,7 +30,7 @@ const int defaultMaxAttachmentsCount = 10; MsgSettings::MsgSettings() { - prepareSendAsAudio(); + prepareSendAsAudio(); } MsgSettings::~MsgSettings() @@ -39,59 +39,59 @@ MsgSettings::~MsgSettings() void MsgSettings::prepareSendAsAudio() { - bool existing = false; - preference_is_existing(SEND_AS_AUDIO_KEY, &existing); - if (!existing) - setSendAsAudio(false); - preference_set_changed_cb(SEND_AS_AUDIO_KEY, makeCbLast(&MsgSettings::onSendAsAudioChanged), this); + bool existing = false; + preference_is_existing(SEND_AS_AUDIO_KEY, &existing); + if (!existing) + setSendAsAudio(false); + preference_set_changed_cb(SEND_AS_AUDIO_KEY, makeCbLast(&MsgSettings::onSendAsAudioChanged), this); } int MsgSettings::getMessageTextMaxChar() const { - return defaultSmsGsm7MaxLen; + return defaultSmsGsm7MaxLen; } int MsgSettings::getMessageMaxPage() const { - return defaultSmsMaxPage; + return defaultSmsMaxPage; } int MsgSettings::getAttachmentsMaxCount() const { - return defaultMaxAttachmentsCount; + return defaultMaxAttachmentsCount; } void MsgSettings::addListener(IMsgSettingsListener &listener) { - auto itr = std::find(m_Listeners.begin(), m_Listeners.end(), &listener); - if (itr == m_Listeners.end()) { - m_Listeners.push_back(&listener); - } + auto itr = std::find(m_Listeners.begin(), m_Listeners.end(), &listener); + 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()) { - m_Listeners.erase(itr); - } + auto itr = std::find(m_Listeners.begin(), m_Listeners.end(), &listener); + if (itr != m_Listeners.end()) { + m_Listeners.erase(itr); + } } void MsgSettings::setSendAsAudio(bool value) { - preference_set_boolean(SEND_AS_AUDIO_KEY, value); + preference_set_boolean(SEND_AS_AUDIO_KEY, value); } bool MsgSettings::getSendAsAudio() const { - bool value = false; - preference_get_boolean(SEND_AS_AUDIO_KEY, &value); - return value; + bool value = false; + preference_get_boolean(SEND_AS_AUDIO_KEY, &value); + return value; } void MsgSettings::onSendAsAudioChanged(const char *key) { - for (auto listener: m_Listeners) - listener->onSendAsAudioChanged(*this); + for (auto listener: m_Listeners) + listener->onSendAsAudioChanged(*this); } diff --git a/src/Common/MsgEngine/src/MsgStorage.cpp b/src/Common/MsgEngine/src/MsgStorage.cpp index 192173b..e6f0c26 100644 --- a/src/Common/MsgEngine/src/MsgStorage.cpp +++ b/src/Common/MsgEngine/src/MsgStorage.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -23,7 +23,7 @@ using namespace Msg; MsgStorage::MsgStorage() { - TRACE; + TRACE; } MsgStorage::~MsgStorage() @@ -32,38 +32,38 @@ MsgStorage::~MsgStorage() void MsgStorage::addListener(IMsgStorageListener &listener) { - auto itr = std::find(m_Listeners.begin(), m_Listeners.end(), &listener); - if (itr == m_Listeners.end()) - { - m_Listeners.push_back(&listener); - } + auto itr = std::find(m_Listeners.begin(), m_Listeners.end(), &listener); + 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()) - { - m_Listeners.erase(itr); - } + auto itr = std::find(m_Listeners.begin(), m_Listeners.end(), &listener); + if (itr != m_Listeners.end()) + { + m_Listeners.erase(itr); + } } bool MsgStorage::hasEmail(ThreadId id) { - if (!id.isValid()) - return false; + if (!id.isValid()) + return false; - const MsgAddressListRef addressList = getAddressList(id); - if (addressList) - { - for (int i = 0; i < addressList->getLength(); ++i) - { - const MsgAddress &msgAddr = addressList->at(i); - if (msgAddr.getAddressType() == MsgAddress::Email) - return true; - else if (MsgUtils::isValidEmail(msgAddr.getAddress())) - return true; - } - } - return false; + const MsgAddressListRef addressList = getAddressList(id); + if (addressList) + { + for (int i = 0; i < addressList->getLength(); ++i) + { + const MsgAddress &msgAddr = addressList->at(i); + if (msgAddr.getAddressType() == MsgAddress::Email) + return true; + else if (MsgUtils::isValidEmail(msgAddr.getAddress())) + return true; + } + } + return false; } diff --git a/src/Common/MsgEngine/src/MsgThreadItem.cpp b/src/Common/MsgEngine/src/MsgThreadItem.cpp index 0654ba1..bbc15fb 100644 --- a/src/Common/MsgEngine/src/MsgThreadItem.cpp +++ b/src/Common/MsgEngine/src/MsgThreadItem.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/Common/MsgEngine/src/MsgTransport.cpp b/src/Common/MsgEngine/src/MsgTransport.cpp index c03dd77..b097a05 100644 --- a/src/Common/MsgEngine/src/MsgTransport.cpp +++ b/src/Common/MsgEngine/src/MsgTransport.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -29,38 +29,38 @@ MsgTransport::~MsgTransport() void MsgTransport::addListener(IMsgTransportListener &listener) { - auto itr = std::find(m_Listeners.begin(), m_Listeners.end(), &listener); - if (itr == m_Listeners.end()){ - m_Listeners.push_back(&listener); - } + auto itr = std::find(m_Listeners.begin(), m_Listeners.end(), &listener); + if (itr == m_Listeners.end()){ + m_Listeners.push_back(&listener); + } } void MsgTransport::removeListener(IMsgTransportListener &listener) { - auto itr = std::find(m_Listeners.begin(), m_Listeners.end(), &listener); - if (itr != m_Listeners.end()) { - m_Listeners.erase(itr); - } + auto itr = std::find(m_Listeners.begin(), m_Listeners.end(), &listener); + if (itr != m_Listeners.end()) { + m_Listeners.erase(itr); + } } void MsgTransport::notifyListenersOnSentStatus(const MsgSentStatus &status) { - for (auto *l : m_Listeners) { - l->onMsgTransportSentStatus(status); - } + for (auto *l : m_Listeners) { + l->onMsgTransportSentStatus(status); + } } MsgTransport::SendResult MsgTransport::sendMessage(MessageRef &msg, ThreadId *threadId, RequestId *requestId) { - return msg ? sendMessage(*msg, threadId, requestId) : MsgTransport::SendFail; + return msg ? sendMessage(*msg, threadId, requestId) : MsgTransport::SendFail; } MsgTransport::SendResult MsgTransport::sendMessage(MessageMmsRef &msg, ThreadId *threadId, RequestId *requestId) { - return msg ? sendMessage(*msg, threadId, requestId) : MsgTransport::SendFail; + return msg ? sendMessage(*msg, threadId, requestId) : MsgTransport::SendFail; } MsgTransport::SendResult MsgTransport::sendMessage(MessageSMSRef &msg, ThreadId *threadId, RequestId *requestId) { - return msg ? sendMessage(*msg, threadId, requestId) : MsgTransport::SendFail; + return msg ? sendMessage(*msg, threadId, requestId) : MsgTransport::SendFail; } diff --git a/src/Common/MsgEngine/src/MsgUtils.cpp b/src/Common/MsgEngine/src/MsgUtils.cpp index fa3298e..b3c2d78 100644 --- a/src/Common/MsgEngine/src/MsgUtils.cpp +++ b/src/Common/MsgEngine/src/MsgUtils.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -35,180 +35,180 @@ const char *emailRegex = "(([[:alnum:]_!#$%&'*+/=?`{|}~^-]+)|(^\"([[:alnum:]_!#$ TokenizedRecipients tokenizeRecipients(const std::string &inputText) { - TokenizedRecipients result; - std::string::size_type begin = inputText.find_first_not_of(delimiters); - std::string::size_type end = inputText.find_first_of(delimiters, begin); - std::string token; - MsgAddress::AddressType addressType = MsgAddress::UnknownAddressType; - - while (begin != end) - { - 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) - { - result.validResults.push_back(std::make_pair(result.invalidResult, addressType)); - result.invalidResult.clear(); - } 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); - } - } - - return result; + TokenizedRecipients result; + std::string::size_type begin = inputText.find_first_not_of(delimiters); + std::string::size_type end = inputText.find_first_of(delimiters, begin); + std::string token; + MsgAddress::AddressType addressType = MsgAddress::UnknownAddressType; + + while (begin != end) + { + 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) + { + result.validResults.push_back(std::make_pair(result.invalidResult, addressType)); + result.invalidResult.clear(); + } 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); + } + } + + return result; } bool isValidNumber(const std::string &address) { - if (address.empty()) - return false; + if (address.empty()) + return false; - std::regex numTemplate(numberRegex); - return std::regex_match(address, numTemplate); + std::regex numTemplate(numberRegex); + return std::regex_match(address, numTemplate); } bool isValidEmail(const std::string &address) { - if (address.empty() || address.length() > emailAddrLenMax) - return false; + if (address.empty() || address.length() > emailAddrLenMax) + return false; - std::regex emailTemplate(emailRegex); - return std::regex_match(address, emailTemplate); + std::regex emailTemplate(emailRegex); + return std::regex_match(address, emailTemplate); } bool isValidAddress(const std::string &address) { - return isValidNumber(address) || isValidEmail(address); + return isValidNumber(address) || isValidEmail(address); } MsgAddress::AddressType getAddressType(const std::string &address) { - if (isValidNumber(address)) - { - return MsgAddress::Phone; - } + if (isValidNumber(address)) + { + return MsgAddress::Phone; + } - if (isValidEmail(address)) - { - return MsgAddress::Email; - } + if (isValidEmail(address)) + { + return MsgAddress::Email; + } - return MsgAddress::UnknownAddressType; + return MsgAddress::UnknownAddressType; } std::string makeNormalizedNumber(const std::string &number) { - std::string normalizedNumber; - for (auto symbol : number) - { - if (isdigit(symbol) || symbol == '*' || symbol == '#' || symbol == '+') - { - normalizedNumber += symbol; - } - } - return normalizedNumber; + std::string normalizedNumber; + for (auto symbol : number) + { + if (isdigit(symbol) || symbol == '*' || symbol == '#' || symbol == '+') + { + normalizedNumber += symbol; + } + } + return normalizedNumber; } std::string makeCleanedNumber(const std::string &number) { - std::string cleanedNumber; - for (auto symbol : number) - { - if (isdigit(symbol)) - cleanedNumber += symbol; - } - return cleanedNumber; + std::string cleanedNumber; + for (auto symbol : number) + { + if (isdigit(symbol)) + cleanedNumber += symbol; + } + return cleanedNumber; } bool isMms(Message::Type type) { - switch (type) - { - case Message::MT_MMS: - case Message::MT_MMS_Noti: - return true; - default: - return false; - } + switch (type) + { + case Message::MT_MMS: + case Message::MT_MMS_Noti: + return true; + default: + return false; + } } bool isSms(Message::Type type) { - return type == Message::MT_SMS; + return type == Message::MT_SMS; } std::string makeKbStr(long long bytes) { - const long long kb = 1024; // Bytes in kb - long long sizeKb = 0; - if (bytes <= kb) - { - sizeKb = 1; - } else { - sizeKb = bytes / kb; - long long sizeB = bytes % kb; - if (sizeB >= (kb / 2)) - ++sizeKb; - } - - return std::to_string(sizeKb) + " " + (std::string)msg("IDS_MSGF_BODY_MSGSIZE_KB"); + const long long kb = 1024; // Bytes in kb + long long sizeKb = 0; + if (bytes <= kb) + { + sizeKb = 1; + } else { + sizeKb = bytes / kb; + long long sizeB = bytes % kb; + if (sizeB >= (kb / 2)) + ++sizeKb; + } + + return std::to_string(sizeKb) + " " + (std::string)msg("IDS_MSGF_BODY_MSGSIZE_KB"); } //return empty list if str is empty or if size of some symbol more then maxSize std::list splitUtf8String(const std::string &str, const unsigned maxSize) { - if (str.empty()) - return {}; - - std::list list; - std::vector vec; - - int index = 0; - int prevIndex = 0; - int size = str.size(); - int c = 0; - std::vector src(size + 1); - i18n_ustring_copy_ua(src.data(), str.c_str()); - i18n_ubreak_iterator_h boundary = {}; - i18n_ubrk_create(I18N_UBRK_CHARACTER, NULL, src.data(), -1, &boundary); - if (!boundary) { - return {}; - } - do { - prevIndex = index; - int pc = c; - c = i18n_ubrk_next(boundary); - if(c == -1) - break; - for(int i = 0; i < c - pc; i++) - eina_unicode_utf8_next_get(str.c_str(), &index); - vec.emplace_back(&str[prevIndex], &str[index]); - } while(index < size); - - i18n_ubrk_destroy(boundary); - - size_t byte = 0; - std::string s; - for (auto &x: vec) { - if(x.size() > maxSize) - return {}; - byte += x.size(); - if (byte <= maxSize) { - s += x; - } else { - list.push_back(std::move(s)); - s = x; - byte = x.size(); - } - } - if (!s.empty()) - list.push_back(s); - return list; + if (str.empty()) + return {}; + + std::list list; + std::vector vec; + + int index = 0; + int prevIndex = 0; + int size = str.size(); + int c = 0; + std::vector src(size + 1); + i18n_ustring_copy_ua(src.data(), str.c_str()); + i18n_ubreak_iterator_h boundary = {}; + i18n_ubrk_create(I18N_UBRK_CHARACTER, NULL, src.data(), -1, &boundary); + if (!boundary) { + return {}; + } + do { + prevIndex = index; + int pc = c; + c = i18n_ubrk_next(boundary); + if(c == -1) + break; + for(int i = 0; i < c - pc; i++) + eina_unicode_utf8_next_get(str.c_str(), &index); + vec.emplace_back(&str[prevIndex], &str[index]); + } while(index < size); + + i18n_ubrk_destroy(boundary); + + size_t byte = 0; + std::string s; + for (auto &x: vec) { + if(x.size() > maxSize) + return {}; + byte += x.size(); + if (byte <= maxSize) { + s += x; + } else { + list.push_back(std::move(s)); + s = x; + byte = x.size(); + } + } + if (!s.empty()) + list.push_back(s); + return list; } } // MsgUtils diff --git a/src/Common/MsgEngine/src/dummy/MessageDummy.cpp b/src/Common/MsgEngine/src/dummy/MessageDummy.cpp index 957371d..29e598f 100644 --- a/src/Common/MsgEngine/src/dummy/MessageDummy.cpp +++ b/src/Common/MsgEngine/src/dummy/MessageDummy.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -24,10 +24,10 @@ using namespace Msg; MessageDummy::MessageDummy(bool release) - : Message() - , MsgStructDummy(release) - , m_Address(false) - , m_AddressList() + : Message() + , MsgStructDummy(release) + , m_Address(false) + , m_AddressList() { } @@ -37,27 +37,27 @@ MessageDummy::~MessageDummy() const MsgAddressListDummy &MessageDummy::getAddressList() const { - return m_AddressList; + return m_AddressList; } MsgAddressDummy &MessageDummy::addAddress() { - return m_Address; + return m_Address; } void MessageDummy::addAddresses(const MsgAddressList &list) { - int len = list.getLength(); - for (int i = 0; i < len; ++i) - { - MsgAddressDummy &newAddr = MessageDummy::addAddress(); - newAddr.setFields(list[i]); - } + int len = list.getLength(); + for (int i = 0; i < len; ++i) + { + MsgAddressDummy &newAddr = MessageDummy::addAddress(); + newAddr.setFields(list[i]); + } } MsgId MessageDummy::getId() const { - return rand()%100; + return rand()%100; } void MessageDummy::setId(MsgId id) @@ -66,12 +66,12 @@ void MessageDummy::setId(MsgId id) ThreadId MessageDummy::getThreadId() const { - return rand()%50; + return rand()%50; } time_t MessageDummy::getTime() const { - return 0; + return 0; } std::string MessageDummy::getText() const @@ -81,28 +81,28 @@ std::string MessageDummy::getText() const Message::Direction MessageDummy::getDirection() const { - return MsgUtilsDummy::nativeToDirection(0); + return MsgUtilsDummy::nativeToDirection(0); } Message::Type MessageDummy::getType() const { - return MT_Unknown; + return MT_Unknown; } MessageDummy::NetworkStatus MessageDummy::getNetworkStatus() const { - return NS_Unknown; + return NS_Unknown; } int MessageDummy::getSize() const { - int msgSize = 300; - return msgSize; + int msgSize = 300; + return msgSize; } std::string MessageDummy::getSubject() const { - return std::string(); + return std::string(); } void MessageDummy::setSubject(const std::string &text) @@ -111,22 +111,22 @@ void MessageDummy::setSubject(const std::string &text) void MessageDummy::setMessageStorageType(Message::MessageStorageType msgStorage) { - switch (msgStorage) - { - case Message::MS_Phone: - break; - case Message::MS_Sim: - break; - case Message::MS_Unknown: - default: - MSG_LOG_ERROR("Unknown storage type!") - break; - } + switch (msgStorage) + { + case Message::MS_Phone: + break; + case Message::MS_Sim: + break; + case Message::MS_Unknown: + default: + MSG_LOG_ERROR("Unknown storage type!") + break; + } } Message::MessageStorageType MessageDummy::getMessageStorageType() const { - return MsgUtilsDummy::nativeToMessageStorage(0); + return MsgUtilsDummy::nativeToMessageStorage(0); } void MessageDummy::commit() @@ -135,12 +135,12 @@ void MessageDummy::commit() bool MessageDummy::isMms() const { - int nativeType = 0; - Message::Type messageType = MsgUtilsDummy::nativeToMessageType(nativeType); - return MsgUtils::isMms(messageType); + int nativeType = 0; + Message::Type messageType = MsgUtilsDummy::nativeToMessageType(nativeType); + return MsgUtils::isMms(messageType); } bool MessageDummy::isRestrictedByDpm() const { - return false; + return false; } diff --git a/src/Common/MsgEngine/src/dummy/MessageDummy.h b/src/Common/MsgEngine/src/dummy/MessageDummy.h index b0303cc..c8e82e6 100644 --- a/src/Common/MsgEngine/src/dummy/MessageDummy.h +++ b/src/Common/MsgEngine/src/dummy/MessageDummy.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -24,42 +24,42 @@ namespace Msg { - class MessageDummy - : public virtual Message - , public MsgStructDummy - { - public: - MessageDummy(bool release); - virtual ~MessageDummy(); + class MessageDummy + : public virtual Message + , public MsgStructDummy + { + public: + MessageDummy(bool release); + virtual ~MessageDummy(); - virtual MsgId getId() const; - virtual ThreadId getThreadId() const; - virtual time_t getTime() const; - virtual const MsgAddressListDummy &getAddressList() const; - virtual MsgAddressDummy &addAddress(); - virtual void addAddresses(const MsgAddressList &list); - virtual std::string getText() const; - Message::Direction getDirection() const; - virtual Type getType() const; - virtual NetworkStatus getNetworkStatus() const; + virtual MsgId getId() const; + virtual ThreadId getThreadId() const; + virtual time_t getTime() const; + virtual const MsgAddressListDummy &getAddressList() const; + virtual MsgAddressDummy &addAddress(); + virtual void addAddresses(const MsgAddressList &list); + virtual std::string getText() const; + Message::Direction getDirection() const; + virtual Type getType() const; + virtual NetworkStatus getNetworkStatus() const; - virtual int getSize() const; - virtual std::string getSubject() const; - virtual void setSubject(const std::string &text); - virtual void setMessageStorageType(Message::MessageStorageType msgStorage); - virtual Message::MessageStorageType getMessageStorageType() const; - virtual bool isMms() const; - virtual bool isRestrictedByDpm() const; + virtual int getSize() const; + virtual std::string getSubject() const; + virtual void setSubject(const std::string &text); + virtual void setMessageStorageType(Message::MessageStorageType msgStorage); + virtual Message::MessageStorageType getMessageStorageType() const; + virtual bool isMms() const; + virtual bool isRestrictedByDpm() const; - void setId(MsgId id); - virtual void commit(); + void setId(MsgId id); + virtual void commit(); - protected: - mutable MsgAddressDummy m_Address; - mutable MsgAddressListDummy m_AddressList; - }; + protected: + mutable MsgAddressDummy m_Address; + mutable MsgAddressListDummy m_AddressList; + }; - typedef class MsgListDummy MessageListDummy; + typedef class MsgListDummy MessageListDummy; } #endif /* _MESSAGE_Dummy_H__ */ diff --git a/src/Common/MsgEngine/src/dummy/MessageMmsDummy.cpp b/src/Common/MsgEngine/src/dummy/MessageMmsDummy.cpp index 48ac6c7..e71ec91 100644 --- a/src/Common/MsgEngine/src/dummy/MessageMmsDummy.cpp +++ b/src/Common/MsgEngine/src/dummy/MessageMmsDummy.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -23,12 +23,12 @@ using namespace Msg; MessageMmsDummy::MessageMmsDummy(bool release) - : MessageDummy(release) - , MessageMms() - , m_PageList() - , m_AttachmentList() - , m_Page(false) - , m_Attachment(false) + : MessageDummy(release) + , MessageMms() + , m_PageList() + , m_AttachmentList() + , m_Page(false) + , m_Attachment(false) { } @@ -42,45 +42,45 @@ MessageMmsDummy::~MessageMmsDummy() MessageMmsDummy::Type MessageMmsDummy::getType() const { - return MsgUtilsDummy::nativeToMessageType(0); + return MsgUtilsDummy::nativeToMessageType(0); } std::string MessageMmsDummy::getText() const { - return fakeMessages[rand() % fakeMessages.size()]; + return fakeMessages[rand() % fakeMessages.size()]; } int MessageMmsDummy::getMediaCount() const { - return 5; + return 5; } const MsgPageListDummy &MessageMmsDummy::getPageList() const { - return m_PageList; + return m_PageList; } MsgPageDummy &MessageMmsDummy::addPage() { - return m_Page; + return m_Page; } const MsgAttachmentListDummy &MessageMmsDummy::getAttachmentList() const { - return m_AttachmentList; + return m_AttachmentList; } MsgAttachmentDummy &MessageMmsDummy::addAttachment() { - return m_Attachment; + return m_Attachment; } time_t MessageMmsDummy::getExpired() const { - return 0; + return 0; } int MessageMmsDummy::getSize() const { - return 250; + return 250; } diff --git a/src/Common/MsgEngine/src/dummy/MessageMmsDummy.h b/src/Common/MsgEngine/src/dummy/MessageMmsDummy.h index 2dc67ef..443e33e 100644 --- a/src/Common/MsgEngine/src/dummy/MessageMmsDummy.h +++ b/src/Common/MsgEngine/src/dummy/MessageMmsDummy.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -24,36 +24,36 @@ namespace Msg { - class MessageMmsDummy - : public MessageDummy - , public MessageMms - { - public: - MessageMmsDummy(bool release); - virtual ~MessageMmsDummy(); - - virtual std::string getText() const; - virtual Type getType() const; - virtual int getSize() const; - - virtual const MsgPageListDummy &getPageList() const; - virtual MsgPageDummy &addPage(); - - virtual const MsgAttachmentListDummy &getAttachmentList() const; - virtual MsgAttachmentDummy &addAttachment(); - virtual time_t getExpired() const; - - virtual void commit(); - int getMediaCount() const; - - private: - mutable MsgPageListDummy m_PageList; - mutable MsgAttachmentListDummy m_AttachmentList; - MsgPageDummy m_Page; - MsgAttachmentDummy m_Attachment; - }; - - typedef class MsgListDummy MmsListDummy; + class MessageMmsDummy + : public MessageDummy + , public MessageMms + { + public: + MessageMmsDummy(bool release); + virtual ~MessageMmsDummy(); + + virtual std::string getText() const; + virtual Type getType() const; + virtual int getSize() const; + + virtual const MsgPageListDummy &getPageList() const; + virtual MsgPageDummy &addPage(); + + virtual const MsgAttachmentListDummy &getAttachmentList() const; + virtual MsgAttachmentDummy &addAttachment(); + virtual time_t getExpired() const; + + virtual void commit(); + int getMediaCount() const; + + private: + mutable MsgPageListDummy m_PageList; + mutable MsgAttachmentListDummy m_AttachmentList; + MsgPageDummy m_Page; + MsgAttachmentDummy m_Attachment; + }; + + typedef class MsgListDummy MmsListDummy; } #endif /* _MESSAGE_MMS_Dummy_H__ */ diff --git a/src/Common/MsgEngine/src/dummy/MessageSMSDummy.cpp b/src/Common/MsgEngine/src/dummy/MessageSMSDummy.cpp index c75b7ae..49a79b7 100644 --- a/src/Common/MsgEngine/src/dummy/MessageSMSDummy.cpp +++ b/src/Common/MsgEngine/src/dummy/MessageSMSDummy.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -23,8 +23,8 @@ using namespace Msg; MessageSMSDummy::MessageSMSDummy(bool release) - : MessageDummy(release) - , MessageSMS() + : MessageDummy(release) + , MessageSMS() { } @@ -34,7 +34,7 @@ MessageSMSDummy::~MessageSMSDummy() MessageSMSDummy::Type MessageSMSDummy::getType() const { - return MT_SMS; + return MT_SMS; } void MessageSMSDummy::setText(const std::string &text) @@ -43,5 +43,5 @@ void MessageSMSDummy::setText(const std::string &text) std::string MessageSMSDummy::getText() const { - return fakeMessages[rand() % fakeMessages.size()]; + return fakeMessages[rand() % fakeMessages.size()]; } diff --git a/src/Common/MsgEngine/src/dummy/MessageSMSDummy.h b/src/Common/MsgEngine/src/dummy/MessageSMSDummy.h index 018f259..a7792a8 100644 --- a/src/Common/MsgEngine/src/dummy/MessageSMSDummy.h +++ b/src/Common/MsgEngine/src/dummy/MessageSMSDummy.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -23,20 +23,20 @@ namespace Msg { - class MessageSMSDummy - : public MessageDummy - , public MessageSMS - { - public: - MessageSMSDummy(bool release); - virtual ~MessageSMSDummy(); + class MessageSMSDummy + : public MessageDummy + , public MessageSMS + { + public: + MessageSMSDummy(bool release); + virtual ~MessageSMSDummy(); - virtual Type getType() const; - virtual void setText(const std::string &text); - virtual std::string getText() const; - }; + virtual Type getType() const; + virtual void setText(const std::string &text); + virtual std::string getText() const; + }; - typedef class MsgListDummy SmsListDummy; + typedef class MsgListDummy SmsListDummy; } #endif /* _MESSAGE_SMS_Dummy_H__ */ diff --git a/src/Common/MsgEngine/src/dummy/MsgAddressDummy.cpp b/src/Common/MsgEngine/src/dummy/MsgAddressDummy.cpp index 075f909..9fa6307 100644 --- a/src/Common/MsgEngine/src/dummy/MsgAddressDummy.cpp +++ b/src/Common/MsgEngine/src/dummy/MsgAddressDummy.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -20,8 +20,8 @@ using namespace Msg; MsgAddressDummy::MsgAddressDummy(bool release) - : MsgStructDummy(release) - , MsgAddress() + : MsgStructDummy(release) + , MsgAddress() { } @@ -31,17 +31,17 @@ MsgAddressDummy::~MsgAddressDummy() std::string MsgAddressDummy::getAddress() const { - return std::string("+380") + std::to_string((rand() % 123515876)); + return std::string("+380") + std::to_string((rand() % 123515876)); } MsgAddressDummy::AddressType MsgAddressDummy::getAddressType() const { - return MsgAddressDummy::Phone; + return MsgAddressDummy::Phone; } MsgAddressDummy::RecipientType MsgAddressDummy::getRecipientType() const { - return MsgAddressDummy::To; + return MsgAddressDummy::To; } void MsgAddressDummy::setAddress(const std::string &address) @@ -58,7 +58,7 @@ void MsgAddressDummy::setRecipientType(RecipientType type) void MsgAddressDummy::setFields(const MsgAddress &addr) { - setAddress(addr.getAddress()); - setAddressType(addr.getAddressType()); - setRecipientType(addr.getRecipientType()); + setAddress(addr.getAddress()); + setAddressType(addr.getAddressType()); + setRecipientType(addr.getRecipientType()); } diff --git a/src/Common/MsgEngine/src/dummy/MsgAddressDummy.h b/src/Common/MsgEngine/src/dummy/MsgAddressDummy.h index 98a4244..cdf8a2b 100644 --- a/src/Common/MsgEngine/src/dummy/MsgAddressDummy.h +++ b/src/Common/MsgEngine/src/dummy/MsgAddressDummy.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -24,26 +24,26 @@ namespace Msg { - class MsgAddressDummy - : public MsgStructDummy - , public MsgAddress - { - public: - MsgAddressDummy(bool release); - virtual ~MsgAddressDummy(); - - virtual std::string getAddress() const; - virtual AddressType getAddressType() const; - virtual RecipientType getRecipientType() const; - - virtual void setAddress(const std::string &address); - virtual void setAddressType(AddressType type); - virtual void setRecipientType(RecipientType type); - - void setFields(const MsgAddress &addr); - }; - - typedef class MsgListDummy MsgAddressListDummy; + class MsgAddressDummy + : public MsgStructDummy + , public MsgAddress + { + public: + MsgAddressDummy(bool release); + virtual ~MsgAddressDummy(); + + virtual std::string getAddress() const; + virtual AddressType getAddressType() const; + virtual RecipientType getRecipientType() const; + + virtual void setAddress(const std::string &address); + virtual void setAddressType(AddressType type); + virtual void setRecipientType(RecipientType type); + + void setFields(const MsgAddress &addr); + }; + + typedef class MsgListDummy MsgAddressListDummy; } #endif /* MsgAddressDummy_h_ */ diff --git a/src/Common/MsgEngine/src/dummy/MsgAttachmentDummy.cpp b/src/Common/MsgEngine/src/dummy/MsgAttachmentDummy.cpp index 00fe7df..6dcf821 100644 --- a/src/Common/MsgEngine/src/dummy/MsgAttachmentDummy.cpp +++ b/src/Common/MsgEngine/src/dummy/MsgAttachmentDummy.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -23,8 +23,8 @@ using namespace Msg; MsgAttachmentDummy::MsgAttachmentDummy(bool release) - : MsgStructDummy(release) - , MsgAttachment() + : MsgStructDummy(release) + , MsgAttachment() { } @@ -34,34 +34,34 @@ MsgAttachmentDummy::~MsgAttachmentDummy() std::string MsgAttachmentDummy::getFilePath() const { - return MsgUtilsDummy::getStr(); + return MsgUtilsDummy::getStr(); } std::string MsgAttachmentDummy::getFileName() const { - return fakeNames[rand()%fakeNames.size()]; + return fakeNames[rand()%fakeNames.size()]; } int MsgAttachmentDummy::getFileSize() const { - return 150; + return 150; } std::string MsgAttachmentDummy::getMime() const { - return MsgUtilsDummy::getStr(); + return MsgUtilsDummy::getStr(); } void MsgAttachmentDummy::setFilePath(const std::string &path) { - setFileName(FileUtils::getFileName(path)); - setFileSize(FileUtils::getFileSize(path)); - setMime(FileUtils::getMimeType(path)); + setFileName(FileUtils::getFileName(path)); + setFileSize(FileUtils::getFileSize(path)); + setMime(FileUtils::getMimeType(path)); } void MsgAttachmentDummy::setFileName(const std::string &fileName) { - MsgUtilsDummy::setStr(); + MsgUtilsDummy::setStr(); } void MsgAttachmentDummy::setFileSize(int size) const @@ -70,7 +70,7 @@ void MsgAttachmentDummy::setFileSize(int size) const void MsgAttachmentDummy::setMime(const std::string &mime) { - MsgUtilsDummy::setStr(); + MsgUtilsDummy::setStr(); } diff --git a/src/Common/MsgEngine/src/dummy/MsgAttachmentDummy.h b/src/Common/MsgEngine/src/dummy/MsgAttachmentDummy.h index 9edf31a..db6a1de 100644 --- a/src/Common/MsgEngine/src/dummy/MsgAttachmentDummy.h +++ b/src/Common/MsgEngine/src/dummy/MsgAttachmentDummy.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -24,26 +24,26 @@ namespace Msg { - class MsgAttachmentDummy - : public MsgStructDummy - , public MsgAttachment - { - public: - MsgAttachmentDummy(bool release); - virtual ~MsgAttachmentDummy(); - - virtual std::string getFilePath() const; - virtual std::string getFileName() const; - virtual int getFileSize() const; - virtual std::string getMime() const; - - virtual void setFilePath(const std::string &path); - void setFileName(const std::string &fileName); - void setFileSize(int size) const; - void setMime(const std::string &mime); - }; - - typedef class MsgListDummy MsgAttachmentListDummy; + class MsgAttachmentDummy + : public MsgStructDummy + , public MsgAttachment + { + public: + MsgAttachmentDummy(bool release); + virtual ~MsgAttachmentDummy(); + + virtual std::string getFilePath() const; + virtual std::string getFileName() const; + virtual int getFileSize() const; + virtual std::string getMime() const; + + virtual void setFilePath(const std::string &path); + void setFileName(const std::string &fileName); + void setFileSize(int size) const; + void setMime(const std::string &mime); + }; + + typedef class MsgListDummy MsgAttachmentListDummy; } #endif /* _MSG_ATTACHMENT_Dummy_H__ */ diff --git a/src/Common/MsgEngine/src/dummy/MsgComposerDummy.cpp b/src/Common/MsgEngine/src/dummy/MsgComposerDummy.cpp index 0195fbd..727ae01 100644 --- a/src/Common/MsgEngine/src/dummy/MsgComposerDummy.cpp +++ b/src/Common/MsgEngine/src/dummy/MsgComposerDummy.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -33,18 +33,18 @@ MsgComposerDummy::~MsgComposerDummy() MessageSMSRef MsgComposerDummy::createSms() { - MessageSMSRef smsRef; - MessageSMSDummy *sms = new MessageSMSDummy(true); - smsRef.reset(sms); - return smsRef; + MessageSMSRef smsRef; + MessageSMSDummy *sms = new MessageSMSDummy(true); + smsRef.reset(sms); + return smsRef; } MessageMmsRef MsgComposerDummy::createMms() { - MessageMmsRef mmsRef; - MessageMmsDummy *mms = new MessageMmsDummy(true); - mmsRef.reset(mms); - return mmsRef; + MessageMmsRef mmsRef; + MessageMmsDummy *mms = new MessageMmsDummy(true); + mmsRef.reset(mms); + return mmsRef; } void MsgComposerDummy::calculateTextMetric(const std::string &text, MsgTextMetric &textMetric) diff --git a/src/Common/MsgEngine/src/dummy/MsgComposerDummy.h b/src/Common/MsgEngine/src/dummy/MsgComposerDummy.h index b4aa903..85f97b7 100644 --- a/src/Common/MsgEngine/src/dummy/MsgComposerDummy.h +++ b/src/Common/MsgEngine/src/dummy/MsgComposerDummy.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -21,22 +21,22 @@ namespace Msg { - class MsgComposerDummy - : public MsgComposer - { - public: - MsgComposerDummy(); - MsgComposerDummy(MsgComposerDummy&) = delete; - MsgComposerDummy &operator=(MsgComposerDummy&) = delete; - virtual ~MsgComposerDummy(); + class MsgComposerDummy + : public MsgComposer + { + public: + MsgComposerDummy(); + MsgComposerDummy(MsgComposerDummy&) = delete; + MsgComposerDummy &operator=(MsgComposerDummy&) = delete; + virtual ~MsgComposerDummy(); - MessageSMSRef createSms() override; - MessageMmsRef createMms() override; - void calculateTextMetric(const std::string &text, MsgTextMetric &textMetric) override; + MessageSMSRef createSms() override; + MessageMmsRef createMms() override; + void calculateTextMetric(const std::string &text, MsgTextMetric &textMetric) override; - private: - void setSmilHeader(bool isTextTop); - }; + private: + void setSmilHeader(bool isTextTop); + }; } #endif /* __MSG_COMPOSER_Dummy_H__ */ diff --git a/src/Common/MsgEngine/src/dummy/MsgConvMediaDummy.cpp b/src/Common/MsgEngine/src/dummy/MsgConvMediaDummy.cpp index d2a4217..1393984 100644 --- a/src/Common/MsgEngine/src/dummy/MsgConvMediaDummy.cpp +++ b/src/Common/MsgEngine/src/dummy/MsgConvMediaDummy.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -21,13 +21,13 @@ using namespace Msg; const std::vector fileNames = {"cat.png", "Calendar1.vcs", "Contact.vcf", - "big.txt", "call.csv", "phone.jpg", "table.3gp", - "Voice.m4a", "1.mp3", "2.mp3"}; + "big.txt", "call.csv", "phone.jpg", "table.3gp", + "Voice.m4a", "1.mp3", "2.mp3"}; MsgConvMediaDummy::MsgConvMediaDummy(bool release) - : MsgStructDummy(release) - , MsgConvMedia() - , m_Number(0) + : MsgStructDummy(release) + , MsgConvMedia() + , m_Number(0) { } @@ -37,23 +37,23 @@ MsgConvMediaDummy::~MsgConvMediaDummy() int MsgConvMediaDummy::getNumberOfItems() { - return fileNames.size(); + return fileNames.size(); } std::string MsgConvMediaDummy::getMime() const { - return std::string(); + return std::string(); } std::string MsgConvMediaDummy::getName() const { - return fileNames[m_Number]; + return fileNames[m_Number]; } std::string MsgConvMediaDummy::getPath() const { - m_Number = rand() % getNumberOfItems(); - return PathUtils::getResourcePath("dummy_res/" + fileNames[m_Number]); + m_Number = rand() % getNumberOfItems(); + return PathUtils::getResourcePath("dummy_res/" + fileNames[m_Number]); } std::string MsgConvMediaDummy::getThumbPath() const diff --git a/src/Common/MsgEngine/src/dummy/MsgConvMediaDummy.h b/src/Common/MsgEngine/src/dummy/MsgConvMediaDummy.h index e783d96..4d64516 100644 --- a/src/Common/MsgEngine/src/dummy/MsgConvMediaDummy.h +++ b/src/Common/MsgEngine/src/dummy/MsgConvMediaDummy.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -24,27 +24,27 @@ namespace Msg { - class MsgConvMediaDummy - : public MsgStructDummy - , public MsgConvMedia - { - public: - MsgConvMediaDummy(bool release); - virtual ~MsgConvMediaDummy(); - - static int getNumberOfItems(); - virtual std::string getMime() const; - virtual std::string getName() const; - virtual std::string getPath() const; - virtual std::string getThumbPath() const; - virtual std::string getContentId() const; - virtual std::string getContentLocation() const; - - private: - mutable int m_Number; - }; - - typedef class MsgListDummy MsgConvMediaListDummy; + class MsgConvMediaDummy + : public MsgStructDummy + , public MsgConvMedia + { + public: + MsgConvMediaDummy(bool release); + virtual ~MsgConvMediaDummy(); + + static int getNumberOfItems(); + virtual std::string getMime() const; + virtual std::string getName() const; + virtual std::string getPath() const; + virtual std::string getThumbPath() const; + virtual std::string getContentId() const; + virtual std::string getContentLocation() const; + + private: + mutable int m_Number; + }; + + typedef class MsgListDummy MsgConvMediaListDummy; } #endif /* MSGCONVMEDIADummy_H_ */ diff --git a/src/Common/MsgEngine/src/dummy/MsgConversationItemDummy.cpp b/src/Common/MsgEngine/src/dummy/MsgConversationItemDummy.cpp index ba7657d..ef4e73e 100644 --- a/src/Common/MsgEngine/src/dummy/MsgConversationItemDummy.cpp +++ b/src/Common/MsgEngine/src/dummy/MsgConversationItemDummy.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -24,8 +24,8 @@ using namespace Msg; MsgConversationItemDummy::MsgConversationItemDummy(bool release) - : MsgStructDummy(release) - , m_MultipartList(rand() % MsgConvMediaDummy::getNumberOfItems()) + : MsgStructDummy(release) + , m_MultipartList(rand() % MsgConvMediaDummy::getNumberOfItems()) { } @@ -35,86 +35,86 @@ MsgConversationItemDummy::~MsgConversationItemDummy() MsgId MsgConversationItemDummy::getMsgId() const { - int id = rand() % 100; - return id; + int id = rand() % 100; + return id; } ThreadId MsgConversationItemDummy::getThreadId() const { - int id = rand() % 50; - return id; + int id = rand() % 50; + return id; } std::string MsgConversationItemDummy::getText() const { - return fakeMessages[rand() % fakeMessages.size()]; + return fakeMessages[rand() % fakeMessages.size()]; } std::string MsgConversationItemDummy::getSubject() const { - return fakeMessages[rand() % fakeMessages.size()]; + return fakeMessages[rand() % fakeMessages.size()]; } time_t MsgConversationItemDummy::getTime() const { - return rand(); + return rand(); } Message::Direction MsgConversationItemDummy::getDirection() const { - int direction = 0; - return MsgUtilsDummy::nativeToDirection(direction); + int direction = 0; + return MsgUtilsDummy::nativeToDirection(direction); } Message::Type MsgConversationItemDummy::getType() const { - Message::Type type = (Message::Type )(rand() % Message::MT_MMS + 1); - return type; + Message::Type type = (Message::Type )(rand() % Message::MT_MMS + 1); + return type; } Message::NetworkStatus MsgConversationItemDummy::getNetworkStatus() const { - Message::NetworkStatus m[] = {Message::NS_Sending, - Message::NS_Send_Success, - Message::NS_Received, - Message::NS_Retrieving, - Message::NS_Retrieve_Success, - Message::NS_Retrieve_Fail, - Message::NS_Send_Fail}; + Message::NetworkStatus m[] = {Message::NS_Sending, + Message::NS_Send_Success, + Message::NS_Received, + Message::NS_Retrieving, + Message::NS_Retrieve_Success, + Message::NS_Retrieve_Fail, + Message::NS_Send_Fail}; - size_t count = sizeof(m) / sizeof(Message::NetworkStatus); - size_t index = rand() % count; - return m[index]; + size_t count = sizeof(m) / sizeof(Message::NetworkStatus); + size_t index = rand() % count; + return m[index]; } bool MsgConversationItemDummy::isDraft() const { - return false; + return false; } bool MsgConversationItemDummy::isRead() const { - return true; + return true; } int MsgConversationItemDummy::getPagesCount() const { - int pages = 0; - return pages; + int pages = 0; + return pages; } int MsgConversationItemDummy::getAttachCount() const { - int attachments = 0; - return attachments; + int attachments = 0; + return attachments; } const MsgConvMediaListDummy &MsgConversationItemDummy::getMediaList() const { - return m_MultipartList; + return m_MultipartList; } bool MsgConversationItemDummy::isRestrictedByDpm() const { - return false; + return false; } diff --git a/src/Common/MsgEngine/src/dummy/MsgConversationItemDummy.h b/src/Common/MsgEngine/src/dummy/MsgConversationItemDummy.h index a4be872..9e81148 100644 --- a/src/Common/MsgEngine/src/dummy/MsgConversationItemDummy.h +++ b/src/Common/MsgEngine/src/dummy/MsgConversationItemDummy.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -23,37 +23,37 @@ namespace Msg { - /** - * @brief Implementation of MsgConversationItem with msg-service Dummy API usage. - */ - class MsgConversationItemDummy - : public MsgStructDummy - , public MsgConversationItem - { - public: - MsgConversationItemDummy(bool release); - virtual ~MsgConversationItemDummy(); + /** + * @brief Implementation of MsgConversationItem with msg-service Dummy API usage. + */ + class MsgConversationItemDummy + : public MsgStructDummy + , public MsgConversationItem + { + public: + MsgConversationItemDummy(bool release); + virtual ~MsgConversationItemDummy(); - virtual MsgId getMsgId() const; - virtual ThreadId getThreadId() const; - virtual std::string getText() const; - virtual std::string getSubject() const; - virtual time_t getTime() const; - virtual Message::Direction getDirection() const; - virtual Message::Type getType() const; - virtual Message::NetworkStatus getNetworkStatus() const; - virtual bool isDraft() const; - virtual bool isRead() const; - virtual int getPagesCount() const; - virtual int getAttachCount() const; - virtual const MsgConvMediaListDummy &getMediaList() const; - virtual bool isRestrictedByDpm() const; + virtual MsgId getMsgId() const; + virtual ThreadId getThreadId() const; + virtual std::string getText() const; + virtual std::string getSubject() const; + virtual time_t getTime() const; + virtual Message::Direction getDirection() const; + virtual Message::Type getType() const; + virtual Message::NetworkStatus getNetworkStatus() const; + virtual bool isDraft() const; + virtual bool isRead() const; + virtual int getPagesCount() const; + virtual int getAttachCount() const; + virtual const MsgConvMediaListDummy &getMediaList() const; + virtual bool isRestrictedByDpm() const; - protected: - mutable MsgConvMediaListDummy m_MultipartList; - }; + protected: + mutable MsgConvMediaListDummy m_MultipartList; + }; - typedef class MsgListDummy MsgConversationListDummy; + typedef class MsgListDummy MsgConversationListDummy; } #endif /* __MSG_CONVERSATION_ITEM_Dummy_H__ */ diff --git a/src/Common/MsgEngine/src/dummy/MsgDefDummy.h b/src/Common/MsgEngine/src/dummy/MsgDefDummy.h index 1d2c9e2..4851d01 100644 --- a/src/Common/MsgEngine/src/dummy/MsgDefDummy.h +++ b/src/Common/MsgEngine/src/dummy/MsgDefDummy.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -21,30 +21,30 @@ namespace Msg { - // SMIL layout: - const int smilScreenWidthP = 100; - const int smilScreenHeightP = 100; - - const int smilPosTop = 1; - const int smilPosBottom = 50; - const int smilPosLeft = 0; - - const int smilRegionWidth = 100; - const int smilRegionHeight = 50; - - // Text style: - const int smilDefaultBgColor = 0xFF000000; - const int smilDefaultFontColor = 0xFFFFFFFF; - const int smilDefaultFontSize = 30; - const bool smilDefaultBold = false; - const bool smilDefaultUnderline = false; - - // Region id: - const std::string textRegionId = "Text"; - const std::string imageRegionId = "Image"; - - // Mime: - const std::string mimeText = "text/plain"; + // SMIL layout: + const int smilScreenWidthP = 100; + const int smilScreenHeightP = 100; + + const int smilPosTop = 1; + const int smilPosBottom = 50; + const int smilPosLeft = 0; + + const int smilRegionWidth = 100; + const int smilRegionHeight = 50; + + // Text style: + const int smilDefaultBgColor = 0xFF000000; + const int smilDefaultFontColor = 0xFFFFFFFF; + const int smilDefaultFontSize = 30; + const bool smilDefaultBold = false; + const bool smilDefaultUnderline = false; + + // Region id: + const std::string textRegionId = "Text"; + const std::string imageRegionId = "Image"; + + // Mime: + const std::string mimeText = "text/plain"; } diff --git a/src/Common/MsgEngine/src/dummy/MsgListDummy.h b/src/Common/MsgEngine/src/dummy/MsgListDummy.h index 4c362d2..d6332cf 100644 --- a/src/Common/MsgEngine/src/dummy/MsgListDummy.h +++ b/src/Common/MsgEngine/src/dummy/MsgListDummy.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -21,49 +21,49 @@ namespace Msg { - // class T : public BaseT {} - template - class MsgListDummy - : public MsgList // implement interface - { - public: - MsgListDummy(int size) - : m_Object(false) - , m_Length(size) - { - } - MsgListDummy() - : m_Object(false) - , m_Length(15) - { - } + // class T : public BaseT {} + template + class MsgListDummy + : public MsgList // implement interface + { + public: + MsgListDummy(int size) + : m_Object(false) + , m_Length(size) + { + } + MsgListDummy() + : m_Object(false) + , m_Length(15) + { + } - virtual ~MsgListDummy() - { - } + virtual ~MsgListDummy() + { + } - virtual BaseT &at(int i) - { - return m_Object; - } + virtual BaseT &at(int i) + { + return m_Object; + } - virtual const BaseT &at(int i) const - { - return m_Object; - } + virtual const BaseT &at(int i) const + { + return m_Object; + } - virtual int getLength() const - { - return m_Length; - } + virtual int getLength() const + { + return m_Length; + } - MsgListDummy(MsgListDummy&) = delete; - MsgListDummy &operator=(MsgListDummy&) = delete; + MsgListDummy(MsgListDummy&) = delete; + MsgListDummy &operator=(MsgListDummy&) = delete; - protected: - mutable T m_Object; - int m_Length; - }; + protected: + mutable T m_Object; + int m_Length; + }; } #endif /* _MsgListDummy_H__ */ diff --git a/src/Common/MsgEngine/src/dummy/MsgMediaDummy.cpp b/src/Common/MsgEngine/src/dummy/MsgMediaDummy.cpp index 9a69498..5305337 100644 --- a/src/Common/MsgEngine/src/dummy/MsgMediaDummy.cpp +++ b/src/Common/MsgEngine/src/dummy/MsgMediaDummy.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -25,7 +25,7 @@ using namespace Msg; MsgMediaDummy::MsgMediaDummy(bool release) - : MsgStructDummy(release) + : MsgStructDummy(release) { } @@ -35,23 +35,23 @@ MsgMediaDummy::~MsgMediaDummy() MsgMediaDummy::Type MsgMediaDummy::getType() const { - int type = UnknownType; - return MsgUtilsDummy::nativeToSmilType(type); + int type = UnknownType; + return MsgUtilsDummy::nativeToSmilType(type); } std::string MsgMediaDummy::getFileName() const { - return ""; + return ""; } std::string MsgMediaDummy::getFilePath() const { - return ""; + return ""; } std::string MsgMediaDummy::getMime() const { - return std::string(); + return std::string(); } void MsgMediaDummy::setType(Type type) @@ -60,18 +60,18 @@ void MsgMediaDummy::setType(Type type) void MsgMediaDummy::setMime(const std::string &mime) { - MsgUtilsDummy::setStr(); + MsgUtilsDummy::setStr(); } void MsgMediaDummy::setFilePath(const std::string &path) { - MsgUtilsDummy::setStr(); - MediaTypeData mediaData = getMsgMediaTypeByFileExt(path); - setType(mediaData.type); - setFileName(FileUtils::getFileName(path)); + MsgUtilsDummy::setStr(); + MediaTypeData mediaData = getMsgMediaTypeByFileExt(path); + setType(mediaData.type); + setFileName(FileUtils::getFileName(path)); } void MsgMediaDummy::setFileName(const std::string &name) { - MsgUtilsDummy::setStr(); + MsgUtilsDummy::setStr(); } diff --git a/src/Common/MsgEngine/src/dummy/MsgMediaDummy.h b/src/Common/MsgEngine/src/dummy/MsgMediaDummy.h index e62dd23..390a990 100644 --- a/src/Common/MsgEngine/src/dummy/MsgMediaDummy.h +++ b/src/Common/MsgEngine/src/dummy/MsgMediaDummy.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -24,26 +24,26 @@ namespace Msg { - class MsgMediaDummy - : public MsgStructDummy - , public MsgMedia - { - public: - MsgMediaDummy(bool release); - virtual ~MsgMediaDummy(); - - virtual Type getType() const; - virtual std::string getFilePath() const; - virtual std::string getFileName() const; - virtual void setFilePath(const std::string &path); - - std::string getMime() const; - void setFileName(const std::string &name); - void setMime(const std::string &mime); - void setType(Type type); - }; - - typedef class MsgListDummy MsgMediaListDummy; + class MsgMediaDummy + : public MsgStructDummy + , public MsgMedia + { + public: + MsgMediaDummy(bool release); + virtual ~MsgMediaDummy(); + + virtual Type getType() const; + virtual std::string getFilePath() const; + virtual std::string getFileName() const; + virtual void setFilePath(const std::string &path); + + std::string getMime() const; + void setFileName(const std::string &name); + void setMime(const std::string &mime); + void setType(Type type); + }; + + typedef class MsgListDummy MsgMediaListDummy; } #endif /* _MSG_MEDIA_Dummy_H__ */ diff --git a/src/Common/MsgEngine/src/dummy/MsgPageDummy.cpp b/src/Common/MsgEngine/src/dummy/MsgPageDummy.cpp index 3d2e43c..aa03bdd 100644 --- a/src/Common/MsgEngine/src/dummy/MsgPageDummy.cpp +++ b/src/Common/MsgEngine/src/dummy/MsgPageDummy.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -19,9 +19,9 @@ using namespace Msg; MsgPageDummy::MsgPageDummy(bool release) - : MsgStructDummy(release) - , m_MediaList() - , m_Media(false) + : MsgStructDummy(release) + , m_MediaList() + , m_Media(false) { } @@ -31,12 +31,12 @@ MsgPageDummy::~MsgPageDummy() MsgMediaListDummy &MsgPageDummy::getMediaList() { - return m_MediaList; + return m_MediaList; } MsgMediaDummy &MsgPageDummy::addMedia() { - return m_Media; + return m_Media; } void MsgPageDummy::setPageDuration(int duration) @@ -45,6 +45,6 @@ void MsgPageDummy::setPageDuration(int duration) int MsgPageDummy::getPageDuration() const { - return 5; + return 5; } diff --git a/src/Common/MsgEngine/src/dummy/MsgPageDummy.h b/src/Common/MsgEngine/src/dummy/MsgPageDummy.h index 07035ec..70901a1 100644 --- a/src/Common/MsgEngine/src/dummy/MsgPageDummy.h +++ b/src/Common/MsgEngine/src/dummy/MsgPageDummy.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -22,25 +22,25 @@ namespace Msg { - class MsgPageDummy - : public MsgStructDummy - , public MsgPage - { - public: - MsgPageDummy(bool release); - virtual ~MsgPageDummy(); + class MsgPageDummy + : public MsgStructDummy + , public MsgPage + { + public: + MsgPageDummy(bool release); + virtual ~MsgPageDummy(); - virtual MsgMediaListDummy &getMediaList(); - virtual MsgMediaDummy &addMedia(); - virtual void setPageDuration(int duration); - virtual int getPageDuration() const; + virtual MsgMediaListDummy &getMediaList(); + virtual MsgMediaDummy &addMedia(); + virtual void setPageDuration(int duration); + virtual int getPageDuration() const; - private: - MsgMediaListDummy m_MediaList; - MsgMediaDummy m_Media; - }; + private: + MsgMediaListDummy m_MediaList; + MsgMediaDummy m_Media; + }; - typedef class MsgListDummy MsgPageListDummy; + typedef class MsgListDummy MsgPageListDummy; } #endif /* _MSG_PAGE_Dummy_H__ */ diff --git a/src/Common/MsgEngine/src/dummy/MsgReportDummy.cpp b/src/Common/MsgEngine/src/dummy/MsgReportDummy.cpp index d548127..230cca3 100644 --- a/src/Common/MsgEngine/src/dummy/MsgReportDummy.cpp +++ b/src/Common/MsgEngine/src/dummy/MsgReportDummy.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -20,8 +20,8 @@ using namespace Msg; MsgReportDummy::MsgReportDummy(bool release) - : MsgStructDummy(release) - , MsgReport() + : MsgStructDummy(release) + , MsgReport() { } @@ -31,29 +31,29 @@ MsgReportDummy::~MsgReportDummy() std::string MsgReportDummy::getAddress() const { - return std::string(); + return std::string(); } MsgReport::DeliveryStatus MsgReportDummy::getDeliveryStatus() const { - int nativeType = 0; - return MsgUtilsDummy::nativeToReportDeliveryStatus(nativeType); + int nativeType = 0; + return MsgUtilsDummy::nativeToReportDeliveryStatus(nativeType); } MsgReport::ReadStatus MsgReportDummy::getReadStatus() const { - int nativeType = 0; - return MsgUtilsDummy::nativeToReportReadStatus(nativeType); + int nativeType = 0; + return MsgUtilsDummy::nativeToReportReadStatus(nativeType); } MsgReport::Type MsgReportDummy::getType() const { - int nativeType = 0; - return MsgUtilsDummy::nativeToReportType(nativeType); + int nativeType = 0; + return MsgUtilsDummy::nativeToReportType(nativeType); } time_t MsgReportDummy::getTime() const { - int time = 0; - return (time_t)time; + int time = 0; + return (time_t)time; } diff --git a/src/Common/MsgEngine/src/dummy/MsgReportDummy.h b/src/Common/MsgEngine/src/dummy/MsgReportDummy.h index c95194a..5c0c497 100644 --- a/src/Common/MsgEngine/src/dummy/MsgReportDummy.h +++ b/src/Common/MsgEngine/src/dummy/MsgReportDummy.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -24,22 +24,22 @@ namespace Msg { - class MsgReportDummy - : public MsgStructDummy - , public MsgReport - { - public: - MsgReportDummy(bool release); - virtual ~MsgReportDummy(); + class MsgReportDummy + : public MsgStructDummy + , public MsgReport + { + public: + MsgReportDummy(bool release); + virtual ~MsgReportDummy(); - virtual std::string getAddress() const; - virtual DeliveryStatus getDeliveryStatus() const; - virtual ReadStatus getReadStatus() const; - virtual Type getType() const; - virtual time_t getTime() const; - }; + virtual std::string getAddress() const; + virtual DeliveryStatus getDeliveryStatus() const; + virtual ReadStatus getReadStatus() const; + virtual Type getType() const; + virtual time_t getTime() const; + }; - typedef class MsgListDummy MsgReportListDummy; + typedef class MsgListDummy MsgReportListDummy; } #endif /* MsgReportDummy_h_ */ diff --git a/src/Common/MsgEngine/src/dummy/MsgSettingsDummy.cpp b/src/Common/MsgEngine/src/dummy/MsgSettingsDummy.cpp index cd687ad..385b9fb 100644 --- a/src/Common/MsgEngine/src/dummy/MsgSettingsDummy.cpp +++ b/src/Common/MsgEngine/src/dummy/MsgSettingsDummy.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -24,7 +24,7 @@ using namespace Msg; MsgSettingsDummy::MsgSettingsDummy() - : MsgSettings() + : MsgSettings() { } @@ -34,43 +34,43 @@ MsgSettingsDummy::~MsgSettingsDummy() int MsgSettingsDummy::getAddressMaxLen() const { - return 500; + return 500; } int MsgSettingsDummy::getPhoneNumberMaxLen() const { - return 500; + return 500; } int MsgSettingsDummy::getAddressMaxCount() const { - return 500; + return 500; } int MsgSettingsDummy::getSubjectMaxLen() const { - return 500; + return 500; } int MsgSettingsDummy::getDisplayNameMaxLen() const { - return 500; + return 500; } int MsgSettingsDummy::getMaxRecipientCount() const { - return 150; + return 150; } int MsgSettingsDummy::getMaxMmsSize() const { - int res = 500; - return res; + int res = 500; + return res; } int MsgSettingsDummy::getMaxMsgTextLen() const { - return 1500; + return 1500; } void MsgSettingsDummy::setAlerts(bool value) @@ -79,35 +79,35 @@ void MsgSettingsDummy::setAlerts(bool value) bool MsgSettingsDummy::getAlerts() const { - bool res = false; - return res; + bool res = false; + return res; } void MsgSettingsDummy::setRingtoneType(RingtoneType type) { - for (auto listener: m_Listeners) - { - listener->onRingtoneChanged(*this); - } + for (auto listener: m_Listeners) + { + listener->onRingtoneChanged(*this); + } } MsgSettingsDummy::RingtoneType MsgSettingsDummy::getRingtoneType() const { - int type = 0; - return MsgUtilsDummy::nativeToRingtoneType(type); + int type = 0; + return MsgUtilsDummy::nativeToRingtoneType(type); } void MsgSettingsDummy::setRingtone(const std::string &soundPath) { - for (auto listener: m_Listeners) - { - listener->onRingtoneChanged(*this); - } + for (auto listener: m_Listeners) + { + listener->onRingtoneChanged(*this); + } } std::string MsgSettingsDummy::getRingtone() const { - return ""; + return ""; } void MsgSettingsDummy::setVibration(bool value) @@ -116,8 +116,8 @@ void MsgSettingsDummy::setVibration(bool value) bool MsgSettingsDummy::getVibration() const { - bool res = false; - return res; + bool res = false; + return res; } void MsgSettingsDummy::setSmsDelivReport(bool value) @@ -126,8 +126,8 @@ void MsgSettingsDummy::setSmsDelivReport(bool value) bool MsgSettingsDummy::getSmsDelivReport() const { - bool res = false; - return res; + bool res = false; + return res; } void MsgSettingsDummy::setMmsDelivReport(bool value) @@ -136,8 +136,8 @@ void MsgSettingsDummy::setMmsDelivReport(bool value) bool MsgSettingsDummy::getMmsDelivReport() const { - bool res = false; - return res; + bool res = false; + return res; } void MsgSettingsDummy::setMmsReadReport(bool value) @@ -146,8 +146,8 @@ void MsgSettingsDummy::setMmsReadReport(bool value) bool MsgSettingsDummy::getMmsReadReport() const { - bool res = false; - return res; + bool res = false; + return res; } void MsgSettingsDummy::setMmsAutoRetr(bool value) @@ -156,8 +156,8 @@ void MsgSettingsDummy::setMmsAutoRetr(bool value) bool MsgSettingsDummy::getMmsAutoRetr() const { - bool res = true; - return res; + bool res = true; + return res; } void MsgSettingsDummy::setMmsAutoRetrRoaming(bool value) @@ -166,8 +166,8 @@ void MsgSettingsDummy::setMmsAutoRetrRoaming(bool value) bool MsgSettingsDummy::getMmsAutoRetrRoaming() const { - bool res = true; - return res; + bool res = true; + return res; } void MsgSettingsDummy::setActiveNotifPolicy(ActiveNotifPolicy type) diff --git a/src/Common/MsgEngine/src/dummy/MsgSettingsDummy.h b/src/Common/MsgEngine/src/dummy/MsgSettingsDummy.h index 866b7fa..fb479df 100644 --- a/src/Common/MsgEngine/src/dummy/MsgSettingsDummy.h +++ b/src/Common/MsgEngine/src/dummy/MsgSettingsDummy.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -23,53 +23,53 @@ namespace Msg { - class MsgSettingsDummy - : public MsgSettings - { - public: - MsgSettingsDummy(); - MsgSettingsDummy(MsgSettingsDummy&) = delete; - MsgSettingsDummy &operator=(MsgSettingsDummy&) = delete; - virtual ~MsgSettingsDummy(); + class MsgSettingsDummy + : public MsgSettings + { + public: + MsgSettingsDummy(); + MsgSettingsDummy(MsgSettingsDummy&) = delete; + MsgSettingsDummy &operator=(MsgSettingsDummy&) = delete; + virtual ~MsgSettingsDummy(); - virtual int getAddressMaxLen() const; - virtual int getPhoneNumberMaxLen() const; - virtual int getAddressMaxCount() const; - virtual int getSubjectMaxLen() const; - virtual int getDisplayNameMaxLen() const; - virtual int getMaxRecipientCount() const; - virtual int getMaxMmsSize() const; - virtual int getMaxMsgTextLen() const; + virtual int getAddressMaxLen() const; + virtual int getPhoneNumberMaxLen() const; + virtual int getAddressMaxCount() const; + virtual int getSubjectMaxLen() const; + virtual int getDisplayNameMaxLen() const; + virtual int getMaxRecipientCount() const; + virtual int getMaxMmsSize() const; + virtual int getMaxMsgTextLen() const; - virtual void setAlerts(bool value); - virtual bool getAlerts() const; + virtual void setAlerts(bool value); + virtual bool getAlerts() const; - virtual void setRingtoneType(RingtoneType type); - virtual RingtoneType getRingtoneType() const; - virtual void setRingtone(const std::string &soundPath); - virtual std::string getRingtone() const; + virtual void setRingtoneType(RingtoneType type); + virtual RingtoneType getRingtoneType() const; + virtual void setRingtone(const std::string &soundPath); + virtual std::string getRingtone() const; - virtual void setVibration(bool value); - virtual bool getVibration() const; + virtual void setVibration(bool value); + virtual bool getVibration() const; - virtual void setSmsDelivReport(bool value); - virtual bool getSmsDelivReport() const; + virtual void setSmsDelivReport(bool value); + virtual bool getSmsDelivReport() const; - virtual void setMmsDelivReport(bool value); - virtual bool getMmsDelivReport() const ; + virtual void setMmsDelivReport(bool value); + virtual bool getMmsDelivReport() const ; - virtual void setMmsReadReport(bool value); - virtual bool getMmsReadReport() const; + virtual void setMmsReadReport(bool value); + virtual bool getMmsReadReport() const; - virtual void setMmsAutoRetr(bool value); - virtual bool getMmsAutoRetr() const; + virtual void setMmsAutoRetr(bool value); + virtual bool getMmsAutoRetr() const; - virtual void setMmsAutoRetrRoaming(bool value); - virtual bool getMmsAutoRetrRoaming() const; + virtual void setMmsAutoRetrRoaming(bool value); + virtual bool getMmsAutoRetrRoaming() const; - virtual void setActiveNotifPolicy(ActiveNotifPolicy type); - virtual void setActiveNotifPolicy(ThreadId id); - }; + virtual void setActiveNotifPolicy(ActiveNotifPolicy type); + virtual void setActiveNotifPolicy(ThreadId id); + }; } #endif /* __MsgSettingsDummy_h__ */ diff --git a/src/Common/MsgEngine/src/dummy/MsgStorageDummy.cpp b/src/Common/MsgEngine/src/dummy/MsgStorageDummy.cpp index 63ea9fe..ff96856 100644 --- a/src/Common/MsgEngine/src/dummy/MsgStorageDummy.cpp +++ b/src/Common/MsgEngine/src/dummy/MsgStorageDummy.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -31,9 +31,9 @@ using namespace Msg; MsgStorageDummy::MsgStorageDummy() - : MsgStorage() + : MsgStorage() { - TRACE; + TRACE; } MsgStorageDummy::~MsgStorageDummy() @@ -45,98 +45,98 @@ MsgThreadListRef MsgStorageDummy::getThreadList() { MsgThreadListRef res; res.reset(new MsgThreadListDummy); - return res; + return res; } MessageSMSListRef MsgStorageDummy::getSimMsgList() { - MessageSMSListRef res; - res.reset(new SmsListDummy); - return res; + MessageSMSListRef res; + res.reset(new SmsListDummy); + return res; } ThreadId MsgStorageDummy::getThreadId(const MsgAddressList &addressList) { - return (ThreadId)rand()%100; + return (ThreadId)rand()%100; } ThreadId MsgStorageDummy::getThreadId(const std::list &addressList) { - return (ThreadId)(rand()%100); + return (ThreadId)(rand()%100); } MsgAddressListRef MsgStorageDummy::getAddressList(ThreadId id) { - MsgAddressListDummy *result = new MsgAddressListDummy; - return MsgAddressListRef(result); + MsgAddressListDummy *result = new MsgAddressListDummy; + return MsgAddressListRef(result); } MsgThreadListRef MsgStorageDummy::searchThread(const std::string &word) { - return getThreadList(); + return getThreadList(); } int MsgStorageDummy::getUnreadThreadCount() const { - return 2; + return 2; } MsgThreadItemRef MsgStorageDummy::getThread(ThreadId id) { - MsgThreadItemRef res; - res.reset(new MsgThreadItemDummy(true)); - return res; + MsgThreadItemRef res; + res.reset(new MsgThreadItemDummy(true)); + return res; } bool MsgStorageDummy::deleteThread(ThreadId id) { - return true; + return true; } MsgConversationListRef MsgStorageDummy::getConversationList(ThreadId id) { - MsgConversationListRef res; - res.reset(new MsgConversationListDummy); - return res; + MsgConversationListRef res; + res.reset(new MsgConversationListDummy); + return res; } MsgConversationItemRef MsgStorageDummy::getConversationItem(MsgId id) { - MsgConversationItemRef res; - res.reset(new MsgConversationItemDummy(true)); - return res; + MsgConversationItemRef res; + res.reset(new MsgConversationItemDummy(true)); + return res; } MessageRef MsgStorageDummy::getMessage(MsgId id) { - MessageRef res; - res.reset(new MessageSMSDummy(true)); - return res; + MessageRef res; + res.reset(new MessageSMSDummy(true)); + return res; } MsgId MsgStorageDummy::saveMessage(Message &msg, bool updateExisting, StorageResult *result) { - if (result) - *result = StorageSuccess; + if (result) + *result = StorageSuccess; - MsgId newMsgId; - return newMsgId; + MsgId newMsgId; + return newMsgId; } bool MsgStorageDummy::deleteMessage(MsgId id) { - return true; + return true; } bool MsgStorageDummy::deleteMessages(const MsgIdList &idList) { - return true; + return true; } MessageListRef MsgStorageDummy::searchMessage(const std::string &word) { - MessageListRef res; - return res; + MessageListRef res; + return res; } void MsgStorageDummy::setReadStatus(ThreadId id) @@ -149,24 +149,24 @@ void MsgStorageDummy::setReadStatus(MsgId id, bool status) MsgReportListRef MsgStorageDummy::getMsgReportList(MsgId msgId) { - MsgReportListDummy *result = new MsgReportListDummy; - return MsgReportListRef(result); + MsgReportListDummy *result = new MsgReportListDummy; + return MsgReportListRef(result); } bool MsgStorageDummy::isReadReportChecked(MsgId msgId) { - bool readFlag = false; - return readFlag; + bool readFlag = false; + return readFlag; } bool MsgStorageDummy::isDeliverReportChecked(MsgId msgId) { - bool deliverFlag = false; - return deliverFlag; + bool deliverFlag = false; + return deliverFlag; } ThreadId MsgStorageDummy::getThreadId(MsgId id) { - int threadId = ThreadId::invalidId; - return threadId; + int threadId = ThreadId::invalidId; + return threadId; } diff --git a/src/Common/MsgEngine/src/dummy/MsgStorageDummy.h b/src/Common/MsgEngine/src/dummy/MsgStorageDummy.h index 02fdf8a..85dbebe 100644 --- a/src/Common/MsgEngine/src/dummy/MsgStorageDummy.h +++ b/src/Common/MsgEngine/src/dummy/MsgStorageDummy.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -22,61 +22,61 @@ namespace Msg { - class MsgStorageDummy - : public MsgStorage - { - public: - MsgStorageDummy(); - MsgStorageDummy(MsgStorageDummy&) = delete; - MsgStorageDummy &operator=(MsgStorageDummy&) = delete; - virtual ~MsgStorageDummy(); + class MsgStorageDummy + : public MsgStorage + { + public: + MsgStorageDummy(); + MsgStorageDummy(MsgStorageDummy&) = delete; + MsgStorageDummy &operator=(MsgStorageDummy&) = delete; + virtual ~MsgStorageDummy(); - // Thread: - virtual MsgThreadListRef getThreadList(); - virtual MsgThreadItemRef getThread(ThreadId id); - virtual ThreadId getThreadId(const MsgAddressList &addressList); - virtual ThreadId getThreadId(const std::list &addressList); - virtual ThreadId getThreadId(MsgId id); - virtual bool deleteThread(ThreadId id); - virtual MsgAddressListRef getAddressList(ThreadId id); - virtual MsgThreadListRef searchThread(const std::string &word); - virtual void setReadStatus(ThreadId id); - virtual int getUnreadThreadCount() const; + // Thread: + virtual MsgThreadListRef getThreadList(); + virtual MsgThreadItemRef getThread(ThreadId id); + virtual ThreadId getThreadId(const MsgAddressList &addressList); + virtual ThreadId getThreadId(const std::list &addressList); + virtual ThreadId getThreadId(MsgId id); + virtual bool deleteThread(ThreadId id); + virtual MsgAddressListRef getAddressList(ThreadId id); + virtual MsgThreadListRef searchThread(const std::string &word); + virtual void setReadStatus(ThreadId id); + virtual int getUnreadThreadCount() const; - // Message: - virtual MessageSMSListRef getSimMsgList(); - virtual MessageRef getMessage(MsgId id); + // Message: + virtual MessageSMSListRef getSimMsgList(); + virtual MessageRef getMessage(MsgId id); - /** - *@brief Return id of new message or of updated message - *@param[in] msg - message that we need to save - *@param[in] updateExisting - true if we need to update our message id DB, - * false if we need to save message with new id - *@param[out] result of storage operation. - *@return MessageId - */ - virtual MsgId saveMessage(Message &msg, bool updateExisting, StorageResult *result); - virtual bool deleteMessage(MsgId id); - virtual bool deleteMessages(const MsgIdList &idList); - virtual MessageListRef searchMessage(const std::string &word); - virtual void setReadStatus(MsgId id, bool status); - virtual MsgReportListRef getMsgReportList(MsgId msgId); - virtual bool isReadReportChecked(MsgId msgId); - virtual bool isDeliverReportChecked(MsgId msgId); + /** + *@brief Return id of new message or of updated message + *@param[in] msg - message that we need to save + *@param[in] updateExisting - true if we need to update our message id DB, + * false if we need to save message with new id + *@param[out] result of storage operation. + *@return MessageId + */ + virtual MsgId saveMessage(Message &msg, bool updateExisting, StorageResult *result); + virtual bool deleteMessage(MsgId id); + virtual bool deleteMessages(const MsgIdList &idList); + virtual MessageListRef searchMessage(const std::string &word); + virtual void setReadStatus(MsgId id, bool status); + virtual MsgReportListRef getMsgReportList(MsgId msgId); + virtual bool isReadReportChecked(MsgId msgId); + virtual bool isDeliverReportChecked(MsgId msgId); - // Conversation: - virtual MsgConversationListRef getConversationList(ThreadId id); - virtual MsgConversationItemRef getConversationItem(MsgId id); + // Conversation: + virtual MsgConversationListRef getConversationList(ThreadId id); + virtual MsgConversationItemRef getConversationItem(MsgId id); - private: - template - using ListenerMethod = void (IMsgStorageListener::*)(const T&); + private: + template + using ListenerMethod = void (IMsgStorageListener::*)(const T&); - template - void notifyListeners(const T& delta, ListenerMethod method); + template + void notifyListeners(const T& delta, ListenerMethod method); - MessageSMS *createSms(); - }; + MessageSMS *createSms(); + }; } #endif /* __MSG_STORAGE_Dummy_H__ */ diff --git a/src/Common/MsgEngine/src/dummy/MsgStructDummy.h b/src/Common/MsgEngine/src/dummy/MsgStructDummy.h index 9e6d3df..f4e3d92 100644 --- a/src/Common/MsgEngine/src/dummy/MsgStructDummy.h +++ b/src/Common/MsgEngine/src/dummy/MsgStructDummy.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -22,32 +22,32 @@ namespace Msg { - class MsgStructDummy - { - public: - inline MsgStructDummy(bool release); - inline virtual ~MsgStructDummy(); - inline void set(); - - MsgStructDummy(MsgStructDummy&) = delete; - MsgStructDummy &operator=(MsgStructDummy&) = delete; - - protected: - bool m_Release; - }; - - inline MsgStructDummy::MsgStructDummy(bool release) - : m_Release(release) - { - } - - inline MsgStructDummy::~MsgStructDummy() - { - } - - inline void MsgStructDummy::set() - { - } + class MsgStructDummy + { + public: + inline MsgStructDummy(bool release); + inline virtual ~MsgStructDummy(); + inline void set(); + + MsgStructDummy(MsgStructDummy&) = delete; + MsgStructDummy &operator=(MsgStructDummy&) = delete; + + protected: + bool m_Release; + }; + + inline MsgStructDummy::MsgStructDummy(bool release) + : m_Release(release) + { + } + + inline MsgStructDummy::~MsgStructDummy() + { + } + + inline void MsgStructDummy::set() + { + } } #endif /* _MsgStructDummy_H__ */ diff --git a/src/Common/MsgEngine/src/dummy/MsgThreadItemDummy.cpp b/src/Common/MsgEngine/src/dummy/MsgThreadItemDummy.cpp index d611424..c7244af 100644 --- a/src/Common/MsgEngine/src/dummy/MsgThreadItemDummy.cpp +++ b/src/Common/MsgEngine/src/dummy/MsgThreadItemDummy.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -24,8 +24,8 @@ using namespace Msg; MsgThreadItemDummy::MsgThreadItemDummy(bool release) - : MsgStructDummy(release) - , MsgThreadItem() + : MsgStructDummy(release) + , MsgThreadItem() { } @@ -35,42 +35,42 @@ MsgThreadItemDummy::~MsgThreadItemDummy() ThreadId MsgThreadItemDummy::getId() const { - int id = rand() % 60; - return id; + int id = rand() % 60; + return id; } std::string MsgThreadItemDummy::getName() const { - return fakeNames[rand() % fakeNames.size()]; + return fakeNames[rand() % fakeNames.size()]; } std::string MsgThreadItemDummy::getLastMessage() const { - return fakeMessages[rand() % fakeMessages.size()]; + return fakeMessages[rand() % fakeMessages.size()]; } time_t MsgThreadItemDummy::getTime() const { - return time(nullptr); + return time(nullptr); } bool MsgThreadItemDummy::hasDraftMessage() const { - return false; + return false; } bool MsgThreadItemDummy::hasFailedMessage() const { - return false; + return false; } bool MsgThreadItemDummy::isSending() const { - return false; + return false; } int MsgThreadItemDummy::getUnreadCount() const { - return 5; + return 5; } diff --git a/src/Common/MsgEngine/src/dummy/MsgThreadItemDummy.h b/src/Common/MsgEngine/src/dummy/MsgThreadItemDummy.h index 571f8fd..ac5b746 100644 --- a/src/Common/MsgEngine/src/dummy/MsgThreadItemDummy.h +++ b/src/Common/MsgEngine/src/dummy/MsgThreadItemDummy.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -24,25 +24,25 @@ namespace Msg { - class MsgThreadItemDummy - : public MsgStructDummy - , public MsgThreadItem - { - public: - MsgThreadItemDummy(bool release); - virtual ~MsgThreadItemDummy(); + class MsgThreadItemDummy + : public MsgStructDummy + , public MsgThreadItem + { + public: + MsgThreadItemDummy(bool release); + virtual ~MsgThreadItemDummy(); - virtual ThreadId getId() const; - virtual std::string getName() const; - virtual std::string getLastMessage() const; - virtual time_t getTime() const; - virtual bool hasDraftMessage() const; - virtual bool hasFailedMessage() const; - virtual bool isSending() const; - virtual int getUnreadCount() const; - }; + virtual ThreadId getId() const; + virtual std::string getName() const; + virtual std::string getLastMessage() const; + virtual time_t getTime() const; + virtual bool hasDraftMessage() const; + virtual bool hasFailedMessage() const; + virtual bool isSending() const; + virtual int getUnreadCount() const; + }; - typedef class MsgListDummy MsgThreadListDummy; + typedef class MsgListDummy MsgThreadListDummy; } #endif /* __MSG_THREAD_ITEM_H__ */ diff --git a/src/Common/MsgEngine/src/dummy/MsgTransportDummy.cpp b/src/Common/MsgEngine/src/dummy/MsgTransportDummy.cpp index b868a58..2e4dc9e 100644 --- a/src/Common/MsgEngine/src/dummy/MsgTransportDummy.cpp +++ b/src/Common/MsgEngine/src/dummy/MsgTransportDummy.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -23,7 +23,7 @@ using namespace Msg; MsgTransportDummy::MsgTransportDummy() - : MsgTransport() + : MsgTransport() { } @@ -33,15 +33,15 @@ MsgTransportDummy::~MsgTransportDummy() MsgTransport::SendResult MsgTransportDummy::sendMessage(Message &msg, ThreadId *threadId, RequestId *requestId) { - return SendSuccess; + return SendSuccess; } MsgTransport::SendResult MsgTransportDummy::retrieveMessage(MsgId msgId, RequestId *requestId) { - return SendSuccess; + return SendSuccess; } MsgTransport::SendResult MsgTransportDummy::sendReadReport(MsgId msgId, MsgReport::ReadStatus status) { - return SendSuccess; + return SendSuccess; } diff --git a/src/Common/MsgEngine/src/dummy/MsgTransportDummy.h b/src/Common/MsgEngine/src/dummy/MsgTransportDummy.h index f8db98f..3b281b4 100644 --- a/src/Common/MsgEngine/src/dummy/MsgTransportDummy.h +++ b/src/Common/MsgEngine/src/dummy/MsgTransportDummy.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -21,20 +21,20 @@ namespace Msg { - /** - * @brief Dummy msg-service API specific implementation of sending messages routine. - */ - class MsgTransportDummy - : public MsgTransport - { - public: - MsgTransportDummy(); - virtual ~MsgTransportDummy(); + /** + * @brief Dummy msg-service API specific implementation of sending messages routine. + */ + class MsgTransportDummy + : public MsgTransport + { + public: + MsgTransportDummy(); + virtual ~MsgTransportDummy(); - SendResult sendMessage(Message &msg, ThreadId *threadId, RequestId *requestId) override; - SendResult retrieveMessage(MsgId msgId, RequestId *requestId) override; - SendResult sendReadReport(MsgId msgId, MsgReport::ReadStatus status) override; - }; + SendResult sendMessage(Message &msg, ThreadId *threadId, RequestId *requestId) override; + SendResult retrieveMessage(MsgId msgId, RequestId *requestId) override; + SendResult sendReadReport(MsgId msgId, MsgReport::ReadStatus status) override; + }; } #endif /* _MSG_TRANSPORT_Dummy_H__ */ diff --git a/src/Common/MsgEngine/src/dummy/MsgUtilsDummy.cpp b/src/Common/MsgEngine/src/dummy/MsgUtilsDummy.cpp index 42f4db6..a7450ca 100644 --- a/src/Common/MsgEngine/src/dummy/MsgUtilsDummy.cpp +++ b/src/Common/MsgEngine/src/dummy/MsgUtilsDummy.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -21,118 +21,118 @@ using namespace Msg; int MsgUtilsDummy::directionToNative(Message::Direction direction) { - return 0; + return 0; } Message::Direction MsgUtilsDummy::nativeToDirection(int direction) { - return (Message::Direction)(rand() % 2); + return (Message::Direction)(rand() % 2); } Message::MessageStorageType MsgUtilsDummy::nativeToMessageStorage(int id) { - return Message::MS_Unknown; + return Message::MS_Unknown; } int MsgUtilsDummy::addressTypeToNative(MsgAddress::AddressType type) { - return 0; + return 0; } MsgAddress::AddressType MsgUtilsDummy::nativeToAddressType(int type) { - return MsgAddress::Phone; + return MsgAddress::Phone; } MsgReport::DeliveryStatus MsgUtilsDummy::nativeToReportDeliveryStatus(int status) { - return MsgReport::StatusNone; + return MsgReport::StatusNone; } MsgReport::ReadStatus MsgUtilsDummy::nativeToReportReadStatus(int status) { - return MsgReport::ReadStatusNone; + return MsgReport::ReadStatusNone; } int MsgUtilsDummy::reportReadReportStatusToNative(MsgReport::ReadStatus status) { - return 0; + return 0; } MsgReport::Type MsgUtilsDummy::nativeToReportType(int type) { - return MsgReport::TypeRead; + return MsgReport::TypeRead; } int MsgUtilsDummy::recipientTypeToNative(MsgAddress::RecipientType type) { - return 0; + return 0; } MsgAddress::RecipientType MsgUtilsDummy::nativeToRecipientType(int type) { - return MsgAddress::UnknownRecipientType; + return MsgAddress::UnknownRecipientType; } Message::Type MsgUtilsDummy::nativeToMessageType(int type) { - return Message::MT_Unknown; + return Message::MT_Unknown; } MsgMedia::Type MsgUtilsDummy::nativeToSmilType(int type) { - return MsgMedia::UnknownType; + return MsgMedia::UnknownType; } int MsgUtilsDummy::smilTypeToNative(MsgMedia::Type type) { - return 0; + return 0; } std::string MsgUtilsDummy::getStr() { - return std::string(); + return std::string(); } int MsgUtilsDummy::setStr() { - return 0; + return 0; } Message::NetworkStatus MsgUtilsDummy::nativeToNetworkStatus(int status) { - return Message::NS_Send_Success; + return Message::NS_Send_Success; } int MsgUtilsDummy::activeNotifPolicyToNative(MsgSettings::ActiveNotifPolicy policy) { - return 0; + return 0; } MsgTransport::SendResult MsgUtilsDummy::nativeToSendResult(int sendRes) { - return MsgTransport::SendSuccess; + return MsgTransport::SendSuccess; } MsgSettings::RingtoneType MsgUtilsDummy::nativeToRingtoneType(int type) { - return MsgSettings::DefaultRingtone; + return MsgSettings::DefaultRingtone; } int MsgUtilsDummy::ringtoneTypeToNative(MsgSettings::RingtoneType type) { - return 0; + return 0; } MsgStorage::StorageResult MsgUtilsDummy::nativeToStorageResult(int resultCode) { - MsgStorage::StorageResult res = MsgStorage::StorageSuccess; - switch (resultCode) - { - case 0: - res = MsgStorage::StorageSuccess; - break; - } - return res; + MsgStorage::StorageResult res = MsgStorage::StorageSuccess; + switch (resultCode) + { + case 0: + res = MsgStorage::StorageSuccess; + break; + } + return res; } diff --git a/src/Common/MsgEngine/src/dummy/MsgUtilsDummy.h b/src/Common/MsgEngine/src/dummy/MsgUtilsDummy.h index 7ad3f57..1a2f4f0 100644 --- a/src/Common/MsgEngine/src/dummy/MsgUtilsDummy.h +++ b/src/Common/MsgEngine/src/dummy/MsgUtilsDummy.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -30,33 +30,33 @@ namespace Msg { - class MsgUtilsDummy - { - public: - static int directionToNative(Message::Direction direction); - static int addressTypeToNative(MsgAddress::AddressType type); - static int recipientTypeToNative(MsgAddress::RecipientType type); - static Message::Direction nativeToDirection(int direction); - static Message::MessageStorageType nativeToMessageStorage(int id); - static MsgAddress::AddressType nativeToAddressType(int type); - static MsgAddress::RecipientType nativeToRecipientType(int type); - static MsgReport::DeliveryStatus nativeToReportDeliveryStatus(int status); - static MsgReport::ReadStatus nativeToReportReadStatus(int status); - static int reportReadReportStatusToNative(MsgReport::ReadStatus status); - static MsgReport::Type nativeToReportType(int type); - static Message::Type nativeToMessageType(int type); - static MsgMedia::Type nativeToSmilType(int type); - static int smilTypeToNative(MsgMedia::Type type); - static Message::NetworkStatus nativeToNetworkStatus(int status); - static int activeNotifPolicyToNative(MsgSettings::ActiveNotifPolicy policy); - static MsgTransport::SendResult nativeToSendResult(int sendRes); - static MsgSettings::RingtoneType nativeToRingtoneType(int type); - static int ringtoneTypeToNative(MsgSettings::RingtoneType type); - static MsgStorage::StorageResult nativeToStorageResult(int resultCode); + class MsgUtilsDummy + { + public: + static int directionToNative(Message::Direction direction); + static int addressTypeToNative(MsgAddress::AddressType type); + static int recipientTypeToNative(MsgAddress::RecipientType type); + static Message::Direction nativeToDirection(int direction); + static Message::MessageStorageType nativeToMessageStorage(int id); + static MsgAddress::AddressType nativeToAddressType(int type); + static MsgAddress::RecipientType nativeToRecipientType(int type); + static MsgReport::DeliveryStatus nativeToReportDeliveryStatus(int status); + static MsgReport::ReadStatus nativeToReportReadStatus(int status); + static int reportReadReportStatusToNative(MsgReport::ReadStatus status); + static MsgReport::Type nativeToReportType(int type); + static Message::Type nativeToMessageType(int type); + static MsgMedia::Type nativeToSmilType(int type); + static int smilTypeToNative(MsgMedia::Type type); + static Message::NetworkStatus nativeToNetworkStatus(int status); + static int activeNotifPolicyToNative(MsgSettings::ActiveNotifPolicy policy); + static MsgTransport::SendResult nativeToSendResult(int sendRes); + static MsgSettings::RingtoneType nativeToRingtoneType(int type); + static int ringtoneTypeToNative(MsgSettings::RingtoneType type); + static MsgStorage::StorageResult nativeToStorageResult(int resultCode); - static std::string getStr(); - static int setStr(); - }; + static std::string getStr(); + static int setStr(); + }; } #endif /* _MESSAGE_UTILS_Dummy_H__ */ diff --git a/src/Common/MsgEngine/src/private/MessageMmsPrivate.cpp b/src/Common/MsgEngine/src/private/MessageMmsPrivate.cpp index 0f59112..7962654 100644 --- a/src/Common/MsgEngine/src/private/MessageMmsPrivate.cpp +++ b/src/Common/MsgEngine/src/private/MessageMmsPrivate.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -23,137 +23,137 @@ using namespace Msg; MessageMmsPrivate::MessageMmsPrivate(bool release, msg_struct_t msgStruct, msg_struct_t mmsStruct) - : MessagePrivate(release, msgStruct) - , MessageMms() - , m_MmsStruct(mmsStruct) - , m_PageList(false) - , m_AttachmentList(false) - , m_Page(false) - , m_Attachment(false) + : MessagePrivate(release, msgStruct) + , MessageMms() + , m_MmsStruct(mmsStruct) + , m_PageList(false) + , m_AttachmentList(false) + , m_Page(false) + , m_Attachment(false) { - if (!m_MmsStruct) { - m_MmsStruct = msg_create_struct(MSG_STRUCT_MMS); - if (msgStruct) - msg_get_mms_struct(m_MsgStruct, m_MmsStruct); - } + if (!m_MmsStruct) { + m_MmsStruct = msg_create_struct(MSG_STRUCT_MMS); + if (msgStruct) + msg_get_mms_struct(m_MsgStruct, m_MmsStruct); + } } void MessageMmsPrivate::set(msg_struct_t msgStruct) { - MessagePrivate::set(msgStruct); - msg_get_mms_struct(m_MsgStruct, m_MmsStruct); + MessagePrivate::set(msgStruct); + msg_get_mms_struct(m_MsgStruct, m_MmsStruct); } void MessageMmsPrivate::commit() { - msg_set_mms_struct(m_MsgStruct, m_MmsStruct); + msg_set_mms_struct(m_MsgStruct, m_MmsStruct); } msg_struct_t MessageMmsPrivate::getMmsStruct() const { - return m_MmsStruct; + return m_MmsStruct; } MessageMmsPrivate::~MessageMmsPrivate() { - if (m_MmsStruct) - msg_release_struct(&m_MmsStruct); + if (m_MmsStruct) + msg_release_struct(&m_MmsStruct); } MessageMmsPrivate::Type MessageMmsPrivate::getType() const { - int nativeType = MSG_TYPE_INVALID; - msg_get_int_value(m_MsgStruct, MSG_MESSAGE_TYPE_INT, &nativeType); - return MsgUtilsPrivate::nativeToMessageType(nativeType); + int nativeType = MSG_TYPE_INVALID; + msg_get_int_value(m_MsgStruct, MSG_MESSAGE_TYPE_INT, &nativeType); + return MsgUtilsPrivate::nativeToMessageType(nativeType); } std::string MessageMmsPrivate::getText() const { - const MsgPageList &pageList = getPageList(); - std::string result; - int size = pageList.getLength(); - - 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) { - if (mediaList[j].getType() == MsgMedia::TextType) { - std::string str = FileUtils::readTextFile(mediaList[j].getFilePath()); - if (!str.empty()) { - if (i > 0 && !result.empty()) - result.append("\n"); - - result += std::move(str); - } - } - } - } - return result; + const MsgPageList &pageList = getPageList(); + std::string result; + int size = pageList.getLength(); + + 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) { + if (mediaList[j].getType() == MsgMedia::TextType) { + std::string str = FileUtils::readTextFile(mediaList[j].getFilePath()); + if (!str.empty()) { + if (i > 0 && !result.empty()) + result.append("\n"); + + result += std::move(str); + } + } + } + } + return result; } int MessageMmsPrivate::getMediaCount() const { - const MsgPageList &pageList = getPageList(); - int result = 0; - - int size = pageList.getLength(); - 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) { - if (mediaList[j].getType() != MsgMedia::TextType && mediaList[j].getType() != MsgMedia::UnknownType) - ++result; - } - } - return result; + const MsgPageList &pageList = getPageList(); + int result = 0; + + int size = pageList.getLength(); + 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) { + if (mediaList[j].getType() != MsgMedia::TextType && mediaList[j].getType() != MsgMedia::UnknownType) + ++result; + } + } + return result; } const MsgPageListHandlePrivate &MessageMmsPrivate::getPageList() const { - msg_list_handle_t list = nullptr; - msg_get_list_handle(m_MmsStruct, MSG_MMS_PAGE_LIST_HND, (void **)&list); - m_PageList.set(list); - return m_PageList; + msg_list_handle_t list = nullptr; + msg_get_list_handle(m_MmsStruct, MSG_MMS_PAGE_LIST_HND, (void **)&list); + m_PageList.set(list); + return m_PageList; } MsgPagePrivate &MessageMmsPrivate::addPage() { - msg_struct_t page = nullptr; - msg_list_add_item(m_MmsStruct, MSG_STRUCT_MMS_PAGE, &page); - m_Page.set(page); - return m_Page; + msg_struct_t page = nullptr; + msg_list_add_item(m_MmsStruct, MSG_STRUCT_MMS_PAGE, &page); + m_Page.set(page); + return m_Page; } const MsgAttachmentListHandlePrivate &MessageMmsPrivate::getAttachmentList() const { - msg_list_handle_t list = nullptr; - msg_get_list_handle(m_MmsStruct, MSG_MMS_ATTACH_LIST_HND, (void **)&list); - m_AttachmentList.set(list); - return m_AttachmentList; + msg_list_handle_t list = nullptr; + msg_get_list_handle(m_MmsStruct, MSG_MMS_ATTACH_LIST_HND, (void **)&list); + m_AttachmentList.set(list); + return m_AttachmentList; } MsgAttachmentPrivate &MessageMmsPrivate::addAttachment() { - msg_struct_t attach = nullptr; - msg_list_add_item(m_MmsStruct, MSG_STRUCT_MMS_ATTACH, &attach); - m_Attachment.set(attach); - return m_Attachment; + msg_struct_t attach = nullptr; + msg_list_add_item(m_MmsStruct, MSG_STRUCT_MMS_ATTACH, &attach); + m_Attachment.set(attach); + return m_Attachment; } time_t MessageMmsPrivate::getExpired() const { - int msgExpiry = 0; - msg_get_int_value(m_MmsStruct, MSG_MMS_HEADER_EXPIRY_TIME_INT, &msgExpiry); - return msgExpiry; + int msgExpiry = 0; + msg_get_int_value(m_MmsStruct, MSG_MMS_HEADER_EXPIRY_TIME_INT, &msgExpiry); + return msgExpiry; } int MessageMmsPrivate::getSize() const { - 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) - msgSize = MessagePrivate::getSize(); - return msgSize; + 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) + msgSize = MessagePrivate::getSize(); + return msgSize; } diff --git a/src/Common/MsgEngine/src/private/MessageMmsPrivate.h b/src/Common/MsgEngine/src/private/MessageMmsPrivate.h index ca996e7..c4af467 100644 --- a/src/Common/MsgEngine/src/private/MessageMmsPrivate.h +++ b/src/Common/MsgEngine/src/private/MessageMmsPrivate.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -23,39 +23,39 @@ #include "MsgAttachmentPrivate.h" namespace Msg { - class MessageMmsPrivate - : public MessagePrivate - , public MessageMms { - public: - MessageMmsPrivate(bool release, msg_struct_t msgStruct = nullptr, msg_struct_t mmsStruct = nullptr); - virtual ~MessageMmsPrivate(); - - virtual std::string getText() const; - virtual Type getType() const; - virtual int getSize() const; - - virtual const MsgPageListHandlePrivate &getPageList() const; - virtual MsgPagePrivate &addPage(); - - virtual const MsgAttachmentListHandlePrivate &getAttachmentList() const; - virtual MsgAttachmentPrivate &addAttachment(); - virtual time_t getExpired() const; - - virtual void commit(); - int getMediaCount() const; - void set(msg_struct_t msgStruct); - msg_struct_t getMmsStruct() const; - - private: - msg_struct_t m_MmsStruct; - mutable MsgPageListHandlePrivate m_PageList; - mutable MsgAttachmentListHandlePrivate m_AttachmentList; - MsgPagePrivate m_Page; - MsgAttachmentPrivate m_Attachment; - }; - - typedef class MsgListHandlePrivate MmsListHandlePrivate; - typedef class MsgStructListPrivate MmsStructListPrivate; + class MessageMmsPrivate + : public MessagePrivate + , public MessageMms { + public: + MessageMmsPrivate(bool release, msg_struct_t msgStruct = nullptr, msg_struct_t mmsStruct = nullptr); + virtual ~MessageMmsPrivate(); + + virtual std::string getText() const; + virtual Type getType() const; + virtual int getSize() const; + + virtual const MsgPageListHandlePrivate &getPageList() const; + virtual MsgPagePrivate &addPage(); + + virtual const MsgAttachmentListHandlePrivate &getAttachmentList() const; + virtual MsgAttachmentPrivate &addAttachment(); + virtual time_t getExpired() const; + + virtual void commit(); + int getMediaCount() const; + void set(msg_struct_t msgStruct); + msg_struct_t getMmsStruct() const; + + private: + msg_struct_t m_MmsStruct; + mutable MsgPageListHandlePrivate m_PageList; + mutable MsgAttachmentListHandlePrivate m_AttachmentList; + MsgPagePrivate m_Page; + MsgAttachmentPrivate m_Attachment; + }; + + typedef class MsgListHandlePrivate MmsListHandlePrivate; + typedef class MsgStructListPrivate MmsStructListPrivate; } #endif /* _MESSAGE_MMS_PRIVATE_H__ */ diff --git a/src/Common/MsgEngine/src/private/MessagePrivate.cpp b/src/Common/MsgEngine/src/private/MessagePrivate.cpp index 283fff9..ac1b4d9 100644 --- a/src/Common/MsgEngine/src/private/MessagePrivate.cpp +++ b/src/Common/MsgEngine/src/private/MessagePrivate.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -26,10 +26,10 @@ using namespace Msg; MessagePrivate::MessagePrivate(bool release, msg_struct_t msgStruct) - : Message() - , MsgStructPrivate(release, msgStruct) - , m_Address(false) - , m_AddressList(false) + : Message() + , MsgStructPrivate(release, msgStruct) + , m_Address(false) + , m_AddressList(false) { } @@ -39,125 +39,125 @@ MessagePrivate::~MessagePrivate() void MessagePrivate::set(msg_struct_t msgStruct) { - MsgStructPrivate::set(msgStruct); + MsgStructPrivate::set(msgStruct); } const MsgAddressListHandlePrivate &MessagePrivate::getAddressList() const { - msg_list_handle_t addrList = nullptr; - msg_get_list_handle(m_MsgStruct, MSG_MESSAGE_ADDR_LIST_HND, (void **)&addrList); - m_AddressList.set(addrList); - return m_AddressList; + msg_list_handle_t addrList = nullptr; + msg_get_list_handle(m_MsgStruct, MSG_MESSAGE_ADDR_LIST_HND, (void **)&addrList); + m_AddressList.set(addrList); + return m_AddressList; } MsgAddressPrivate &MessagePrivate::addAddress() { - msg_struct_t addr = nullptr; - msg_list_add_item(m_MsgStruct, MSG_MESSAGE_ADDR_LIST_HND, &addr); - m_Address.set(addr); - return m_Address; + msg_struct_t addr = nullptr; + msg_list_add_item(m_MsgStruct, MSG_MESSAGE_ADDR_LIST_HND, &addr); + m_Address.set(addr); + return m_Address; } void MessagePrivate::addAddresses(const MsgAddressList &list) { - int len = list.getLength(); - for (int i = 0; i < len; ++i) { - MsgAddressPrivate &newAddr = MessagePrivate::addAddress(); - newAddr.setFields(list[i]); - } + int len = list.getLength(); + for (int i = 0; i < len; ++i) { + MsgAddressPrivate &newAddr = MessagePrivate::addAddress(); + newAddr.setFields(list[i]); + } } MsgId MessagePrivate::getId() const { - int id = MsgId::invalidId; - msg_get_int_value(m_MsgStruct, MSG_MESSAGE_ID_INT, &id); - return id; + int id = MsgId::invalidId; + msg_get_int_value(m_MsgStruct, MSG_MESSAGE_ID_INT, &id); + return id; } void MessagePrivate::setId(MsgId id) { - msg_set_int_value(m_MsgStruct, MSG_MESSAGE_ID_INT, id); + msg_set_int_value(m_MsgStruct, MSG_MESSAGE_ID_INT, id); } ThreadId MessagePrivate::getThreadId() const { - int threadId = ThreadId::invalidId; - msg_get_int_value(m_MsgStruct, MSG_MESSAGE_THREAD_ID_INT, &threadId); - return threadId; + int threadId = ThreadId::invalidId; + msg_get_int_value(m_MsgStruct, MSG_MESSAGE_THREAD_ID_INT, &threadId); + return threadId; } time_t MessagePrivate::getTime() const { - int time = 0; - msg_get_int_value(m_MsgStruct, MSG_MESSAGE_DISPLAY_TIME_INT, &time); - return time; + int time = 0; + msg_get_int_value(m_MsgStruct, MSG_MESSAGE_DISPLAY_TIME_INT, &time); + return time; } std::string MessagePrivate::getText() const { - 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); + 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); } Message::Direction MessagePrivate::getDirection() const { - int direction = 0; - msg_get_int_value(m_MsgStruct, MSG_MESSAGE_DIRECTION_INT, &direction); - return MsgUtilsPrivate::nativeToDirection(direction); + int direction = 0; + msg_get_int_value(m_MsgStruct, MSG_MESSAGE_DIRECTION_INT, &direction); + return MsgUtilsPrivate::nativeToDirection(direction); } Message::Type MessagePrivate::getType() const { - return MT_Unknown; + return MT_Unknown; } MessagePrivate::NetworkStatus MessagePrivate::getNetworkStatus() const { - int status = 0; - int err = msg_get_int_value(m_MsgStruct, MSG_MESSAGE_NETWORK_STATUS_INT, &status); - return err == 0 ? MsgUtilsPrivate::nativeToNetworkStatus(status) : NS_Unknown; + int status = 0; + int err = msg_get_int_value(m_MsgStruct, MSG_MESSAGE_NETWORK_STATUS_INT, &status); + return err == 0 ? MsgUtilsPrivate::nativeToNetworkStatus(status) : NS_Unknown; } int MessagePrivate::getSize() const { - int msgSize = 0; - msg_get_int_value(m_MsgStruct, MSG_MESSAGE_DATA_SIZE_INT, &msgSize); // Size in bytes - return msgSize; + int msgSize = 0; + msg_get_int_value(m_MsgStruct, MSG_MESSAGE_DATA_SIZE_INT, &msgSize); // Size in bytes + return msgSize; } std::string MessagePrivate::getSubject() const { - return MsgUtilsPrivate::getStr(m_MsgStruct, MSG_MESSAGE_SUBJECT_STR, MAX_SUBJECT_LEN); + return MsgUtilsPrivate::getStr(m_MsgStruct, MSG_MESSAGE_SUBJECT_STR, MAX_SUBJECT_LEN); } void MessagePrivate::setSubject(const std::string &text) { - MsgUtilsPrivate::setStr(m_MsgStruct, MSG_MESSAGE_SUBJECT_STR, text); + MsgUtilsPrivate::setStr(m_MsgStruct, MSG_MESSAGE_SUBJECT_STR, text); } void MessagePrivate::setMessageStorageType(Message::MessageStorageType msgStorage) { - switch (msgStorage) { - case Message::MS_Phone: - msg_set_int_value(m_MsgStruct, MSG_MESSAGE_STORAGE_ID_INT, MSG_STORAGE_PHONE); - break; - case Message::MS_Sim: - msg_set_int_value(m_MsgStruct, MSG_MESSAGE_STORAGE_ID_INT, MSG_STORAGE_SIM); - break; - case Message::MS_Unknown: - default: - MSG_LOG_ERROR("Unknown storage type!") - break; - } + switch (msgStorage) { + case Message::MS_Phone: + msg_set_int_value(m_MsgStruct, MSG_MESSAGE_STORAGE_ID_INT, MSG_STORAGE_PHONE); + break; + case Message::MS_Sim: + msg_set_int_value(m_MsgStruct, MSG_MESSAGE_STORAGE_ID_INT, MSG_STORAGE_SIM); + break; + case Message::MS_Unknown: + default: + MSG_LOG_ERROR("Unknown storage type!") + break; + } } Message::MessageStorageType MessagePrivate::getMessageStorageType() const { - int id = -1; - msg_get_int_value(m_MsgStruct, MSG_MESSAGE_STORAGE_ID_INT, &id); - return MsgUtilsPrivate::nativeToMessageStorage(id); + int id = -1; + msg_get_int_value(m_MsgStruct, MSG_MESSAGE_STORAGE_ID_INT, &id); + return MsgUtilsPrivate::nativeToMessageStorage(id); } void MessagePrivate::commit() @@ -166,15 +166,15 @@ void MessagePrivate::commit() bool MessagePrivate::isMms() const { - int nativeType = MSG_TYPE_INVALID; - msg_get_int_value(m_MsgStruct, MSG_MESSAGE_TYPE_INT, &nativeType); - Message::Type messageType = MsgUtilsPrivate::nativeToMessageType(nativeType); - return MsgUtils::isMms(messageType); + int nativeType = MSG_TYPE_INVALID; + msg_get_int_value(m_MsgStruct, MSG_MESSAGE_TYPE_INT, &nativeType); + Message::Type messageType = MsgUtilsPrivate::nativeToMessageType(nativeType); + return MsgUtils::isMms(messageType); } bool MessagePrivate::isRestrictedByDpm() const { - bool restricted = false; - msg_get_bool_value(m_MsgStruct, MSG_MESSAGE_DPM_RESTRICTED_BOOL, &restricted); - return restricted; + bool restricted = false; + msg_get_bool_value(m_MsgStruct, MSG_MESSAGE_DPM_RESTRICTED_BOOL, &restricted); + return restricted; } diff --git a/src/Common/MsgEngine/src/private/MessagePrivate.h b/src/Common/MsgEngine/src/private/MessagePrivate.h index fd5c260..9c2bf6c 100644 --- a/src/Common/MsgEngine/src/private/MessagePrivate.h +++ b/src/Common/MsgEngine/src/private/MessagePrivate.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -24,43 +24,43 @@ #include namespace Msg { - class MessagePrivate - : public virtual Message - , public MsgStructPrivate { - public: - MessagePrivate(bool release, msg_struct_t msgStruct = nullptr); - virtual ~MessagePrivate(); + class MessagePrivate + : public virtual Message + , public MsgStructPrivate { + public: + MessagePrivate(bool release, msg_struct_t msgStruct = nullptr); + virtual ~MessagePrivate(); - virtual MsgId getId() const; - virtual ThreadId getThreadId() const; - virtual time_t getTime() const; - virtual const MsgAddressListHandlePrivate &getAddressList() const; - virtual MsgAddressPrivate &addAddress(); - virtual void addAddresses(const MsgAddressList &list); - virtual std::string getText() const; - Message::Direction getDirection() const; - virtual Type getType() const; - virtual NetworkStatus getNetworkStatus() const; + virtual MsgId getId() const; + virtual ThreadId getThreadId() const; + virtual time_t getTime() const; + virtual const MsgAddressListHandlePrivate &getAddressList() const; + virtual MsgAddressPrivate &addAddress(); + virtual void addAddresses(const MsgAddressList &list); + virtual std::string getText() const; + Message::Direction getDirection() const; + virtual Type getType() const; + virtual NetworkStatus getNetworkStatus() const; - virtual int getSize() const; - virtual std::string getSubject() const; - virtual void setSubject(const std::string &text); - virtual void setMessageStorageType(Message::MessageStorageType msgStorage); - virtual Message::MessageStorageType getMessageStorageType() const; - virtual bool isMms() const; - virtual bool isRestrictedByDpm() const; + virtual int getSize() const; + virtual std::string getSubject() const; + virtual void setSubject(const std::string &text); + virtual void setMessageStorageType(Message::MessageStorageType msgStorage); + virtual Message::MessageStorageType getMessageStorageType() const; + virtual bool isMms() const; + virtual bool isRestrictedByDpm() const; - void setId(MsgId id); - void set(msg_struct_t msgStruct); - virtual void commit(); + void setId(MsgId id); + void set(msg_struct_t msgStruct); + virtual void commit(); - protected: - mutable MsgAddressPrivate m_Address; - mutable MsgAddressListHandlePrivate m_AddressList; - }; + protected: + mutable MsgAddressPrivate m_Address; + mutable MsgAddressListHandlePrivate m_AddressList; + }; - typedef class MsgListHandlePrivate MessageListHandlePrivate; - typedef class MsgStructListPrivate MessageStructListPrivate; + typedef class MsgListHandlePrivate MessageListHandlePrivate; + typedef class MsgStructListPrivate MessageStructListPrivate; } #endif /* _MESSAGE_PRIVATE_H__ */ diff --git a/src/Common/MsgEngine/src/private/MessageSMSPrivate.cpp b/src/Common/MsgEngine/src/private/MessageSMSPrivate.cpp index 8aabfad..aaa1466 100644 --- a/src/Common/MsgEngine/src/private/MessageSMSPrivate.cpp +++ b/src/Common/MsgEngine/src/private/MessageSMSPrivate.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -28,8 +28,8 @@ using namespace Msg; MessageSMSPrivate::MessageSMSPrivate(bool release, msg_struct_t msgStruct) - : MessagePrivate(release, msgStruct) - , MessageSMS() + : MessagePrivate(release, msgStruct) + , MessageSMS() { } @@ -39,15 +39,15 @@ MessageSMSPrivate::~MessageSMSPrivate() MessageSMSPrivate::Type MessageSMSPrivate::getType() const { - return MT_SMS; + return MT_SMS; } void MessageSMSPrivate::setText(const std::string &text) { - msg_set_str_value(m_MsgStruct, MSG_MESSAGE_SMS_DATA_STR, text.c_str(), text.length()); + msg_set_str_value(m_MsgStruct, MSG_MESSAGE_SMS_DATA_STR, text.c_str(), text.length()); } std::string MessageSMSPrivate::getText() const { - return MsgUtilsPrivate::getStr(m_MsgStruct, MSG_MESSAGE_SMS_DATA_STR, MAX_MSG_DATA_LEN); + return MsgUtilsPrivate::getStr(m_MsgStruct, MSG_MESSAGE_SMS_DATA_STR, MAX_MSG_DATA_LEN); } diff --git a/src/Common/MsgEngine/src/private/MessageSMSPrivate.h b/src/Common/MsgEngine/src/private/MessageSMSPrivate.h index 7561fb8..3770ad2 100644 --- a/src/Common/MsgEngine/src/private/MessageSMSPrivate.h +++ b/src/Common/MsgEngine/src/private/MessageSMSPrivate.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -23,20 +23,20 @@ #include "MsgStructListPrivate.h" namespace Msg { - class MessageSMSPrivate - : public MessagePrivate - , public MessageSMS { - public: - MessageSMSPrivate(bool release, msg_struct_t msgStruct = nullptr); - virtual ~MessageSMSPrivate(); + class MessageSMSPrivate + : public MessagePrivate + , public MessageSMS { + public: + MessageSMSPrivate(bool release, msg_struct_t msgStruct = nullptr); + virtual ~MessageSMSPrivate(); - virtual Type getType() const; - virtual void setText(const std::string &text); - virtual std::string getText() const; - }; + virtual Type getType() const; + virtual void setText(const std::string &text); + virtual std::string getText() const; + }; - typedef class MsgListHandlePrivate SmsListHandlePrivate; - typedef class MsgStructListPrivate SmsStructListPrivate; + typedef class MsgListHandlePrivate SmsListHandlePrivate; + typedef class MsgStructListPrivate SmsStructListPrivate; } #endif /* _MESSAGE_SMS_PRIVATE_H__ */ diff --git a/src/Common/MsgEngine/src/private/MsgAddressPrivate.cpp b/src/Common/MsgEngine/src/private/MsgAddressPrivate.cpp index 88a2a14..f28a886 100644 --- a/src/Common/MsgEngine/src/private/MsgAddressPrivate.cpp +++ b/src/Common/MsgEngine/src/private/MsgAddressPrivate.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -22,8 +22,8 @@ using namespace Msg; MsgAddressPrivate::MsgAddressPrivate(bool release, msg_struct_t msgStruct) - : MsgStructPrivate(release, msgStruct) - , MsgAddress() + : MsgStructPrivate(release, msgStruct) + , MsgAddress() { } @@ -33,41 +33,41 @@ MsgAddressPrivate::~MsgAddressPrivate() std::string MsgAddressPrivate::getAddress() const { - return MsgUtilsPrivate::getStr(m_MsgStruct, MSG_ADDRESS_INFO_ADDRESS_VALUE_STR, MAX_ADDRESS_VAL_LEN); + return MsgUtilsPrivate::getStr(m_MsgStruct, MSG_ADDRESS_INFO_ADDRESS_VALUE_STR, MAX_ADDRESS_VAL_LEN); } MsgAddressPrivate::AddressType MsgAddressPrivate::getAddressType() const { - int nativeType = MSG_ADDRESS_TYPE_UNKNOWN; - msg_get_int_value(m_MsgStruct, MSG_ADDRESS_INFO_ADDRESS_TYPE_INT, &nativeType); - return MsgUtilsPrivate::nativeToAddressType(nativeType); + int nativeType = MSG_ADDRESS_TYPE_UNKNOWN; + msg_get_int_value(m_MsgStruct, MSG_ADDRESS_INFO_ADDRESS_TYPE_INT, &nativeType); + return MsgUtilsPrivate::nativeToAddressType(nativeType); } MsgAddressPrivate::RecipientType MsgAddressPrivate::getRecipientType() const { - int nativeType = MSG_RECIPIENTS_TYPE_UNKNOWN; - msg_get_int_value(m_MsgStruct, MSG_ADDRESS_INFO_RECIPIENT_TYPE_INT, &nativeType); - return MsgUtilsPrivate::nativeToRecipientType(nativeType); + int nativeType = MSG_RECIPIENTS_TYPE_UNKNOWN; + msg_get_int_value(m_MsgStruct, MSG_ADDRESS_INFO_RECIPIENT_TYPE_INT, &nativeType); + return MsgUtilsPrivate::nativeToRecipientType(nativeType); } void MsgAddressPrivate::setAddress(const std::string &address) { - msg_set_str_value(m_MsgStruct, MSG_ADDRESS_INFO_ADDRESS_VALUE_STR, address.c_str(), address.length()); + msg_set_str_value(m_MsgStruct, MSG_ADDRESS_INFO_ADDRESS_VALUE_STR, address.c_str(), address.length()); } void MsgAddressPrivate::setAddressType(AddressType type) { - msg_set_int_value(m_MsgStruct, MSG_ADDRESS_INFO_ADDRESS_TYPE_INT, MsgUtilsPrivate::addressTypeToNative(type)); + msg_set_int_value(m_MsgStruct, MSG_ADDRESS_INFO_ADDRESS_TYPE_INT, MsgUtilsPrivate::addressTypeToNative(type)); } void MsgAddressPrivate::setRecipientType(RecipientType type) { - msg_set_int_value(m_MsgStruct, MSG_ADDRESS_INFO_RECIPIENT_TYPE_INT, MsgUtilsPrivate::recipientTypeToNative(type)); + msg_set_int_value(m_MsgStruct, MSG_ADDRESS_INFO_RECIPIENT_TYPE_INT, MsgUtilsPrivate::recipientTypeToNative(type)); } void MsgAddressPrivate::setFields(const MsgAddress &addr) { - setAddress(addr.getAddress()); - setAddressType(addr.getAddressType()); - setRecipientType(addr.getRecipientType()); + setAddress(addr.getAddress()); + setAddressType(addr.getAddressType()); + setRecipientType(addr.getRecipientType()); } diff --git a/src/Common/MsgEngine/src/private/MsgAddressPrivate.h b/src/Common/MsgEngine/src/private/MsgAddressPrivate.h index dc593c6..4d71c45 100644 --- a/src/Common/MsgEngine/src/private/MsgAddressPrivate.h +++ b/src/Common/MsgEngine/src/private/MsgAddressPrivate.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -23,26 +23,26 @@ #include "MsgStructPrivate.h" namespace Msg { - class MsgAddressPrivate - : public MsgStructPrivate - , public MsgAddress { - public: - MsgAddressPrivate(bool release, msg_struct_t msgStruct = nullptr); - virtual ~MsgAddressPrivate(); - - virtual std::string getAddress() const; - virtual AddressType getAddressType() const; - virtual RecipientType getRecipientType() const; - - virtual void setAddress(const std::string &address); - virtual void setAddressType(AddressType type); - virtual void setRecipientType(RecipientType type); - - void setFields(const MsgAddress &addr); - }; - - typedef class MsgListHandlePrivate MsgAddressListHandlePrivate; - typedef class MsgStructListPrivate MsgAddressStructListPrivate; + class MsgAddressPrivate + : public MsgStructPrivate + , public MsgAddress { + public: + MsgAddressPrivate(bool release, msg_struct_t msgStruct = nullptr); + virtual ~MsgAddressPrivate(); + + virtual std::string getAddress() const; + virtual AddressType getAddressType() const; + virtual RecipientType getRecipientType() const; + + virtual void setAddress(const std::string &address); + virtual void setAddressType(AddressType type); + virtual void setRecipientType(RecipientType type); + + void setFields(const MsgAddress &addr); + }; + + typedef class MsgListHandlePrivate MsgAddressListHandlePrivate; + typedef class MsgStructListPrivate MsgAddressStructListPrivate; } #endif /* MsgAddressPrivate_h_ */ diff --git a/src/Common/MsgEngine/src/private/MsgAttachmentPrivate.cpp b/src/Common/MsgEngine/src/private/MsgAttachmentPrivate.cpp index 63673b6..8c01ac7 100644 --- a/src/Common/MsgEngine/src/private/MsgAttachmentPrivate.cpp +++ b/src/Common/MsgEngine/src/private/MsgAttachmentPrivate.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -22,8 +22,8 @@ using namespace Msg; MsgAttachmentPrivate::MsgAttachmentPrivate(bool release, msg_struct_t msgStruct) - : MsgStructPrivate(release, msgStruct) - , MsgAttachment() + : MsgStructPrivate(release, msgStruct) + , MsgAttachment() { } @@ -33,54 +33,54 @@ MsgAttachmentPrivate::~MsgAttachmentPrivate() std::string MsgAttachmentPrivate::getFilePath() const { - return MsgUtilsPrivate::getStr(m_MsgStruct, MSG_MMS_ATTACH_FILEPATH_STR, MSG_FILEPATH_LEN_MAX); + return MsgUtilsPrivate::getStr(m_MsgStruct, MSG_MMS_ATTACH_FILEPATH_STR, MSG_FILEPATH_LEN_MAX); } std::string MsgAttachmentPrivate::getFileName() const { - return MsgUtilsPrivate::getStr(m_MsgStruct, MSG_MMS_ATTACH_FILENAME_STR, MSG_FILENAME_LEN_MAX); + return MsgUtilsPrivate::getStr(m_MsgStruct, MSG_MMS_ATTACH_FILENAME_STR, MSG_FILENAME_LEN_MAX); } int MsgAttachmentPrivate::getFileSize() const { - int size = 0; - msg_get_int_value(m_MsgStruct, MSG_MMS_ATTACH_FILESIZE_INT, &size); + int size = 0; + msg_get_int_value(m_MsgStruct, MSG_MMS_ATTACH_FILESIZE_INT, &size); - if (size == 0) { - MSG_LOG_WARN("File ", getFilePath(), " size = 0, trying to get real file size"); - size = (int)FileUtils::getFileSize(getFilePath()); - MSG_LOG("Real file size = ", size); - } + if (size == 0) { + MSG_LOG_WARN("File ", getFilePath(), " size = 0, trying to get real file size"); + size = (int)FileUtils::getFileSize(getFilePath()); + MSG_LOG("Real file size = ", size); + } - return size; + return size; } std::string MsgAttachmentPrivate::getMime() const { - return MsgUtilsPrivate::getStr(m_MsgStruct, MSG_MMS_ATTACH_CONTENT_TYPE_STR, MAX_MIME_TYPE_LEN); + return MsgUtilsPrivate::getStr(m_MsgStruct, MSG_MMS_ATTACH_CONTENT_TYPE_STR, MAX_MIME_TYPE_LEN); } void MsgAttachmentPrivate::setFilePath(const std::string &path) { - MsgUtilsPrivate::setStr(m_MsgStruct, MSG_MMS_ATTACH_FILEPATH_STR, path); - setFileName(FileUtils::getFileName(path)); - setFileSize(FileUtils::getFileSize(path)); - setMime(FileUtils::getMimeType(path)); + MsgUtilsPrivate::setStr(m_MsgStruct, MSG_MMS_ATTACH_FILEPATH_STR, path); + setFileName(FileUtils::getFileName(path)); + setFileSize(FileUtils::getFileSize(path)); + setMime(FileUtils::getMimeType(path)); } void MsgAttachmentPrivate::setFileName(const std::string &fileName) { - MsgUtilsPrivate::setStr(m_MsgStruct, MSG_MMS_ATTACH_FILENAME_STR, fileName); + MsgUtilsPrivate::setStr(m_MsgStruct, MSG_MMS_ATTACH_FILENAME_STR, fileName); } void MsgAttachmentPrivate::setFileSize(int size) const { - msg_set_int_value(m_MsgStruct, MSG_MMS_ATTACH_FILESIZE_INT, size); + msg_set_int_value(m_MsgStruct, MSG_MMS_ATTACH_FILESIZE_INT, size); } void MsgAttachmentPrivate::setMime(const std::string &mime) { - MsgUtilsPrivate::setStr(m_MsgStruct, MSG_MMS_ATTACH_CONTENT_TYPE_STR, mime); + MsgUtilsPrivate::setStr(m_MsgStruct, MSG_MMS_ATTACH_CONTENT_TYPE_STR, mime); } diff --git a/src/Common/MsgEngine/src/private/MsgAttachmentPrivate.h b/src/Common/MsgEngine/src/private/MsgAttachmentPrivate.h index 3ed3814..f493abc 100644 --- a/src/Common/MsgEngine/src/private/MsgAttachmentPrivate.h +++ b/src/Common/MsgEngine/src/private/MsgAttachmentPrivate.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -23,26 +23,26 @@ #include "MsgStructListPrivate.h" namespace Msg { - class MsgAttachmentPrivate - : public MsgStructPrivate - , public MsgAttachment { - public: - MsgAttachmentPrivate(bool release, msg_struct_t msgStruct = nullptr); - virtual ~MsgAttachmentPrivate(); + class MsgAttachmentPrivate + : public MsgStructPrivate + , public MsgAttachment { + public: + MsgAttachmentPrivate(bool release, msg_struct_t msgStruct = nullptr); + virtual ~MsgAttachmentPrivate(); - virtual std::string getFilePath() const; - virtual std::string getFileName() const; - virtual int getFileSize() const; - virtual std::string getMime() const; + virtual std::string getFilePath() const; + virtual std::string getFileName() const; + virtual int getFileSize() const; + virtual std::string getMime() const; - virtual void setFilePath(const std::string &path); - void setFileName(const std::string &fileName); - void setFileSize(int size) const; - void setMime(const std::string &mime); - }; + virtual void setFilePath(const std::string &path); + void setFileName(const std::string &fileName); + void setFileSize(int size) const; + void setMime(const std::string &mime); + }; - typedef class MsgListHandlePrivate MsgAttachmentListHandlePrivate; - typedef class MsgStructListPrivate MsgAttachmentStructListPrivate; + typedef class MsgListHandlePrivate MsgAttachmentListHandlePrivate; + typedef class MsgStructListPrivate MsgAttachmentStructListPrivate; } #endif /* _MSG_ATTACHMENT_PRIVATE_H__ */ diff --git a/src/Common/MsgEngine/src/private/MsgComposerPrivate.cpp b/src/Common/MsgEngine/src/private/MsgComposerPrivate.cpp index eb9f40f..c1c65dc 100644 --- a/src/Common/MsgEngine/src/private/MsgComposerPrivate.cpp +++ b/src/Common/MsgEngine/src/private/MsgComposerPrivate.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -30,7 +30,7 @@ using namespace Msg; MsgComposerPrivate::MsgComposerPrivate(MsgEngine &msgEngine) - : m_Engine(msgEngine) + : m_Engine(msgEngine) { } @@ -40,124 +40,124 @@ MsgComposerPrivate::~MsgComposerPrivate() MessageSMSRef MsgComposerPrivate::createSms() { - MessageSMSRef smsRef; - msg_struct_t msgInfo = msg_create_struct(MSG_STRUCT_MESSAGE_INFO); - if (msgInfo) { - msg_set_int_value(msgInfo, MSG_MESSAGE_TYPE_INT, MSG_TYPE_SMS); - - MessageSMSPrivate *sms = new MessageSMSPrivate(true, msgInfo); - smsRef.reset(sms); - } - return smsRef; + MessageSMSRef smsRef; + msg_struct_t msgInfo = msg_create_struct(MSG_STRUCT_MESSAGE_INFO); + if (msgInfo) { + msg_set_int_value(msgInfo, MSG_MESSAGE_TYPE_INT, MSG_TYPE_SMS); + + MessageSMSPrivate *sms = new MessageSMSPrivate(true, msgInfo); + smsRef.reset(sms); + } + return smsRef; } MessageMmsRef MsgComposerPrivate::createMms() { - MessageMmsRef mmsRef; - msg_struct_t msgInfo = msg_create_struct(MSG_STRUCT_MESSAGE_INFO); - if (msgInfo) { - msg_set_int_value(msgInfo, MSG_MESSAGE_TYPE_INT, MSG_TYPE_MMS); - msg_struct_t mmsStruct = msg_create_struct(MSG_STRUCT_MMS); - - setSmilHeader(mmsStruct, false); // BodyView support only Image after Text layout order isTextTop = false - - MessageMmsPrivate *mms = new MessageMmsPrivate(true, msgInfo, mmsStruct); - mmsRef.reset(mms); - } - return mmsRef; + MessageMmsRef mmsRef; + msg_struct_t msgInfo = msg_create_struct(MSG_STRUCT_MESSAGE_INFO); + if (msgInfo) { + msg_set_int_value(msgInfo, MSG_MESSAGE_TYPE_INT, MSG_TYPE_MMS); + msg_struct_t mmsStruct = msg_create_struct(MSG_STRUCT_MMS); + + setSmilHeader(mmsStruct, false); // BodyView support only Image after Text layout order isTextTop = false + + MessageMmsPrivate *mms = new MessageMmsPrivate(true, msgInfo, mmsStruct); + mmsRef.reset(mms); + } + return mmsRef; } void MsgComposerPrivate::setSmilHeader(msg_struct_t mms, bool isTextTop) { - msg_struct_t textRegion = NULL; - msg_struct_t imageRegion = NULL; - - /************ make rootlayout ***************/ - msg_set_int_value(mms, MSG_MMS_ROOTLAYOUT_WIDTH_INT, smilScreenWidthP); - msg_set_int_value(mms, MSG_MMS_ROOTLAYOUT_HEIGHT_INT, smilScreenHeightP); - - msg_set_bool_value(mms, MSG_MMS_ROOTLAYOUT_WIDTH_PERCENT_BOOL, true); - msg_set_bool_value(mms, MSG_MMS_ROOTLAYOUT_HEIGHT_PERCENT_BOOL, true); - /************ make region ********************/ - /* 1. add text region */ - msg_list_add_item(mms, MSG_STRUCT_MMS_REGION, &textRegion); - MsgUtilsPrivate::setStr(textRegion, MSG_MMS_REGION_ID_STR, textRegionId); - msg_set_int_value(textRegion, MSG_MMS_REGION_LENGTH_LEFT_INT, smilPosLeft); - msg_set_bool_value(textRegion, MSG_MMS_REGION_LENGTH_LEFT_PERCENT_BOOL, true); - - int textVertPos = isTextTop ? smilPosTop : smilPosBottom; - msg_set_int_value(textRegion, MSG_MMS_REGION_LENGTH_TOP_INT, textVertPos); - - msg_set_bool_value(textRegion, MSG_MMS_REGION_LENGTH_TOP_PERCENT_BOOL, true); - - msg_set_int_value(textRegion, MSG_MMS_REGION_LENGTH_WIDTH_INT, smilRegionWidth); - msg_set_bool_value(textRegion, MSG_MMS_REGION_LENGTH_WIDTH_PERCENT_BOOL, true); - - msg_set_int_value(textRegion, MSG_MMS_REGION_LENGTH_HEIGHT_INT, smilRegionHeight); - msg_set_bool_value(textRegion, MSG_MMS_REGION_LENGTH_HEIGHT_PERCENT_BOOL, true); - - /* 2. image(video) region */ - msg_list_add_item(mms, MSG_STRUCT_MMS_REGION, &imageRegion); - MsgUtilsPrivate::setStr(imageRegion, MSG_MMS_REGION_ID_STR, imageRegionId); - msg_set_int_value(imageRegion, MSG_MMS_REGION_LENGTH_LEFT_INT, smilPosLeft); - msg_set_bool_value(imageRegion, MSG_MMS_REGION_LENGTH_LEFT_PERCENT_BOOL, true); - - int imgVertPos = isTextTop ? smilPosBottom : smilPosTop; - msg_set_int_value(imageRegion, MSG_MMS_REGION_LENGTH_TOP_INT, imgVertPos); - - msg_set_bool_value(imageRegion, MSG_MMS_REGION_LENGTH_TOP_PERCENT_BOOL, true); - msg_set_int_value(imageRegion, MSG_MMS_REGION_LENGTH_WIDTH_INT, smilRegionWidth); - msg_set_bool_value(imageRegion, MSG_MMS_REGION_LENGTH_WIDTH_PERCENT_BOOL, true); - msg_set_int_value(imageRegion, MSG_MMS_REGION_LENGTH_HEIGHT_INT, smilRegionHeight); - msg_set_bool_value(imageRegion, MSG_MMS_REGION_LENGTH_HEIGHT_PERCENT_BOOL, true); + msg_struct_t textRegion = NULL; + msg_struct_t imageRegion = NULL; + + /************ make rootlayout ***************/ + msg_set_int_value(mms, MSG_MMS_ROOTLAYOUT_WIDTH_INT, smilScreenWidthP); + msg_set_int_value(mms, MSG_MMS_ROOTLAYOUT_HEIGHT_INT, smilScreenHeightP); + + msg_set_bool_value(mms, MSG_MMS_ROOTLAYOUT_WIDTH_PERCENT_BOOL, true); + msg_set_bool_value(mms, MSG_MMS_ROOTLAYOUT_HEIGHT_PERCENT_BOOL, true); + /************ make region ********************/ + /* 1. add text region */ + msg_list_add_item(mms, MSG_STRUCT_MMS_REGION, &textRegion); + MsgUtilsPrivate::setStr(textRegion, MSG_MMS_REGION_ID_STR, textRegionId); + msg_set_int_value(textRegion, MSG_MMS_REGION_LENGTH_LEFT_INT, smilPosLeft); + msg_set_bool_value(textRegion, MSG_MMS_REGION_LENGTH_LEFT_PERCENT_BOOL, true); + + int textVertPos = isTextTop ? smilPosTop : smilPosBottom; + msg_set_int_value(textRegion, MSG_MMS_REGION_LENGTH_TOP_INT, textVertPos); + + msg_set_bool_value(textRegion, MSG_MMS_REGION_LENGTH_TOP_PERCENT_BOOL, true); + + msg_set_int_value(textRegion, MSG_MMS_REGION_LENGTH_WIDTH_INT, smilRegionWidth); + msg_set_bool_value(textRegion, MSG_MMS_REGION_LENGTH_WIDTH_PERCENT_BOOL, true); + + msg_set_int_value(textRegion, MSG_MMS_REGION_LENGTH_HEIGHT_INT, smilRegionHeight); + msg_set_bool_value(textRegion, MSG_MMS_REGION_LENGTH_HEIGHT_PERCENT_BOOL, true); + + /* 2. image(video) region */ + msg_list_add_item(mms, MSG_STRUCT_MMS_REGION, &imageRegion); + MsgUtilsPrivate::setStr(imageRegion, MSG_MMS_REGION_ID_STR, imageRegionId); + msg_set_int_value(imageRegion, MSG_MMS_REGION_LENGTH_LEFT_INT, smilPosLeft); + msg_set_bool_value(imageRegion, MSG_MMS_REGION_LENGTH_LEFT_PERCENT_BOOL, true); + + int imgVertPos = isTextTop ? smilPosBottom : smilPosTop; + msg_set_int_value(imageRegion, MSG_MMS_REGION_LENGTH_TOP_INT, imgVertPos); + + msg_set_bool_value(imageRegion, MSG_MMS_REGION_LENGTH_TOP_PERCENT_BOOL, true); + msg_set_int_value(imageRegion, MSG_MMS_REGION_LENGTH_WIDTH_INT, smilRegionWidth); + msg_set_bool_value(imageRegion, MSG_MMS_REGION_LENGTH_WIDTH_PERCENT_BOOL, true); + msg_set_int_value(imageRegion, MSG_MMS_REGION_LENGTH_HEIGHT_INT, smilRegionHeight); + msg_set_bool_value(imageRegion, MSG_MMS_REGION_LENGTH_HEIGHT_PERCENT_BOOL, true); } void MsgComposerPrivate::calculateTextMetric(const std::string &text, MsgTextMetric &textMetric) { - textMetric.reset(); - - static const unsigned maxGsm7Len = 160; - static const unsigned maxUnicodeLen = 70; - const unsigned maxMmsLen = m_Engine.getSettings().getMaxMmsSize(); // In bytes - unsigned maxSmsLen = maxGsm7Len; // In chars - - msg_encode_type_t encode = MSG_ENCODE_GSM7BIT; - unsigned textLen = 0; - unsigned segmentLen = 0; - int bytesInChar = 1; - - if (!text.empty()) { - 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"); - } - - switch (encode) - { - case MSG_ENCODE_UCS2: - bytesInChar = 2; - maxSmsLen = maxUnicodeLen; - break; - - case MSG_ENCODE_GSM7BIT: - case MSG_ENCODE_AUTO: - bytesInChar = 1; - maxSmsLen = maxGsm7Len; - break; - - default: - MSG_LOG_ERROR("Unknown encode type: ", encode); - break; - } - - textLen /= bytesInChar; - } - - if (textLen == 0) - textLen = text.length() / bytesInChar; - - textMetric.isMms = textLen > maxSmsLen; - textMetric.maxSmsLen = maxSmsLen; - textMetric.bytes = textLen * bytesInChar; - textMetric.textLen = textLen; - textMetric.maxLen = textMetric.isMms ? maxMmsLen : maxSmsLen; + textMetric.reset(); + + static const unsigned maxGsm7Len = 160; + static const unsigned maxUnicodeLen = 70; + const unsigned maxMmsLen = m_Engine.getSettings().getMaxMmsSize(); // In bytes + unsigned maxSmsLen = maxGsm7Len; // In chars + + msg_encode_type_t encode = MSG_ENCODE_GSM7BIT; + unsigned textLen = 0; + unsigned segmentLen = 0; + int bytesInChar = 1; + + if (!text.empty()) { + 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"); + } + + switch (encode) + { + case MSG_ENCODE_UCS2: + bytesInChar = 2; + maxSmsLen = maxUnicodeLen; + break; + + case MSG_ENCODE_GSM7BIT: + case MSG_ENCODE_AUTO: + bytesInChar = 1; + maxSmsLen = maxGsm7Len; + break; + + default: + MSG_LOG_ERROR("Unknown encode type: ", encode); + break; + } + + textLen /= bytesInChar; + } + + if (textLen == 0) + textLen = text.length() / bytesInChar; + + textMetric.isMms = textLen > maxSmsLen; + textMetric.maxSmsLen = maxSmsLen; + textMetric.bytes = textLen * bytesInChar; + textMetric.textLen = textLen; + textMetric.maxLen = textMetric.isMms ? maxMmsLen : maxSmsLen; } diff --git a/src/Common/MsgEngine/src/private/MsgComposerPrivate.h b/src/Common/MsgEngine/src/private/MsgComposerPrivate.h index aefca1a..c124e4e 100644 --- a/src/Common/MsgEngine/src/private/MsgComposerPrivate.h +++ b/src/Common/MsgEngine/src/private/MsgComposerPrivate.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -21,25 +21,25 @@ #include namespace Msg { - class MsgEngine; - class MsgComposerPrivate - : public MsgComposer { - public: - MsgComposerPrivate(MsgEngine &msgEngine); - MsgComposerPrivate(MsgComposerPrivate&) = delete; - MsgComposerPrivate &operator=(MsgComposerPrivate&) = delete; - virtual ~MsgComposerPrivate(); + class MsgEngine; + class MsgComposerPrivate + : public MsgComposer { + public: + MsgComposerPrivate(MsgEngine &msgEngine); + MsgComposerPrivate(MsgComposerPrivate&) = delete; + MsgComposerPrivate &operator=(MsgComposerPrivate&) = delete; + virtual ~MsgComposerPrivate(); - MessageSMSRef createSms() override; - MessageMmsRef createMms() override; - void calculateTextMetric(const std::string &text, MsgTextMetric &textMetric) override; + MessageSMSRef createSms() override; + MessageMmsRef createMms() override; + void calculateTextMetric(const std::string &text, MsgTextMetric &textMetric) override; - private: - void setSmilHeader(msg_struct_t mms, bool isTextTop); + private: + void setSmilHeader(msg_struct_t mms, bool isTextTop); - private: - MsgEngine &m_Engine; - }; + private: + MsgEngine &m_Engine; + }; } #endif /* __MSG_COMPOSER_PRIVATE_H__ */ diff --git a/src/Common/MsgEngine/src/private/MsgConvMediaPrivate.cpp b/src/Common/MsgEngine/src/private/MsgConvMediaPrivate.cpp index 8b34264..eb05589 100644 --- a/src/Common/MsgEngine/src/private/MsgConvMediaPrivate.cpp +++ b/src/Common/MsgEngine/src/private/MsgConvMediaPrivate.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -20,8 +20,8 @@ using namespace Msg; MsgConvMediaPrivate::MsgConvMediaPrivate(bool release, msg_struct_t msgStruct) - : MsgStructPrivate(release, msgStruct) - , MsgConvMedia() + : MsgStructPrivate(release, msgStruct) + , MsgConvMedia() { } @@ -31,30 +31,30 @@ MsgConvMediaPrivate::~MsgConvMediaPrivate() std::string MsgConvMediaPrivate::getMime() const { - return MsgUtilsPrivate::getStr(m_MsgStruct, MSG_MMS_MULTIPART_CONTENT_TYPE_STR, MAX_MIME_TYPE_LEN); + return MsgUtilsPrivate::getStr(m_MsgStruct, MSG_MMS_MULTIPART_CONTENT_TYPE_STR, MAX_MIME_TYPE_LEN); } std::string MsgConvMediaPrivate::getName() const { - return MsgUtilsPrivate::getStr(m_MsgStruct, MSG_MMS_MULTIPART_NAME_STR, MSG_FILENAME_LEN_MAX); + return MsgUtilsPrivate::getStr(m_MsgStruct, MSG_MMS_MULTIPART_NAME_STR, MSG_FILENAME_LEN_MAX); } std::string MsgConvMediaPrivate::getPath() const { - return MsgUtilsPrivate::getStr(m_MsgStruct, MSG_MMS_MULTIPART_FILEPATH_STR, MSG_FILEPATH_LEN_MAX); + return MsgUtilsPrivate::getStr(m_MsgStruct, MSG_MMS_MULTIPART_FILEPATH_STR, MSG_FILEPATH_LEN_MAX); } std::string MsgConvMediaPrivate::getThumbPath() const { - return MsgUtilsPrivate::getStr(m_MsgStruct, MSG_MMS_MULTIPART_THUMBNAIL_FILEPATH_STR, MSG_FILEPATH_LEN_MAX); + return MsgUtilsPrivate::getStr(m_MsgStruct, MSG_MMS_MULTIPART_THUMBNAIL_FILEPATH_STR, MSG_FILEPATH_LEN_MAX); } std::string MsgConvMediaPrivate::getContentId() const { - return MsgUtilsPrivate::getStr(m_MsgStruct, MSG_MMS_MULTIPART_CONTENT_ID_STR, MMS_MSG_ID_LEN); + return MsgUtilsPrivate::getStr(m_MsgStruct, MSG_MMS_MULTIPART_CONTENT_ID_STR, MMS_MSG_ID_LEN); } std::string MsgConvMediaPrivate::getContentLocation() const { - return MsgUtilsPrivate::getStr(m_MsgStruct, MSG_MMS_MULTIPART_CONTENT_LOCATION_STR, MMS_LOCATION_LEN); + return MsgUtilsPrivate::getStr(m_MsgStruct, MSG_MMS_MULTIPART_CONTENT_LOCATION_STR, MMS_LOCATION_LEN); } diff --git a/src/Common/MsgEngine/src/private/MsgConvMediaPrivate.h b/src/Common/MsgEngine/src/private/MsgConvMediaPrivate.h index 2f1fc09..cea2365 100644 --- a/src/Common/MsgEngine/src/private/MsgConvMediaPrivate.h +++ b/src/Common/MsgEngine/src/private/MsgConvMediaPrivate.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -22,22 +22,22 @@ #include "MsgStructPrivate.h" namespace Msg { - class MsgConvMediaPrivate - : public MsgStructPrivate - , public MsgConvMedia { - public: - MsgConvMediaPrivate(bool release, msg_struct_t msgStruct = nullptr); - virtual ~MsgConvMediaPrivate(); + class MsgConvMediaPrivate + : public MsgStructPrivate + , public MsgConvMedia { + public: + MsgConvMediaPrivate(bool release, msg_struct_t msgStruct = nullptr); + virtual ~MsgConvMediaPrivate(); - virtual std::string getMime() const; - virtual std::string getName() const; - virtual std::string getPath() const; - virtual std::string getThumbPath() const; - virtual std::string getContentId() const; - virtual std::string getContentLocation() const; - }; + virtual std::string getMime() const; + virtual std::string getName() const; + virtual std::string getPath() const; + virtual std::string getThumbPath() const; + virtual std::string getContentId() const; + virtual std::string getContentLocation() const; + }; - typedef class MsgListHandlePrivate MsgConvMediaListHandlePrivate; + typedef class MsgListHandlePrivate MsgConvMediaListHandlePrivate; } #endif /* MSGCONVMEDIAPRIVATE_H_ */ diff --git a/src/Common/MsgEngine/src/private/MsgConversationItemPrivate.cpp b/src/Common/MsgEngine/src/private/MsgConversationItemPrivate.cpp index 2981a96..879cf88 100644 --- a/src/Common/MsgEngine/src/private/MsgConversationItemPrivate.cpp +++ b/src/Common/MsgEngine/src/private/MsgConversationItemPrivate.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -24,8 +24,8 @@ using namespace Msg; MsgConversationItemPrivate::MsgConversationItemPrivate(bool release, msg_struct_t msgStruct) - : MsgStructPrivate(release, msgStruct) - , m_MultipartList(false) + : MsgStructPrivate(release, msgStruct) + , m_MultipartList(false) { } @@ -35,95 +35,95 @@ MsgConversationItemPrivate::~MsgConversationItemPrivate() MsgId MsgConversationItemPrivate::getMsgId() const { - int id = MsgId::invalidId; - msg_get_int_value(m_MsgStruct, MSG_CONV_MSG_ID_INT, &id); - return id; + int id = MsgId::invalidId; + msg_get_int_value(m_MsgStruct, MSG_CONV_MSG_ID_INT, &id); + return id; } ThreadId MsgConversationItemPrivate::getThreadId() const { - int id = ThreadId::invalidId; - msg_get_int_value(m_MsgStruct, MSG_CONV_MSG_THREAD_ID_INT, &id); - return id; + int id = ThreadId::invalidId; + msg_get_int_value(m_MsgStruct, MSG_CONV_MSG_THREAD_ID_INT, &id); + return id; } std::string MsgConversationItemPrivate::getText() const { - return MsgUtilsPrivate::getStr(m_MsgStruct, MSG_CONV_MSG_TEXT_STR, MAX_MSG_TEXT_LEN); + return MsgUtilsPrivate::getStr(m_MsgStruct, MSG_CONV_MSG_TEXT_STR, MAX_MSG_TEXT_LEN); } std::string MsgConversationItemPrivate::getSubject() const { - return MsgUtilsPrivate::getStr(m_MsgStruct, MSG_CONV_MSG_SUBJECT_STR, MAX_SUBJECT_LEN); + return MsgUtilsPrivate::getStr(m_MsgStruct, MSG_CONV_MSG_SUBJECT_STR, MAX_SUBJECT_LEN); } time_t MsgConversationItemPrivate::getTime() const { - int time = 0; - msg_get_int_value(m_MsgStruct, MSG_CONV_MSG_DISPLAY_TIME_INT, &time); - return time; + int time = 0; + msg_get_int_value(m_MsgStruct, MSG_CONV_MSG_DISPLAY_TIME_INT, &time); + return time; } Message::Direction MsgConversationItemPrivate::getDirection() const { - int direction = 0; - msg_get_int_value(m_MsgStruct, MSG_CONV_MSG_DIRECTION_INT, &direction); - return MsgUtilsPrivate::nativeToDirection(direction); + int direction = 0; + msg_get_int_value(m_MsgStruct, MSG_CONV_MSG_DIRECTION_INT, &direction); + return MsgUtilsPrivate::nativeToDirection(direction); } Message::Type MsgConversationItemPrivate::getType() const { - int type = 0; - msg_get_int_value(m_MsgStruct, MSG_CONV_MSG_TYPE_INT, &type); - return MsgUtilsPrivate::nativeToMessageType(type); + int type = 0; + msg_get_int_value(m_MsgStruct, MSG_CONV_MSG_TYPE_INT, &type); + return MsgUtilsPrivate::nativeToMessageType(type); } Message::NetworkStatus MsgConversationItemPrivate::getNetworkStatus() const { - int status = 0; - int err = msg_get_int_value(m_MsgStruct, MSG_CONV_MSG_NETWORK_STATUS_INT, &status); - return err == 0 ? MsgUtilsPrivate::nativeToNetworkStatus(status) : Message::NS_Unknown; + int status = 0; + int err = msg_get_int_value(m_MsgStruct, MSG_CONV_MSG_NETWORK_STATUS_INT, &status); + return err == 0 ? MsgUtilsPrivate::nativeToNetworkStatus(status) : Message::NS_Unknown; } bool MsgConversationItemPrivate::isDraft() const { - int folder = 0; - msg_get_int_value(m_MsgStruct, MSG_CONV_MSG_FOLDER_ID_INT, &folder); - return (folder == MSG_DRAFT_ID); + int folder = 0; + msg_get_int_value(m_MsgStruct, MSG_CONV_MSG_FOLDER_ID_INT, &folder); + return (folder == MSG_DRAFT_ID); } bool MsgConversationItemPrivate::isRead() const { - bool read = 0; - msg_get_bool_value(m_MsgStruct, MSG_CONV_MSG_READ_BOOL, &read); - return read; + bool read = 0; + msg_get_bool_value(m_MsgStruct, MSG_CONV_MSG_READ_BOOL, &read); + return read; } int MsgConversationItemPrivate::getPagesCount() const { - int pages = 0; - msg_get_int_value(m_MsgStruct, MSG_CONV_MSG_PAGE_COUNT_INT, &pages); - return pages; + int pages = 0; + msg_get_int_value(m_MsgStruct, MSG_CONV_MSG_PAGE_COUNT_INT, &pages); + return pages; } int MsgConversationItemPrivate::getAttachCount() const { - int attachments = 0; - msg_get_int_value(m_MsgStruct, MSG_CONV_MSG_ATTACH_COUNT_INT, &attachments); - return attachments; + int attachments = 0; + msg_get_int_value(m_MsgStruct, MSG_CONV_MSG_ATTACH_COUNT_INT, &attachments); + return attachments; } const MsgConvMediaListHandlePrivate &MsgConversationItemPrivate::getMediaList() const { - msg_list_handle_t multipartList = nullptr; - msg_get_list_handle(m_MsgStruct, MSG_CONV_MSG_MULTIPART_HND, (void **)&multipartList); - m_MultipartList.set(multipartList); - return m_MultipartList; + msg_list_handle_t multipartList = nullptr; + msg_get_list_handle(m_MsgStruct, MSG_CONV_MSG_MULTIPART_HND, (void **)&multipartList); + m_MultipartList.set(multipartList); + return m_MultipartList; } bool MsgConversationItemPrivate::isRestrictedByDpm() const { - bool restricted = false; - msg_get_bool_value(m_MsgStruct, MSG_CONV_MSG_DPM_RESTRICTED_BOOL, &restricted); - return restricted; + bool restricted = false; + msg_get_bool_value(m_MsgStruct, MSG_CONV_MSG_DPM_RESTRICTED_BOOL, &restricted); + return restricted; } diff --git a/src/Common/MsgEngine/src/private/MsgConversationItemPrivate.h b/src/Common/MsgEngine/src/private/MsgConversationItemPrivate.h index b1e55d8..52226c3 100644 --- a/src/Common/MsgEngine/src/private/MsgConversationItemPrivate.h +++ b/src/Common/MsgEngine/src/private/MsgConversationItemPrivate.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -24,37 +24,37 @@ #include "MsgConvMediaPrivate.h" namespace Msg { - /** - * @brief Implementation of MsgConversationItem with msg-service private API usage. - */ - class MsgConversationItemPrivate - : public MsgStructPrivate - , public MsgConversationItem { - public: - MsgConversationItemPrivate(bool release, msg_struct_t msgStruct = nullptr); - virtual ~MsgConversationItemPrivate(); + /** + * @brief Implementation of MsgConversationItem with msg-service private API usage. + */ + class MsgConversationItemPrivate + : public MsgStructPrivate + , public MsgConversationItem { + public: + MsgConversationItemPrivate(bool release, msg_struct_t msgStruct = nullptr); + virtual ~MsgConversationItemPrivate(); - virtual MsgId getMsgId() const; - virtual ThreadId getThreadId() const; - virtual std::string getText() const; - virtual std::string getSubject() const; - virtual time_t getTime() const; - virtual Message::Direction getDirection() const; - virtual Message::Type getType() const; - virtual Message::NetworkStatus getNetworkStatus() const; - virtual bool isDraft() const; - virtual bool isRead() const; - virtual int getPagesCount() const; - virtual int getAttachCount() const; - virtual const MsgConvMediaListHandlePrivate &getMediaList() const; - virtual bool isRestrictedByDpm() const; + virtual MsgId getMsgId() const; + virtual ThreadId getThreadId() const; + virtual std::string getText() const; + virtual std::string getSubject() const; + virtual time_t getTime() const; + virtual Message::Direction getDirection() const; + virtual Message::Type getType() const; + virtual Message::NetworkStatus getNetworkStatus() const; + virtual bool isDraft() const; + virtual bool isRead() const; + virtual int getPagesCount() const; + virtual int getAttachCount() const; + virtual const MsgConvMediaListHandlePrivate &getMediaList() const; + virtual bool isRestrictedByDpm() const; - protected: - mutable MsgConvMediaListHandlePrivate m_MultipartList; - }; + protected: + mutable MsgConvMediaListHandlePrivate m_MultipartList; + }; - typedef class MsgListHandlePrivate MsgConversationListHandlePrivate; - typedef class MsgStructListPrivate MsgConversationStructListPrivate; + typedef class MsgListHandlePrivate MsgConversationListHandlePrivate; + typedef class MsgStructListPrivate MsgConversationStructListPrivate; } #endif /* __MSG_CONVERSATION_ITEM_PRIVATE_H__ */ diff --git a/src/Common/MsgEngine/src/private/MsgDefPrivate.h b/src/Common/MsgEngine/src/private/MsgDefPrivate.h index 38e0670..3ca3443 100644 --- a/src/Common/MsgEngine/src/private/MsgDefPrivate.h +++ b/src/Common/MsgEngine/src/private/MsgDefPrivate.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -20,30 +20,30 @@ #include namespace Msg { - // SMIL layout: - const int smilScreenWidthP = 100; - const int smilScreenHeightP = 100; - - const int smilPosTop = 1; - const int smilPosBottom = 50; - const int smilPosLeft = 0; - - const int smilRegionWidth = 100; - const int smilRegionHeight = 50; - - // Text style: - const int smilDefaultBgColor = 0xFF000000; - const int smilDefaultFontColor = 0xFFFFFFFF; - const int smilDefaultFontSize = 30; - const bool smilDefaultBold = false; - const bool smilDefaultUnderline = false; - - // Region id: - const std::string textRegionId = "Text"; - const std::string imageRegionId = "Image"; - - // Mime: - const std::string mimeText = "text/plain"; + // SMIL layout: + const int smilScreenWidthP = 100; + const int smilScreenHeightP = 100; + + const int smilPosTop = 1; + const int smilPosBottom = 50; + const int smilPosLeft = 0; + + const int smilRegionWidth = 100; + const int smilRegionHeight = 50; + + // Text style: + const int smilDefaultBgColor = 0xFF000000; + const int smilDefaultFontColor = 0xFFFFFFFF; + const int smilDefaultFontSize = 30; + const bool smilDefaultBold = false; + const bool smilDefaultUnderline = false; + + // Region id: + const std::string textRegionId = "Text"; + const std::string imageRegionId = "Image"; + + // Mime: + const std::string mimeText = "text/plain"; } diff --git a/src/Common/MsgEngine/src/private/MsgListHandlePrivate.h b/src/Common/MsgEngine/src/private/MsgListHandlePrivate.h index 5645b97..aac55ab 100644 --- a/src/Common/MsgEngine/src/private/MsgListHandlePrivate.h +++ b/src/Common/MsgEngine/src/private/MsgListHandlePrivate.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -22,75 +22,75 @@ #include namespace Msg { - // class T : public BaseT {} - template - class MsgListHandlePrivate - : public MsgList { // implement interface - public: - MsgListHandlePrivate(bool release, msg_list_handle_t list = nullptr) - : m_List(list) - , m_Object(false) - , m_Release(release) - { - } + // class T : public BaseT {} + template + class MsgListHandlePrivate + : public MsgList { // implement interface + public: + MsgListHandlePrivate(bool release, msg_list_handle_t list = nullptr) + : m_List(list) + , m_Object(false) + , m_Release(release) + { + } - virtual ~MsgListHandlePrivate() - { - if (m_Release && m_List) - msg_list_free(m_List); - } + virtual ~MsgListHandlePrivate() + { + if (m_Release && m_List) + msg_list_free(m_List); + } - virtual BaseT &at(int i) - { - msg_struct_t msgStruct = msg_list_nth_data(m_List, i); - m_Object.set(msgStruct); - return m_Object; - } + virtual BaseT &at(int i) + { + msg_struct_t msgStruct = msg_list_nth_data(m_List, i); + m_Object.set(msgStruct); + return m_Object; + } - virtual const BaseT &at(int i) const - { - msg_struct_t msgStruct = msg_list_nth_data(m_List, i); - m_Object.set(msgStruct); - return m_Object; - } + virtual const BaseT &at(int i) const + { + msg_struct_t msgStruct = msg_list_nth_data(m_List, i); + m_Object.set(msgStruct); + return m_Object; + } - virtual int getLength() const - { - return msg_list_length(m_List); - } + virtual int getLength() const + { + return msg_list_length(m_List); + } - inline void set(msg_list_handle_t list) - { - m_List = list; - } + inline void set(msg_list_handle_t list) + { + m_List = list; + } - inline operator msg_list_handle_t &() - { - return m_List; - } + inline operator msg_list_handle_t &() + { + return m_List; + } - inline operator const msg_list_handle_t &() const - { - return m_List; - } + inline operator const msg_list_handle_t &() const + { + return m_List; + } - inline const msg_list_handle_t &get() const - { - return m_List; - } + inline const msg_list_handle_t &get() const + { + return m_List; + } - inline msg_list_handle_t &get() - { - return m_List; - } - MsgListHandlePrivate(MsgListHandlePrivate&) = delete; - MsgListHandlePrivate &operator=(MsgListHandlePrivate&) = delete; + inline msg_list_handle_t &get() + { + return m_List; + } + MsgListHandlePrivate(MsgListHandlePrivate&) = delete; + MsgListHandlePrivate &operator=(MsgListHandlePrivate&) = delete; - protected: - mutable msg_list_handle_t m_List; - mutable T m_Object; - bool m_Release; - }; + protected: + mutable msg_list_handle_t m_List; + mutable T m_Object; + bool m_Release; + }; } #endif /* _MsgListHandlePrivate_H__ */ diff --git a/src/Common/MsgEngine/src/private/MsgMediaPrivate.cpp b/src/Common/MsgEngine/src/private/MsgMediaPrivate.cpp index e5d5ebb..61ddc2a 100644 --- a/src/Common/MsgEngine/src/private/MsgMediaPrivate.cpp +++ b/src/Common/MsgEngine/src/private/MsgMediaPrivate.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -26,7 +26,7 @@ using namespace Msg; MsgMediaPrivate::MsgMediaPrivate(bool release, msg_struct_t msgStruct) - : MsgStructPrivate(release, msgStruct) + : MsgStructPrivate(release, msgStruct) { } @@ -36,59 +36,59 @@ MsgMediaPrivate::~MsgMediaPrivate() MsgMediaPrivate::Type MsgMediaPrivate::getType() const { - int type = UnknownType; - msg_get_int_value(m_MsgStruct, MSG_MMS_MEDIA_TYPE_INT, &type); - return MsgUtilsPrivate::nativeToSmilType(type); + int type = UnknownType; + msg_get_int_value(m_MsgStruct, MSG_MMS_MEDIA_TYPE_INT, &type); + return MsgUtilsPrivate::nativeToSmilType(type); } std::string MsgMediaPrivate::getFileName() const { - return MsgUtilsPrivate::getStr(m_MsgStruct, MSG_MMS_MEDIA_FILENAME_STR, MSG_FILENAME_LEN_MAX); + return MsgUtilsPrivate::getStr(m_MsgStruct, MSG_MMS_MEDIA_FILENAME_STR, MSG_FILENAME_LEN_MAX); } std::string MsgMediaPrivate::getFilePath() const { - return MsgUtilsPrivate::getStr(m_MsgStruct, MSG_MMS_MEDIA_FILEPATH_STR, MSG_FILEPATH_LEN_MAX); + return MsgUtilsPrivate::getStr(m_MsgStruct, MSG_MMS_MEDIA_FILEPATH_STR, MSG_FILEPATH_LEN_MAX); } std::string MsgMediaPrivate::getMime() const { - return MsgUtilsPrivate::getStr(m_MsgStruct, MSG_MMS_MEDIA_CONTENT_TYPE_STR, MAX_MIME_TYPE_LEN); + return MsgUtilsPrivate::getStr(m_MsgStruct, MSG_MMS_MEDIA_CONTENT_TYPE_STR, MAX_MIME_TYPE_LEN); } void MsgMediaPrivate::setType(Type type) { - msg_set_int_value(m_MsgStruct, MSG_MMS_MEDIA_TYPE_INT, MsgUtilsPrivate::smilTypeToNative(type)); + msg_set_int_value(m_MsgStruct, MSG_MMS_MEDIA_TYPE_INT, MsgUtilsPrivate::smilTypeToNative(type)); - switch (type) { - case ImageType: - case VideoType: - MsgUtilsPrivate::setStr(m_MsgStruct, MSG_MMS_MEDIA_REGION_ID_STR, imageRegionId); - break; - case AudioType: - break; - case TextType: - MsgUtilsPrivate::setStr(m_MsgStruct, MSG_MMS_MEDIA_REGION_ID_STR, textRegionId); - break; - default: - MSG_ASSERT(false, "Wrong SMIL type:", type); - } + switch (type) { + case ImageType: + case VideoType: + MsgUtilsPrivate::setStr(m_MsgStruct, MSG_MMS_MEDIA_REGION_ID_STR, imageRegionId); + break; + case AudioType: + break; + case TextType: + MsgUtilsPrivate::setStr(m_MsgStruct, MSG_MMS_MEDIA_REGION_ID_STR, textRegionId); + break; + default: + MSG_ASSERT(false, "Wrong SMIL type:", type); + } } void MsgMediaPrivate::setMime(const std::string &mime) { - MsgUtilsPrivate::setStr(m_MsgStruct, MSG_MMS_MEDIA_CONTENT_TYPE_STR, mime); + MsgUtilsPrivate::setStr(m_MsgStruct, MSG_MMS_MEDIA_CONTENT_TYPE_STR, mime); } void MsgMediaPrivate::setFilePath(const std::string &path) { - MsgUtilsPrivate::setStr(m_MsgStruct, MSG_MMS_MEDIA_FILEPATH_STR, path); - MediaTypeData mediaData = getMsgMediaTypeByFileExt(path); - setType(mediaData.type); - setFileName(FileUtils::getFileName(path)); + MsgUtilsPrivate::setStr(m_MsgStruct, MSG_MMS_MEDIA_FILEPATH_STR, path); + MediaTypeData mediaData = getMsgMediaTypeByFileExt(path); + setType(mediaData.type); + setFileName(FileUtils::getFileName(path)); } void MsgMediaPrivate::setFileName(const std::string &name) { - MsgUtilsPrivate::setStr(m_MsgStruct, MSG_MMS_MEDIA_FILENAME_STR, name); + MsgUtilsPrivate::setStr(m_MsgStruct, MSG_MMS_MEDIA_FILENAME_STR, name); } diff --git a/src/Common/MsgEngine/src/private/MsgMediaPrivate.h b/src/Common/MsgEngine/src/private/MsgMediaPrivate.h index bffa366..6e1990f 100644 --- a/src/Common/MsgEngine/src/private/MsgMediaPrivate.h +++ b/src/Common/MsgEngine/src/private/MsgMediaPrivate.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -23,26 +23,26 @@ #include "MsgStructListPrivate.h" namespace Msg { - class MsgMediaPrivate - : public MsgStructPrivate - , public MsgMedia { - public: - MsgMediaPrivate(bool release, msg_struct_t msgStruct = nullptr); - virtual ~MsgMediaPrivate(); + class MsgMediaPrivate + : public MsgStructPrivate + , public MsgMedia { + public: + MsgMediaPrivate(bool release, msg_struct_t msgStruct = nullptr); + virtual ~MsgMediaPrivate(); - virtual Type getType() const; - virtual std::string getFilePath() const; - virtual std::string getFileName() const; - virtual void setFilePath(const std::string &path); + virtual Type getType() const; + virtual std::string getFilePath() const; + virtual std::string getFileName() const; + virtual void setFilePath(const std::string &path); - std::string getMime() const; - void setFileName(const std::string &name); - void setMime(const std::string &mime); - void setType(Type type); - }; + std::string getMime() const; + void setFileName(const std::string &name); + void setMime(const std::string &mime); + void setType(Type type); + }; - typedef class MsgListHandlePrivate MsgMediaListHandlePrivate; - typedef class MsgStructListPrivate MsgMediaStructListPrivate; + typedef class MsgListHandlePrivate MsgMediaListHandlePrivate; + typedef class MsgStructListPrivate MsgMediaStructListPrivate; } #endif /* _MSG_MEDIA_PRIVATE_H__ */ diff --git a/src/Common/MsgEngine/src/private/MsgPagePrivate.cpp b/src/Common/MsgEngine/src/private/MsgPagePrivate.cpp index b7ae9a8..e1baaa8 100644 --- a/src/Common/MsgEngine/src/private/MsgPagePrivate.cpp +++ b/src/Common/MsgEngine/src/private/MsgPagePrivate.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -19,9 +19,9 @@ using namespace Msg; MsgPagePrivate::MsgPagePrivate(bool release, msg_struct_t msgStruct) - : MsgStructPrivate(release, msgStruct) - , m_MediaList(false) - , m_Media(false) + : MsgStructPrivate(release, msgStruct) + , m_MediaList(false) + , m_Media(false) { } @@ -31,29 +31,29 @@ MsgPagePrivate::~MsgPagePrivate() MsgMediaListHandlePrivate &MsgPagePrivate::getMediaList() { - msg_list_handle_t mediaList = nullptr; - msg_get_list_handle(m_MsgStruct, MSG_MMS_PAGE_MEDIA_LIST_HND, (void **)&mediaList); - m_MediaList.set(mediaList); - return m_MediaList; + msg_list_handle_t mediaList = nullptr; + msg_get_list_handle(m_MsgStruct, MSG_MMS_PAGE_MEDIA_LIST_HND, (void **)&mediaList); + m_MediaList.set(mediaList); + return m_MediaList; } MsgMediaPrivate &MsgPagePrivate::addMedia() { - msg_struct_t media = nullptr; - msg_list_add_item(m_MsgStruct, MSG_STRUCT_MMS_MEDIA, &media); - m_Media.set(media); - return m_Media; + msg_struct_t media = nullptr; + msg_list_add_item(m_MsgStruct, MSG_STRUCT_MMS_MEDIA, &media); + m_Media.set(media); + return m_Media; } void MsgPagePrivate::setPageDuration(int duration) { - msg_set_int_value(m_MsgStruct, MSG_MMS_PAGE_PAGE_DURATION_INT, duration); + msg_set_int_value(m_MsgStruct, MSG_MMS_PAGE_PAGE_DURATION_INT, duration); } int MsgPagePrivate::getPageDuration() const { - int duration = 0; - msg_get_int_value(m_MsgStruct, MSG_MMS_PAGE_PAGE_DURATION_INT, &duration); - return duration; + int duration = 0; + msg_get_int_value(m_MsgStruct, MSG_MMS_PAGE_PAGE_DURATION_INT, &duration); + return duration; } diff --git a/src/Common/MsgEngine/src/private/MsgPagePrivate.h b/src/Common/MsgEngine/src/private/MsgPagePrivate.h index 8e676b9..291304b 100644 --- a/src/Common/MsgEngine/src/private/MsgPagePrivate.h +++ b/src/Common/MsgEngine/src/private/MsgPagePrivate.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -21,25 +21,25 @@ #include "MsgMediaPrivate.h" namespace Msg { - class MsgPagePrivate - : public MsgStructPrivate - , public MsgPage { - public: - MsgPagePrivate(bool release, msg_struct_t msgStruct = nullptr); - virtual ~MsgPagePrivate(); + class MsgPagePrivate + : public MsgStructPrivate + , public MsgPage { + public: + MsgPagePrivate(bool release, msg_struct_t msgStruct = nullptr); + virtual ~MsgPagePrivate(); - virtual MsgMediaListHandlePrivate &getMediaList(); - virtual MsgMediaPrivate &addMedia(); - virtual void setPageDuration(int duration); - virtual int getPageDuration() const; + virtual MsgMediaListHandlePrivate &getMediaList(); + virtual MsgMediaPrivate &addMedia(); + virtual void setPageDuration(int duration); + virtual int getPageDuration() const; - private: - MsgMediaListHandlePrivate m_MediaList; - MsgMediaPrivate m_Media; - }; + private: + MsgMediaListHandlePrivate m_MediaList; + MsgMediaPrivate m_Media; + }; - typedef class MsgListHandlePrivate MsgPageListHandlePrivate; - typedef class MsgStructListPrivate MsgPageStructListPrivate; + typedef class MsgListHandlePrivate MsgPageListHandlePrivate; + typedef class MsgStructListPrivate MsgPageStructListPrivate; } #endif /* _MSG_PAGE_PRIVATE_H__ */ diff --git a/src/Common/MsgEngine/src/private/MsgReportPrivate.cpp b/src/Common/MsgEngine/src/private/MsgReportPrivate.cpp index 4c0a20c..c188c64 100644 --- a/src/Common/MsgEngine/src/private/MsgReportPrivate.cpp +++ b/src/Common/MsgEngine/src/private/MsgReportPrivate.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -22,8 +22,8 @@ using namespace Msg; MsgReportPrivate::MsgReportPrivate(bool release, msg_struct_t msgStruct) - : MsgStructPrivate(release, msgStruct) - , MsgReport() + : MsgStructPrivate(release, msgStruct) + , MsgReport() { } @@ -33,33 +33,33 @@ MsgReportPrivate::~MsgReportPrivate() std::string MsgReportPrivate::getAddress() const { - return MsgUtilsPrivate::getStr(m_MsgStruct, MSG_REPORT_ADDRESS_STR, MAX_ADDRESS_VAL_LEN); + return MsgUtilsPrivate::getStr(m_MsgStruct, MSG_REPORT_ADDRESS_STR, MAX_ADDRESS_VAL_LEN); } MsgReport::DeliveryStatus MsgReportPrivate::getDeliveryStatus() const { - int nativeType = MSG_DELIVERY_REPORT_NONE; - msg_get_int_value(m_MsgStruct, MSG_REPORT_STATUS_INT, &nativeType); - return MsgUtilsPrivate::nativeToReportDeliveryStatus(nativeType); + int nativeType = MSG_DELIVERY_REPORT_NONE; + msg_get_int_value(m_MsgStruct, MSG_REPORT_STATUS_INT, &nativeType); + return MsgUtilsPrivate::nativeToReportDeliveryStatus(nativeType); } MsgReport::ReadStatus MsgReportPrivate::getReadStatus() const { - int nativeType = MSG_READ_REPORT_NONE; - msg_get_int_value(m_MsgStruct, MSG_REPORT_STATUS_INT, (int *)&nativeType); - return MsgUtilsPrivate::nativeToReportReadStatus(nativeType); + int nativeType = MSG_READ_REPORT_NONE; + msg_get_int_value(m_MsgStruct, MSG_REPORT_STATUS_INT, (int *)&nativeType); + return MsgUtilsPrivate::nativeToReportReadStatus(nativeType); } MsgReport::Type MsgReportPrivate::getType() const { - int nativeType = MSG_REPORT_TYPE_DELIVERY; - msg_get_int_value(m_MsgStruct, MSG_REPORT_TYPE_INT, &nativeType); - return MsgUtilsPrivate::nativeToReportType(nativeType); + int nativeType = MSG_REPORT_TYPE_DELIVERY; + msg_get_int_value(m_MsgStruct, MSG_REPORT_TYPE_INT, &nativeType); + return MsgUtilsPrivate::nativeToReportType(nativeType); } time_t MsgReportPrivate::getTime() const { - int time = 0; - msg_get_int_value(m_MsgStruct, MSG_REPORT_TIME_INT, &time); - return (time_t)time; + int time = 0; + msg_get_int_value(m_MsgStruct, MSG_REPORT_TIME_INT, &time); + return (time_t)time; } diff --git a/src/Common/MsgEngine/src/private/MsgReportPrivate.h b/src/Common/MsgEngine/src/private/MsgReportPrivate.h index daaff40..0dacb29 100644 --- a/src/Common/MsgEngine/src/private/MsgReportPrivate.h +++ b/src/Common/MsgEngine/src/private/MsgReportPrivate.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -23,22 +23,22 @@ #include "MsgStructPrivate.h" namespace Msg { - class MsgReportPrivate - : public MsgStructPrivate - , public MsgReport { - public: - MsgReportPrivate(bool release, msg_struct_t msgStruct = nullptr); - virtual ~MsgReportPrivate(); + class MsgReportPrivate + : public MsgStructPrivate + , public MsgReport { + public: + MsgReportPrivate(bool release, msg_struct_t msgStruct = nullptr); + virtual ~MsgReportPrivate(); - virtual std::string getAddress() const; - virtual DeliveryStatus getDeliveryStatus() const; - virtual ReadStatus getReadStatus() const; - virtual Type getType() const; - virtual time_t getTime() const; - }; + virtual std::string getAddress() const; + virtual DeliveryStatus getDeliveryStatus() const; + virtual ReadStatus getReadStatus() const; + virtual Type getType() const; + virtual time_t getTime() const; + }; - typedef class MsgListHandlePrivate MsgReportListHandlePrivate; - typedef class MsgStructListPrivate MsgReportStructListPrivate; + typedef class MsgListHandlePrivate MsgReportListHandlePrivate; + typedef class MsgStructListPrivate MsgReportStructListPrivate; } #endif /* MsgReportPrivate_h_ */ diff --git a/src/Common/MsgEngine/src/private/MsgSentStatusPrivate.cpp b/src/Common/MsgEngine/src/private/MsgSentStatusPrivate.cpp index c42b202..2b4d74b 100644 --- a/src/Common/MsgEngine/src/private/MsgSentStatusPrivate.cpp +++ b/src/Common/MsgEngine/src/private/MsgSentStatusPrivate.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +20,7 @@ using namespace Msg; MsgSentStatusPrivate::MsgSentStatusPrivate(msg_struct_t msgStruct) - : MsgStructPrivate(false, msgStruct) + : MsgStructPrivate(false, msgStruct) { } @@ -30,14 +30,14 @@ MsgSentStatusPrivate::~MsgSentStatusPrivate() RequestId MsgSentStatusPrivate::getId() const { - int id = RequestId::invalidId; - msg_get_int_value(m_MsgStruct, MSG_SENT_STATUS_REQUESTID_INT, &id); - return id; + int id = RequestId::invalidId; + msg_get_int_value(m_MsgStruct, MSG_SENT_STATUS_REQUESTID_INT, &id); + return id; } Message::NetworkStatus MsgSentStatusPrivate::getNetworkStatus() const { - int status = Message::NS_Unknown; - int err = msg_get_int_value(m_MsgStruct, MSG_SENT_STATUS_NETWORK_STATUS_INT, &status); - return err == 0 ? MsgUtilsPrivate::nativeToNetworkStatus(status) : Message::NS_Unknown; + int status = Message::NS_Unknown; + int err = msg_get_int_value(m_MsgStruct, MSG_SENT_STATUS_NETWORK_STATUS_INT, &status); + return err == 0 ? MsgUtilsPrivate::nativeToNetworkStatus(status) : Message::NS_Unknown; } diff --git a/src/Common/MsgEngine/src/private/MsgSentStatusPrivate.h b/src/Common/MsgEngine/src/private/MsgSentStatusPrivate.h index cd7b04e..5a32699 100644 --- a/src/Common/MsgEngine/src/private/MsgSentStatusPrivate.h +++ b/src/Common/MsgEngine/src/private/MsgSentStatusPrivate.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -21,17 +21,17 @@ #include "MsgStructPrivate.h" namespace Msg { - class MsgSentStatusPrivate - : public MsgStructPrivate - , public MsgSentStatus { + class MsgSentStatusPrivate + : public MsgStructPrivate + , public MsgSentStatus { - public: - MsgSentStatusPrivate(msg_struct_t msgStruct); - virtual ~MsgSentStatusPrivate(); + public: + MsgSentStatusPrivate(msg_struct_t msgStruct); + virtual ~MsgSentStatusPrivate(); - RequestId getId() const override; - Message::NetworkStatus getNetworkStatus() const override; - }; + RequestId getId() const override; + Message::NetworkStatus getNetworkStatus() const override; + }; } diff --git a/src/Common/MsgEngine/src/private/MsgSettingsPrivate.cpp b/src/Common/MsgEngine/src/private/MsgSettingsPrivate.cpp index 8b4a75d..268effd 100644 --- a/src/Common/MsgEngine/src/private/MsgSettingsPrivate.cpp +++ b/src/Common/MsgEngine/src/private/MsgSettingsPrivate.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -28,257 +28,257 @@ using namespace Msg; MsgSettingsPrivate::MsgSettingsPrivate(msg_handle_t serviceHandle) - : MsgSettings() - , m_ServiceHandle(serviceHandle) - , m_GeneralOpt() - , m_SmsSendOpt() - , m_MmsSendOpt() - , m_MmsRecvOpt() - , m_pActiveNotifJob(nullptr) - , m_ActiveNotifValue(0) + : MsgSettings() + , m_ServiceHandle(serviceHandle) + , m_GeneralOpt() + , m_SmsSendOpt() + , m_MmsSendOpt() + , m_MmsRecvOpt() + , m_pActiveNotifJob(nullptr) + , m_ActiveNotifValue(0) { - init(); + init(); } MsgSettingsPrivate::~MsgSettingsPrivate() { - finit(); + finit(); } void MsgSettingsPrivate::init() { - m_GeneralOpt = msg_create_struct(MSG_STRUCT_SETTING_GENERAL_OPT); - msg_get_general_opt(m_ServiceHandle, m_GeneralOpt); + m_GeneralOpt = msg_create_struct(MSG_STRUCT_SETTING_GENERAL_OPT); + msg_get_general_opt(m_ServiceHandle, m_GeneralOpt); - m_SmsSendOpt = msg_create_struct(MSG_STRUCT_SETTING_SMS_SEND_OPT); - msg_get_sms_send_opt(m_ServiceHandle, m_SmsSendOpt); + m_SmsSendOpt = msg_create_struct(MSG_STRUCT_SETTING_SMS_SEND_OPT); + msg_get_sms_send_opt(m_ServiceHandle, m_SmsSendOpt); - m_MmsSendOpt = msg_create_struct(MSG_STRUCT_SETTING_MMS_SEND_OPT); - msg_get_mms_send_opt(m_ServiceHandle, m_MmsSendOpt); + m_MmsSendOpt = msg_create_struct(MSG_STRUCT_SETTING_MMS_SEND_OPT); + msg_get_mms_send_opt(m_ServiceHandle, m_MmsSendOpt); - m_MmsRecvOpt = msg_create_struct(MSG_STRUCT_SETTING_MMS_RECV_OPT); - msg_get_mms_recv_opt(m_ServiceHandle, m_MmsRecvOpt); + m_MmsRecvOpt = msg_create_struct(MSG_STRUCT_SETTING_MMS_RECV_OPT); + msg_get_mms_recv_opt(m_ServiceHandle, m_MmsRecvOpt); } void MsgSettingsPrivate::finit() { - if (m_pActiveNotifJob) { - ecore_job_del(m_pActiveNotifJob); - m_pActiveNotifJob = nullptr; - vconf_set_int(VCONFKEY_MESSAGE_ACTIVATED_CONVERSATION_ID, m_ActiveNotifValue); - MSG_LOG("ActiveNotifValue = ", m_ActiveNotifValue); - } - msg_release_struct(&m_MmsRecvOpt); - msg_release_struct(&m_MmsSendOpt); - msg_release_struct(&m_SmsSendOpt); - msg_release_struct(&m_GeneralOpt); + if (m_pActiveNotifJob) { + ecore_job_del(m_pActiveNotifJob); + m_pActiveNotifJob = nullptr; + vconf_set_int(VCONFKEY_MESSAGE_ACTIVATED_CONVERSATION_ID, m_ActiveNotifValue); + MSG_LOG("ActiveNotifValue = ", m_ActiveNotifValue); + } + msg_release_struct(&m_MmsRecvOpt); + msg_release_struct(&m_MmsSendOpt); + msg_release_struct(&m_SmsSendOpt); + msg_release_struct(&m_GeneralOpt); } int MsgSettingsPrivate::getAddressMaxLen() const { - return MAX_ADDRESS_VAL_LEN; + return MAX_ADDRESS_VAL_LEN; } int MsgSettingsPrivate::getPhoneNumberMaxLen() const { - return MAX_PHONE_NUMBER_LEN; + return MAX_PHONE_NUMBER_LEN; } int MsgSettingsPrivate::getAddressMaxCount() const { - return MAX_TO_ADDRESS_CNT; + return MAX_TO_ADDRESS_CNT; } int MsgSettingsPrivate::getSubjectMaxLen() const { - return MAX_SUBJECT_LEN; + return MAX_SUBJECT_LEN; } int MsgSettingsPrivate::getDisplayNameMaxLen() const { - return MAX_DISPLAY_NAME_LEN; + return MAX_DISPLAY_NAME_LEN; } int MsgSettingsPrivate::getMaxRecipientCount() const { - return MAX_TO_ADDRESS_CNT; + return MAX_TO_ADDRESS_CNT; } int MsgSettingsPrivate::getMaxMmsSize() const { - int res = 0; - msg_struct_t setting = msg_create_struct(MSG_STRUCT_SETTING_MSGSIZE_OPT); - if (msg_get_msgsize_opt(m_ServiceHandle, setting) == 0) - msg_get_int_value(setting, MSG_MESSAGE_SIZE_INT, &res); - msg_release_struct(&setting); + int res = 0; + msg_struct_t setting = msg_create_struct(MSG_STRUCT_SETTING_MSGSIZE_OPT); + 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; + // Standard MMS has size 307200 bytes + const int kb = 1024; - if (res > 0) { - res *= kb; - res -= 5 * kb; // header size - } else { - res = MAX_MSG_DATA_LEN * kb; - } + if (res > 0) { + res *= kb; + res -= 5 * kb; // header size + } else { + res = MAX_MSG_DATA_LEN * kb; + } - return res; + return res; } int MsgSettingsPrivate::getMaxMsgTextLen() const { - return MAX_MSG_TEXT_LEN; + return MAX_MSG_TEXT_LEN; } void MsgSettingsPrivate::setAlerts(bool value) { - msg_set_bool_value(m_GeneralOpt, MSG_GENERAL_MSG_NOTIFICATION_BOOL, value); - msg_set_general_opt(m_ServiceHandle, m_GeneralOpt); + msg_set_bool_value(m_GeneralOpt, MSG_GENERAL_MSG_NOTIFICATION_BOOL, value); + msg_set_general_opt(m_ServiceHandle, m_GeneralOpt); } bool MsgSettingsPrivate::getAlerts() const { - bool res = false; - msg_get_bool_value(m_GeneralOpt, MSG_GENERAL_MSG_NOTIFICATION_BOOL, &res); - return res; + bool res = false; + msg_get_bool_value(m_GeneralOpt, MSG_GENERAL_MSG_NOTIFICATION_BOOL, &res); + return res; } void MsgSettingsPrivate::setRingtoneType(RingtoneType type) { - 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) - listener->onRingtoneChanged(*this); + 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) + listener->onRingtoneChanged(*this); } MsgSettingsPrivate::RingtoneType MsgSettingsPrivate::getRingtoneType() const { - int type = MSG_RINGTONE_TYPE_DEFAULT; - msg_get_int_value(m_GeneralOpt, MSG_GENERAL_RINGTONE_TYPE_INT, &type); - return MsgUtilsPrivate::nativeToRingtoneType(type); + int type = MSG_RINGTONE_TYPE_DEFAULT; + msg_get_int_value(m_GeneralOpt, MSG_GENERAL_RINGTONE_TYPE_INT, &type); + return MsgUtilsPrivate::nativeToRingtoneType(type); } void MsgSettingsPrivate::setRingtone(const std::string &soundPath) { - MsgUtilsPrivate::setStr(m_GeneralOpt, MSG_GENERAL_RINGTONE_PATH_STR, soundPath); - msg_set_general_opt(m_ServiceHandle, m_GeneralOpt); - 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) + listener->onRingtoneChanged(*this); } std::string MsgSettingsPrivate::getRingtone() const { - return MsgUtilsPrivate::getStr(m_GeneralOpt, MSG_GENERAL_RINGTONE_PATH_STR, MSG_FILEPATH_LEN_MAX); + return MsgUtilsPrivate::getStr(m_GeneralOpt, MSG_GENERAL_RINGTONE_PATH_STR, MSG_FILEPATH_LEN_MAX); } void MsgSettingsPrivate::setVibration(bool value) { - msg_set_bool_value(m_GeneralOpt, MSG_GENERAL_MSG_VIBRATION_BOOL, value); - msg_set_general_opt(m_ServiceHandle, m_GeneralOpt); + msg_set_bool_value(m_GeneralOpt, MSG_GENERAL_MSG_VIBRATION_BOOL, value); + msg_set_general_opt(m_ServiceHandle, m_GeneralOpt); } bool MsgSettingsPrivate::getVibration() const { - bool res = false; - msg_get_bool_value(m_GeneralOpt, MSG_GENERAL_MSG_VIBRATION_BOOL, &res); - return res; + bool res = false; + msg_get_bool_value(m_GeneralOpt, MSG_GENERAL_MSG_VIBRATION_BOOL, &res); + return res; } void MsgSettingsPrivate::setSmsDelivReport(bool value) { - msg_set_bool_value(m_SmsSendOpt, MSG_SMS_SENDOPT_DELIVERY_REPORT_BOOL, value); - msg_set_sms_send_opt(m_ServiceHandle, m_SmsSendOpt); + msg_set_bool_value(m_SmsSendOpt, MSG_SMS_SENDOPT_DELIVERY_REPORT_BOOL, value); + msg_set_sms_send_opt(m_ServiceHandle, m_SmsSendOpt); } bool MsgSettingsPrivate::getSmsDelivReport() const { - bool res = false; - msg_get_bool_value(m_SmsSendOpt, MSG_SMS_SENDOPT_DELIVERY_REPORT_BOOL, &res); - return res; + bool res = false; + msg_get_bool_value(m_SmsSendOpt, MSG_SMS_SENDOPT_DELIVERY_REPORT_BOOL, &res); + return res; } void MsgSettingsPrivate::setMmsDelivReport(bool value) { - msg_set_bool_value(m_MmsSendOpt, MSG_MMS_SENDOPT_DELIVERY_REPORT_BOOL, value); - msg_set_mms_send_opt(m_ServiceHandle, m_MmsSendOpt); + msg_set_bool_value(m_MmsSendOpt, MSG_MMS_SENDOPT_DELIVERY_REPORT_BOOL, value); + msg_set_mms_send_opt(m_ServiceHandle, m_MmsSendOpt); } bool MsgSettingsPrivate::getMmsDelivReport() const { - bool res = false; - msg_get_bool_value(m_MmsSendOpt, MSG_MMS_SENDOPT_DELIVERY_REPORT_BOOL, &res); - return res; + bool res = false; + msg_get_bool_value(m_MmsSendOpt, MSG_MMS_SENDOPT_DELIVERY_REPORT_BOOL, &res); + return res; } void MsgSettingsPrivate::setMmsReadReport(bool value) { - msg_set_bool_value(m_MmsSendOpt, MSG_MMS_SENDOPT_READ_REPLY_BOOL, value); - msg_set_mms_send_opt(m_ServiceHandle, m_MmsSendOpt); + msg_set_bool_value(m_MmsSendOpt, MSG_MMS_SENDOPT_READ_REPLY_BOOL, value); + msg_set_mms_send_opt(m_ServiceHandle, m_MmsSendOpt); } bool MsgSettingsPrivate::getMmsReadReport() const { - bool res = false; - msg_get_bool_value(m_MmsSendOpt, MSG_MMS_SENDOPT_READ_REPLY_BOOL, &res); - return res; + bool res = false; + msg_get_bool_value(m_MmsSendOpt, MSG_MMS_SENDOPT_READ_REPLY_BOOL, &res); + return res; } void MsgSettingsPrivate::setMmsAutoRetr(bool value) { - 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); + 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); } bool MsgSettingsPrivate::getMmsAutoRetr() const { - bool res = false; - int retrType = 0; - msg_get_int_value(m_MmsRecvOpt, MSG_MMS_RECVOPT_HOME_RETRIEVE_TYPE_INT, &retrType); - res = retrType == MSG_HOME_AUTO_DOWNLOAD; - return res; + bool res = false; + int retrType = 0; + msg_get_int_value(m_MmsRecvOpt, MSG_MMS_RECVOPT_HOME_RETRIEVE_TYPE_INT, &retrType); + res = retrType == MSG_HOME_AUTO_DOWNLOAD; + return res; } void MsgSettingsPrivate::setMmsAutoRetrRoaming(bool value) { - int retrType = value ? MSG_ABROAD_AUTO_DOWNLOAD : MSG_ABROAD_MANUAL; - msg_set_int_value(m_MmsRecvOpt, MSG_MMS_RECVOPT_ABROAD_RETRIEVE_TYPE_INT, retrType); - msg_set_mms_recv_opt(m_ServiceHandle, m_MmsRecvOpt); + int retrType = value ? MSG_ABROAD_AUTO_DOWNLOAD : MSG_ABROAD_MANUAL; + msg_set_int_value(m_MmsRecvOpt, MSG_MMS_RECVOPT_ABROAD_RETRIEVE_TYPE_INT, retrType); + msg_set_mms_recv_opt(m_ServiceHandle, m_MmsRecvOpt); } bool MsgSettingsPrivate::getMmsAutoRetrRoaming() const { - bool res = false; - int retrType = 0; - msg_get_int_value(m_MmsRecvOpt, MSG_MMS_RECVOPT_ABROAD_RETRIEVE_TYPE_INT, &retrType); - res = retrType == MSG_ABROAD_AUTO_DOWNLOAD; - return res; + bool res = false; + int retrType = 0; + msg_get_int_value(m_MmsRecvOpt, MSG_MMS_RECVOPT_ABROAD_RETRIEVE_TYPE_INT, &retrType); + res = retrType == MSG_ABROAD_AUTO_DOWNLOAD; + return res; } void MsgSettingsPrivate::setActiveNotifPolicy(ActiveNotifPolicy type) { - int value = MsgUtilsPrivate::activeNotifPolicyToNative(type); - addJobSetActiveNotifPolicy(value); + int value = MsgUtilsPrivate::activeNotifPolicyToNative(type); + addJobSetActiveNotifPolicy(value); } void MsgSettingsPrivate::setActiveNotifPolicy(ThreadId id) { - addJobSetActiveNotifPolicy(id); + addJobSetActiveNotifPolicy(id); } void MsgSettingsPrivate::addJobSetActiveNotifPolicy(int value) { - m_ActiveNotifValue = value; - if (!m_pActiveNotifJob) { - m_pActiveNotifJob = ecore_job_add - ( - [](void *data) - { - auto *self =(MsgSettingsPrivate*)data; - self->m_pActiveNotifJob = nullptr; - vconf_set_int(VCONFKEY_MESSAGE_ACTIVATED_CONVERSATION_ID, self->m_ActiveNotifValue); - MSG_LOG("ActiveNotifValue = ", self->m_ActiveNotifValue); - }, - this); - } + m_ActiveNotifValue = value; + if (!m_pActiveNotifJob) { + m_pActiveNotifJob = ecore_job_add + ( + [](void *data) + { + auto *self =(MsgSettingsPrivate*)data; + self->m_pActiveNotifJob = nullptr; + vconf_set_int(VCONFKEY_MESSAGE_ACTIVATED_CONVERSATION_ID, self->m_ActiveNotifValue); + MSG_LOG("ActiveNotifValue = ", self->m_ActiveNotifValue); + }, + this); + } } diff --git a/src/Common/MsgEngine/src/private/MsgSettingsPrivate.h b/src/Common/MsgEngine/src/private/MsgSettingsPrivate.h index f3ea3f3..c1703d3 100644 --- a/src/Common/MsgEngine/src/private/MsgSettingsPrivate.h +++ b/src/Common/MsgEngine/src/private/MsgSettingsPrivate.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -23,66 +23,66 @@ #include namespace Msg { - class MsgSettingsPrivate - : public MsgSettings { - public: - MsgSettingsPrivate(msg_handle_t serviceHandle); - MsgSettingsPrivate(MsgSettingsPrivate&) = delete; - MsgSettingsPrivate &operator=(MsgSettingsPrivate&) = delete; - virtual ~MsgSettingsPrivate(); - - virtual int getAddressMaxLen() const; - virtual int getPhoneNumberMaxLen() const; - virtual int getAddressMaxCount() const; - virtual int getSubjectMaxLen() const; - virtual int getDisplayNameMaxLen() const; - virtual int getMaxRecipientCount() const; - virtual int getMaxMmsSize() const; - virtual int getMaxMsgTextLen() const; - - virtual void setAlerts(bool value); - virtual bool getAlerts() const; - - virtual void setRingtoneType(RingtoneType type); - virtual RingtoneType getRingtoneType() const; - virtual void setRingtone(const std::string &soundPath); - virtual std::string getRingtone() const; - - virtual void setVibration(bool value); - virtual bool getVibration() const; - - virtual void setSmsDelivReport(bool value); - virtual bool getSmsDelivReport() const; - - virtual void setMmsDelivReport(bool value); - virtual bool getMmsDelivReport() const ; - - virtual void setMmsReadReport(bool value); - virtual bool getMmsReadReport() const; - - virtual void setMmsAutoRetr(bool value); - virtual bool getMmsAutoRetr() const; - - virtual void setMmsAutoRetrRoaming(bool value); - virtual bool getMmsAutoRetrRoaming() const; - - virtual void setActiveNotifPolicy(ActiveNotifPolicy type); - virtual void setActiveNotifPolicy(ThreadId id); - - private: - void init(); - void finit(); - void addJobSetActiveNotifPolicy(int value); - - private: - msg_handle_t m_ServiceHandle; - msg_struct_t m_GeneralOpt; - msg_struct_t m_SmsSendOpt; - msg_struct_t m_MmsSendOpt; - msg_struct_t m_MmsRecvOpt; - Ecore_Job *m_pActiveNotifJob; - int m_ActiveNotifValue; - }; + class MsgSettingsPrivate + : public MsgSettings { + public: + MsgSettingsPrivate(msg_handle_t serviceHandle); + MsgSettingsPrivate(MsgSettingsPrivate&) = delete; + MsgSettingsPrivate &operator=(MsgSettingsPrivate&) = delete; + virtual ~MsgSettingsPrivate(); + + virtual int getAddressMaxLen() const; + virtual int getPhoneNumberMaxLen() const; + virtual int getAddressMaxCount() const; + virtual int getSubjectMaxLen() const; + virtual int getDisplayNameMaxLen() const; + virtual int getMaxRecipientCount() const; + virtual int getMaxMmsSize() const; + virtual int getMaxMsgTextLen() const; + + virtual void setAlerts(bool value); + virtual bool getAlerts() const; + + virtual void setRingtoneType(RingtoneType type); + virtual RingtoneType getRingtoneType() const; + virtual void setRingtone(const std::string &soundPath); + virtual std::string getRingtone() const; + + virtual void setVibration(bool value); + virtual bool getVibration() const; + + virtual void setSmsDelivReport(bool value); + virtual bool getSmsDelivReport() const; + + virtual void setMmsDelivReport(bool value); + virtual bool getMmsDelivReport() const ; + + virtual void setMmsReadReport(bool value); + virtual bool getMmsReadReport() const; + + virtual void setMmsAutoRetr(bool value); + virtual bool getMmsAutoRetr() const; + + virtual void setMmsAutoRetrRoaming(bool value); + virtual bool getMmsAutoRetrRoaming() const; + + virtual void setActiveNotifPolicy(ActiveNotifPolicy type); + virtual void setActiveNotifPolicy(ThreadId id); + + private: + void init(); + void finit(); + void addJobSetActiveNotifPolicy(int value); + + private: + msg_handle_t m_ServiceHandle; + msg_struct_t m_GeneralOpt; + msg_struct_t m_SmsSendOpt; + msg_struct_t m_MmsSendOpt; + msg_struct_t m_MmsRecvOpt; + Ecore_Job *m_pActiveNotifJob; + int m_ActiveNotifValue; + }; } #endif /* __MsgSettingsPrivate_h__ */ diff --git a/src/Common/MsgEngine/src/private/MsgStoragePrivate.cpp b/src/Common/MsgEngine/src/private/MsgStoragePrivate.cpp index bcdd450..1d63ff0 100644 --- a/src/Common/MsgEngine/src/private/MsgStoragePrivate.cpp +++ b/src/Common/MsgEngine/src/private/MsgStoragePrivate.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -32,69 +32,69 @@ using namespace Msg; MsgStoragePrivate::MsgStoragePrivate(msg_handle_t serviceHandle) - : MsgStorage() - , m_ServiceHandle(serviceHandle) + : MsgStorage() + , m_ServiceHandle(serviceHandle) { - TRACE; - msg_reg_storage_change_callback(m_ServiceHandle, msg_storage_change_cb, this); - msg_reg_thread_change_callback(m_ServiceHandle, msg_thread_change_cb, this); + TRACE; + msg_reg_storage_change_callback(m_ServiceHandle, msg_storage_change_cb, this); + msg_reg_thread_change_callback(m_ServiceHandle, msg_thread_change_cb, this); } template void MsgStoragePrivate::notifyListeners(const T& delta, ListenerMethod method) { - for (auto listener: m_Listeners) - (listener->*method)(delta); + for (auto listener: m_Listeners) + (listener->*method)(delta); } void MsgStoragePrivate::msg_storage_change_cb(msg_handle_t handle, msg_storage_change_type_t storageChangeType, msg_id_list_s *pMsgIdList, void *user_param) { - TRACE; - MsgStoragePrivate *self = static_cast(user_param); - MsgIdList msgIdList; - - int count = pMsgIdList->nCount; - msgIdList.reserve(count); - - for (int i = 0; i < count; ++i) - msgIdList.push_back(pMsgIdList->msgIdList[i]); - - switch (storageChangeType) { - case MSG_STORAGE_CHANGE_UPDATE: - self->notifyListeners(msgIdList, &IMsgStorageListener::onMsgStorageUpdate); - break; - case MSG_STORAGE_CHANGE_INSERT: - self->notifyListeners(msgIdList, &IMsgStorageListener::onMsgStorageInsert); - break; - case MSG_STORAGE_CHANGE_DELETE: - self->notifyListeners(msgIdList, &IMsgStorageListener::onMsgStorageDelete); - break; - case MSG_STORAGE_CHANGE_CONTACT: - self->notifyListeners(msgIdList, &IMsgStorageListener::onMsgStorageContact); - break; - } + TRACE; + MsgStoragePrivate *self = static_cast(user_param); + MsgIdList msgIdList; + + int count = pMsgIdList->nCount; + msgIdList.reserve(count); + + for (int i = 0; i < count; ++i) + msgIdList.push_back(pMsgIdList->msgIdList[i]); + + switch (storageChangeType) { + case MSG_STORAGE_CHANGE_UPDATE: + self->notifyListeners(msgIdList, &IMsgStorageListener::onMsgStorageUpdate); + break; + case MSG_STORAGE_CHANGE_INSERT: + self->notifyListeners(msgIdList, &IMsgStorageListener::onMsgStorageInsert); + break; + case MSG_STORAGE_CHANGE_DELETE: + self->notifyListeners(msgIdList, &IMsgStorageListener::onMsgStorageDelete); + break; + case MSG_STORAGE_CHANGE_CONTACT: + self->notifyListeners(msgIdList, &IMsgStorageListener::onMsgStorageContact); + break; + } } void MsgStoragePrivate::msg_thread_change_cb(msg_handle_t handle, msg_storage_change_type_t storageChangeType, msg_thread_id_t threadId, void *user_param) { - TRACE; - MsgStoragePrivate *self = static_cast(user_param); - ThreadId tId = static_cast(threadId); - - switch (storageChangeType) { - case MSG_STORAGE_CHANGE_UPDATE: - self->notifyListeners(tId, &IMsgStorageListener::onMsgStorageThreadUpdate); - break; - case MSG_STORAGE_CHANGE_INSERT: - self->notifyListeners(tId, &IMsgStorageListener::onMsgStorageThreadInsert); - break; - case MSG_STORAGE_CHANGE_DELETE: - self->notifyListeners(tId, &IMsgStorageListener::onMsgStorageThreadDelete); - break; - case MSG_STORAGE_CHANGE_CONTACT: - self->notifyListeners(tId, &IMsgStorageListener::onMsgStorageThreadContact); - break; - } + TRACE; + MsgStoragePrivate *self = static_cast(user_param); + ThreadId tId = static_cast(threadId); + + switch (storageChangeType) { + case MSG_STORAGE_CHANGE_UPDATE: + self->notifyListeners(tId, &IMsgStorageListener::onMsgStorageThreadUpdate); + break; + case MSG_STORAGE_CHANGE_INSERT: + self->notifyListeners(tId, &IMsgStorageListener::onMsgStorageThreadInsert); + break; + case MSG_STORAGE_CHANGE_DELETE: + self->notifyListeners(tId, &IMsgStorageListener::onMsgStorageThreadDelete); + break; + case MSG_STORAGE_CHANGE_CONTACT: + self->notifyListeners(tId, &IMsgStorageListener::onMsgStorageThreadContact); + break; + } } MsgStoragePrivate::~MsgStoragePrivate() @@ -104,326 +104,326 @@ MsgStoragePrivate::~MsgStoragePrivate() MsgThreadListRef MsgStoragePrivate::getThreadList() { - MsgThreadListRef res; - msg_struct_list_s msgList = {}; - msg_struct_t sortRule = msg_create_struct(MSG_STRUCT_SORT_RULE); - msg_set_int_value(sortRule, MSG_SORT_RULE_SORT_TYPE_INT, MSG_SORT_BY_THREAD_DATE); - msg_set_bool_value(sortRule, MSG_SORT_RULE_ACSCEND_BOOL, false); - int error = msg_get_thread_view_list(m_ServiceHandle, sortRule, &msgList); - msg_release_struct(&sortRule); - - if (error == 0) - res.reset(new MsgThreadStructListPrivate(true, msgList)); - - return res; + MsgThreadListRef res; + msg_struct_list_s msgList = {}; + msg_struct_t sortRule = msg_create_struct(MSG_STRUCT_SORT_RULE); + msg_set_int_value(sortRule, MSG_SORT_RULE_SORT_TYPE_INT, MSG_SORT_BY_THREAD_DATE); + msg_set_bool_value(sortRule, MSG_SORT_RULE_ACSCEND_BOOL, false); + int error = msg_get_thread_view_list(m_ServiceHandle, sortRule, &msgList); + msg_release_struct(&sortRule); + + if (error == 0) + res.reset(new MsgThreadStructListPrivate(true, msgList)); + + return res; } MessageSMSListRef MsgStoragePrivate::getSimMsgList() { - MessageSMSListRef res; + MessageSMSListRef res; - msg_struct_list_s msgList; + msg_struct_list_s msgList; - msg_struct_t listCond = msg_create_struct(MSG_STRUCT_MSG_LIST_CONDITION); - msg_set_int_value(listCond, MSG_LIST_CONDITION_FOLDER_ID_INT, MSG_ALLBOX_ID); - msg_set_int_value(listCond, MSG_LIST_CONDITION_MSGTYPE_INT, MSG_TYPE_SMS); - 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); + msg_struct_t listCond = msg_create_struct(MSG_STRUCT_MSG_LIST_CONDITION); + msg_set_int_value(listCond, MSG_LIST_CONDITION_FOLDER_ID_INT, MSG_ALLBOX_ID); + msg_set_int_value(listCond, MSG_LIST_CONDITION_MSGTYPE_INT, MSG_TYPE_SMS); + 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) - res.reset(new SmsStructListPrivate(true, msgList)); + if (msg_get_message_list2(m_ServiceHandle, listCond, &msgList) == 0) + res.reset(new SmsStructListPrivate(true, msgList)); - msg_release_struct(&listCond); - return res; + msg_release_struct(&listCond); + return res; } ThreadId MsgStoragePrivate::getThreadId(const MsgAddressList &addressList) { - msg_thread_id_t id = ThreadId::invalidId; - - if (const MsgAddressListHandlePrivate *privateList = dynamic_cast(&addressList)) { - msg_list_handle_t handleList = *privateList; - msg_get_thread_id_by_address2(m_ServiceHandle, handleList, &id); - } else if (const MsgAddressStructListPrivate *privateList = dynamic_cast(&addressList)) { - msg_struct_list_s msgStructList = *privateList; - msg_get_thread_id_by_address(m_ServiceHandle, &msgStructList, &id); - } else { - assert(false); - } - - return (ThreadId)id; + msg_thread_id_t id = ThreadId::invalidId; + + if (const MsgAddressListHandlePrivate *privateList = dynamic_cast(&addressList)) { + msg_list_handle_t handleList = *privateList; + msg_get_thread_id_by_address2(m_ServiceHandle, handleList, &id); + } else if (const MsgAddressStructListPrivate *privateList = dynamic_cast(&addressList)) { + msg_struct_list_s msgStructList = *privateList; + msg_get_thread_id_by_address(m_ServiceHandle, &msgStructList, &id); + } else { + assert(false); + } + + return (ThreadId)id; } ThreadId MsgStoragePrivate::getThreadId(const std::list &addressList) { - msg_thread_id_t tid = ThreadId::invalidId; - msg_struct_t msgInfo = msg_create_struct(MSG_STRUCT_MESSAGE_INFO); - - if (msgInfo) { - for (auto &addr : addressList) { - MsgAddress::AddressType type = MsgUtils::getAddressType(addr); - msg_struct_t tmpAddr = nullptr; - - if (msg_list_add_item(msgInfo, MSG_MESSAGE_ADDR_LIST_HND, &tmpAddr) == MSG_SUCCESS) { - msg_set_int_value(tmpAddr, MSG_ADDRESS_INFO_ADDRESS_TYPE_INT, MsgUtilsPrivate::addressTypeToNative(type)); - msg_set_int_value(tmpAddr, MSG_ADDRESS_INFO_RECIPIENT_TYPE_INT, MSG_RECIPIENTS_TYPE_TO); - MsgUtilsPrivate::setStr(tmpAddr, MSG_ADDRESS_INFO_ADDRESS_VALUE_STR, addr); - } - } - - msg_list_handle_t addrList = nullptr; - msg_get_list_handle(msgInfo, MSG_MESSAGE_ADDR_LIST_HND, (void **)&addrList); - if (addrList) - msg_get_thread_id_by_address2(m_ServiceHandle, addrList, &tid); - - msg_release_struct(&msgInfo); - } - - return (ThreadId)tid; + msg_thread_id_t tid = ThreadId::invalidId; + msg_struct_t msgInfo = msg_create_struct(MSG_STRUCT_MESSAGE_INFO); + + if (msgInfo) { + for (auto &addr : addressList) { + MsgAddress::AddressType type = MsgUtils::getAddressType(addr); + msg_struct_t tmpAddr = nullptr; + + if (msg_list_add_item(msgInfo, MSG_MESSAGE_ADDR_LIST_HND, &tmpAddr) == MSG_SUCCESS) { + msg_set_int_value(tmpAddr, MSG_ADDRESS_INFO_ADDRESS_TYPE_INT, MsgUtilsPrivate::addressTypeToNative(type)); + msg_set_int_value(tmpAddr, MSG_ADDRESS_INFO_RECIPIENT_TYPE_INT, MSG_RECIPIENTS_TYPE_TO); + MsgUtilsPrivate::setStr(tmpAddr, MSG_ADDRESS_INFO_ADDRESS_VALUE_STR, addr); + } + } + + msg_list_handle_t addrList = nullptr; + msg_get_list_handle(msgInfo, MSG_MESSAGE_ADDR_LIST_HND, (void **)&addrList); + if (addrList) + msg_get_thread_id_by_address2(m_ServiceHandle, addrList, &tid); + + msg_release_struct(&msgInfo); + } + + return (ThreadId)tid; } MsgAddressListRef MsgStoragePrivate::getAddressList(ThreadId id) { - MsgAddressStructListPrivate *result = new MsgAddressStructListPrivate(true); - msg_get_address_list(m_ServiceHandle, id, &result->get()); - return MsgAddressListRef(result); + MsgAddressStructListPrivate *result = new MsgAddressStructListPrivate(true); + msg_get_address_list(m_ServiceHandle, id, &result->get()); + return MsgAddressListRef(result); } MsgThreadListRef MsgStoragePrivate::searchThread(const std::string &word) { - MsgThreadListRef res; - msg_struct_list_s searchList = {}; + MsgThreadListRef res; + msg_struct_list_s searchList = {}; - msg_error_t error = msg_search_message_for_thread_view(m_ServiceHandle, word.c_str(), &searchList); - if (error != 0) { - MSG_LOG_ERROR("msg_search_message_for_thread_view error ", error); - } + msg_error_t error = msg_search_message_for_thread_view(m_ServiceHandle, word.c_str(), &searchList); + if (error != 0) { + MSG_LOG_ERROR("msg_search_message_for_thread_view error ", error); + } - if (error == 0) - res.reset(new MsgThreadStructListPrivate(true, searchList)); + if (error == 0) + res.reset(new MsgThreadStructListPrivate(true, searchList)); - return res; + return res; } int MsgStoragePrivate::getUnreadThreadCount() const { - msg_struct_t sortRule = msg_create_struct(MSG_STRUCT_SORT_RULE); - msg_struct_list_s peerList; + msg_struct_t sortRule = msg_create_struct(MSG_STRUCT_SORT_RULE); + msg_struct_list_s peerList; - int unreadThreadCount = 0; + int unreadThreadCount = 0; - msg_set_int_value(sortRule, MSG_SORT_RULE_SORT_TYPE_INT, MSG_SORT_BY_READ_STATUS); - msg_set_bool_value(sortRule, MSG_SORT_RULE_ACSCEND_BOOL, false); + msg_set_int_value(sortRule, MSG_SORT_RULE_SORT_TYPE_INT, MSG_SORT_BY_READ_STATUS); + msg_set_bool_value(sortRule, MSG_SORT_RULE_ACSCEND_BOOL, false); - msg_get_thread_view_list(m_ServiceHandle, sortRule, &peerList); - msg_release_struct(&sortRule); + msg_get_thread_view_list(m_ServiceHandle, sortRule, &peerList); + msg_release_struct(&sortRule); - 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); + 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) - unreadThreadCount++; - } + if (unreadCnt > 0) + unreadThreadCount++; + } - return unreadThreadCount; + return unreadThreadCount; } MsgThreadItemRef MsgStoragePrivate::getThread(ThreadId id) { - MsgThreadItemRef res; - msg_struct_t thread = msg_create_struct(MSG_STRUCT_THREAD_INFO); - if (msg_get_thread(m_ServiceHandle, id, thread) == 0) - res.reset(new MsgThreadItemPrivate(true, thread)); + MsgThreadItemRef res; + msg_struct_t thread = msg_create_struct(MSG_STRUCT_THREAD_INFO); + if (msg_get_thread(m_ServiceHandle, id, thread) == 0) + res.reset(new MsgThreadItemPrivate(true, thread)); - return res; + return res; } bool MsgStoragePrivate::deleteThread(ThreadId id) { - return msg_delete_thread_message_list(m_ServiceHandle, id, true) == 0; + return msg_delete_thread_message_list(m_ServiceHandle, id, true) == 0; } MsgConversationListRef MsgStoragePrivate::getConversationList(ThreadId id) { - MsgConversationListRef res; - msg_struct_list_s convList = {}; - int error = msg_get_conversation_view_list(m_ServiceHandle, id, &convList); + MsgConversationListRef res; + msg_struct_list_s convList = {}; + int error = msg_get_conversation_view_list(m_ServiceHandle, id, &convList); - if (error == 0) - res.reset(new MsgConversationStructListPrivate(true, convList)); + if (error == 0) + res.reset(new MsgConversationStructListPrivate(true, convList)); - return res; + return res; } MsgConversationItemRef MsgStoragePrivate::getConversationItem(MsgId id) { - MsgConversationItemRef res; - msg_struct_t convItem = msg_create_struct(MSG_STRUCT_CONV_INFO); - if (msg_get_conversation(m_ServiceHandle, id, convItem) == 0) { - res.reset(new MsgConversationItemPrivate(true, convItem)); - } else { - msg_release_struct(&convItem); - } - - return res; + MsgConversationItemRef res; + msg_struct_t convItem = msg_create_struct(MSG_STRUCT_CONV_INFO); + if (msg_get_conversation(m_ServiceHandle, id, convItem) == 0) { + res.reset(new MsgConversationItemPrivate(true, convItem)); + } else { + msg_release_struct(&convItem); + } + + return res; } MessageRef MsgStoragePrivate::getMessage(MsgId id) { - MessageRef msgRef; - 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) { - int nativeType = MSG_TYPE_INVALID; - msg_get_int_value(msg, MSG_MESSAGE_TYPE_INT, &nativeType); - Message::Type type = MsgUtilsPrivate::nativeToMessageType(nativeType); - - if (MsgUtils::isMms(type)) - msgRef = std::make_shared(true, msg); - else - msgRef = std::make_shared(true, msg); - } else { - msg_release_struct(&msg); - } - msg_release_struct(&sendOpt); - return msgRef; + MessageRef msgRef; + 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) { + int nativeType = MSG_TYPE_INVALID; + msg_get_int_value(msg, MSG_MESSAGE_TYPE_INT, &nativeType); + Message::Type type = MsgUtilsPrivate::nativeToMessageType(nativeType); + + if (MsgUtils::isMms(type)) + msgRef = std::make_shared(true, msg); + else + msgRef = std::make_shared(true, msg); + } else { + msg_release_struct(&msg); + } + msg_release_struct(&sendOpt); + return msgRef; } MsgId MsgStoragePrivate::saveMessage(Message &msg, bool updateExisting, StorageResult *result) { - if (result) - *result = StorageFail; - - MsgId newMsgId; - MessagePrivate &msgPriv = dynamic_cast(msg); - - msg_struct_t sendOpt = msg_create_struct(MSG_STRUCT_SENDOPT); - msg_set_bool_value(sendOpt, MSG_SEND_OPT_SETTING_BOOL, false); - - msgPriv.commit(); - if (msgPriv.getId().isValid() && updateExisting) { - int err = msg_update_message(m_ServiceHandle, msgPriv, sendOpt); - if (result) - *result = MsgUtilsPrivate::nativeToStorageResult(err); - if (err == MSG_SUCCESS) - newMsgId = msg.getId(); - } else { - newMsgId = msg_add_message(m_ServiceHandle, msgPriv, sendOpt); - if (newMsgId > 0) { - int err = msg_move_msg_to_storage(m_ServiceHandle, newMsgId, msg.getMessageStorageType()); - if (result) - *result = MsgUtilsPrivate::nativeToStorageResult(err); - if (err != MSG_SUCCESS) { - MSG_LOG_WARN("Can't move msg to storage, error = ", MsgEngine::whatError(err)); - deleteMessage(newMsgId); - newMsgId.reset(); - } - } - } - msg_release_struct(&sendOpt); - return newMsgId; + if (result) + *result = StorageFail; + + MsgId newMsgId; + MessagePrivate &msgPriv = dynamic_cast(msg); + + msg_struct_t sendOpt = msg_create_struct(MSG_STRUCT_SENDOPT); + msg_set_bool_value(sendOpt, MSG_SEND_OPT_SETTING_BOOL, false); + + msgPriv.commit(); + if (msgPriv.getId().isValid() && updateExisting) { + int err = msg_update_message(m_ServiceHandle, msgPriv, sendOpt); + if (result) + *result = MsgUtilsPrivate::nativeToStorageResult(err); + if (err == MSG_SUCCESS) + newMsgId = msg.getId(); + } else { + newMsgId = msg_add_message(m_ServiceHandle, msgPriv, sendOpt); + if (newMsgId > 0) { + int err = msg_move_msg_to_storage(m_ServiceHandle, newMsgId, msg.getMessageStorageType()); + if (result) + *result = MsgUtilsPrivate::nativeToStorageResult(err); + if (err != MSG_SUCCESS) { + MSG_LOG_WARN("Can't move msg to storage, error = ", MsgEngine::whatError(err)); + deleteMessage(newMsgId); + newMsgId.reset(); + } + } + } + msg_release_struct(&sendOpt); + return newMsgId; } bool MsgStoragePrivate::deleteMessage(MsgId id) { - return msg_delete_message(m_ServiceHandle, id) == 0; + return msg_delete_message(m_ServiceHandle, id) == 0; } bool MsgStoragePrivate::deleteMessages(const MsgIdList &idList) { - msg_id_list_s internalIdList; + msg_id_list_s internalIdList; - internalIdList.nCount = idList.size(); - if (internalIdList.nCount <= 0) - return false; + internalIdList.nCount = idList.size(); + if (internalIdList.nCount <= 0) + return false; - msg_message_id_t ids[internalIdList.nCount]; - std::copy(idList.begin(), idList.end(), ids); - internalIdList.msgIdList = ids; + msg_message_id_t ids[internalIdList.nCount]; + std::copy(idList.begin(), idList.end(), ids); + internalIdList.msgIdList = ids; - return msg_delete_msgs_by_list(m_ServiceHandle, &internalIdList) == 0; + return msg_delete_msgs_by_list(m_ServiceHandle, &internalIdList) == 0; } MessageListRef MsgStoragePrivate::searchMessage(const std::string &word) { - MessageListRef res; - msg_struct_list_s searchList = {}; + MessageListRef res; + msg_struct_list_s searchList = {}; - msg_struct_t listCond = msg_create_struct(MSG_STRUCT_MSG_LIST_CONDITION); - msg_set_int_value(listCond, MSG_LIST_CONDITION_FOLDER_ID_INT, MSG_ALLBOX_ID); - msg_set_int_value(listCond, MSG_LIST_CONDITION_STORAGE_ID_INT, MSG_STORAGE_PHONE); - msg_set_str_value(listCond, MSG_LIST_CONDITION_TEXT_VALUE_STR, word.c_str(), word.length()); + msg_struct_t listCond = msg_create_struct(MSG_STRUCT_MSG_LIST_CONDITION); + msg_set_int_value(listCond, MSG_LIST_CONDITION_FOLDER_ID_INT, MSG_ALLBOX_ID); + msg_set_int_value(listCond, MSG_LIST_CONDITION_STORAGE_ID_INT, MSG_STORAGE_PHONE); + msg_set_str_value(listCond, MSG_LIST_CONDITION_TEXT_VALUE_STR, word.c_str(), word.length()); - msg_error_t error = msg_get_message_list2(m_ServiceHandle, listCond, &searchList); - msg_release_struct(&listCond); + msg_error_t error = msg_get_message_list2(m_ServiceHandle, listCond, &searchList); + msg_release_struct(&listCond); - if (error == 0) - res.reset(new MessageStructListPrivate(true, searchList)); + if (error == 0) + res.reset(new MessageStructListPrivate(true, searchList)); - return res; + return res; } void MsgStoragePrivate::setReadStatus(ThreadId id) { - msg_set_conversation_to_read(m_ServiceHandle, id); + msg_set_conversation_to_read(m_ServiceHandle, id); } void MsgStoragePrivate::setReadStatus(MsgId id, bool status) { - msg_update_read_status(m_ServiceHandle, id, status); + msg_update_read_status(m_ServiceHandle, id, status); } MsgReportListRef MsgStoragePrivate::getMsgReportList(MsgId msgId) { - MsgReportStructListPrivate *result = new MsgReportStructListPrivate(true); - msg_get_report_status(m_ServiceHandle, msgId, &result->get()); - return MsgReportListRef(result); + MsgReportStructListPrivate *result = new MsgReportStructListPrivate(true); + msg_get_report_status(m_ServiceHandle, msgId, &result->get()); + return MsgReportListRef(result); } bool MsgStoragePrivate::isReadReportChecked(MsgId msgId) { - bool readFlag = false; - msg_struct_t mmsSendOpt = nullptr; - msg_struct_t sendOpt = msg_create_struct(MSG_STRUCT_SENDOPT); - msg_struct_t msgInfo = msg_create_struct(MSG_STRUCT_MESSAGE_INFO); - - msg_get_message(m_ServiceHandle, msgId, msgInfo, sendOpt); - msg_get_struct_handle(sendOpt, MSG_SEND_OPT_MMS_OPT_HND, &mmsSendOpt); - if (mmsSendOpt) - msg_get_bool_value(mmsSendOpt, MSG_MMS_SENDOPTION_READ_REQUEST_BOOL, &readFlag); - - msg_release_struct(&msgInfo); - msg_release_struct(&sendOpt); - return readFlag; + bool readFlag = false; + msg_struct_t mmsSendOpt = nullptr; + msg_struct_t sendOpt = msg_create_struct(MSG_STRUCT_SENDOPT); + msg_struct_t msgInfo = msg_create_struct(MSG_STRUCT_MESSAGE_INFO); + + msg_get_message(m_ServiceHandle, msgId, msgInfo, sendOpt); + msg_get_struct_handle(sendOpt, MSG_SEND_OPT_MMS_OPT_HND, &mmsSendOpt); + if (mmsSendOpt) + msg_get_bool_value(mmsSendOpt, MSG_MMS_SENDOPTION_READ_REQUEST_BOOL, &readFlag); + + msg_release_struct(&msgInfo); + msg_release_struct(&sendOpt); + return readFlag; } bool MsgStoragePrivate::isDeliverReportChecked(MsgId msgId) { - bool deliverFlag = false; - msg_struct_t sendOpt = msg_create_struct(MSG_STRUCT_SENDOPT); - msg_struct_t msgInfo = msg_create_struct(MSG_STRUCT_MESSAGE_INFO); + bool deliverFlag = false; + msg_struct_t sendOpt = msg_create_struct(MSG_STRUCT_SENDOPT); + msg_struct_t msgInfo = msg_create_struct(MSG_STRUCT_MESSAGE_INFO); - msg_get_message(m_ServiceHandle, msgId, msgInfo, sendOpt); - msg_get_bool_value(sendOpt, MSG_SEND_OPT_DELIVER_REQ_BOOL, &deliverFlag); + msg_get_message(m_ServiceHandle, msgId, msgInfo, sendOpt); + msg_get_bool_value(sendOpt, MSG_SEND_OPT_DELIVER_REQ_BOOL, &deliverFlag); - msg_release_struct(&msgInfo); - msg_release_struct(&sendOpt); - return deliverFlag; + msg_release_struct(&msgInfo); + msg_release_struct(&sendOpt); + return deliverFlag; } ThreadId MsgStoragePrivate::getThreadId(MsgId id) { - int threadId = ThreadId::invalidId; - msg_struct_t msg = msg_create_struct(MSG_STRUCT_MESSAGE_INFO); - msg_struct_t sendOpt = msg_create_struct(MSG_STRUCT_SENDOPT); + int threadId = ThreadId::invalidId; + 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) - msg_get_int_value(msg, MSG_MESSAGE_THREAD_ID_INT, &threadId); + 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); - msg_release_struct(&sendOpt); + msg_release_struct(&msg); + msg_release_struct(&sendOpt); - return threadId; + return threadId; } diff --git a/src/Common/MsgEngine/src/private/MsgStoragePrivate.h b/src/Common/MsgEngine/src/private/MsgStoragePrivate.h index 6154bb0..e7be79b 100644 --- a/src/Common/MsgEngine/src/private/MsgStoragePrivate.h +++ b/src/Common/MsgEngine/src/private/MsgStoragePrivate.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -24,66 +24,66 @@ #include namespace Msg { - class MsgStoragePrivate - : public MsgStorage { - public: - MsgStoragePrivate(msg_handle_t serviceHandle); - MsgStoragePrivate(MsgStoragePrivate&) = delete; - MsgStoragePrivate &operator=(MsgStoragePrivate&) = delete; - virtual ~MsgStoragePrivate(); + class MsgStoragePrivate + : public MsgStorage { + public: + MsgStoragePrivate(msg_handle_t serviceHandle); + MsgStoragePrivate(MsgStoragePrivate&) = delete; + MsgStoragePrivate &operator=(MsgStoragePrivate&) = delete; + virtual ~MsgStoragePrivate(); - // Thread: - virtual MsgThreadListRef getThreadList(); - virtual MsgThreadItemRef getThread(ThreadId id); - virtual ThreadId getThreadId(const MsgAddressList &addressList); - virtual ThreadId getThreadId(const std::list &addressList); - virtual ThreadId getThreadId(MsgId id); - virtual bool deleteThread(ThreadId id); - virtual MsgAddressListRef getAddressList(ThreadId id); - virtual MsgThreadListRef searchThread(const std::string &word); - virtual void setReadStatus(ThreadId id); - virtual int getUnreadThreadCount() const; + // Thread: + virtual MsgThreadListRef getThreadList(); + virtual MsgThreadItemRef getThread(ThreadId id); + virtual ThreadId getThreadId(const MsgAddressList &addressList); + virtual ThreadId getThreadId(const std::list &addressList); + virtual ThreadId getThreadId(MsgId id); + virtual bool deleteThread(ThreadId id); + virtual MsgAddressListRef getAddressList(ThreadId id); + virtual MsgThreadListRef searchThread(const std::string &word); + virtual void setReadStatus(ThreadId id); + virtual int getUnreadThreadCount() const; - // Message: - virtual MessageSMSListRef getSimMsgList(); - virtual MessageRef getMessage(MsgId id); + // Message: + virtual MessageSMSListRef getSimMsgList(); + virtual MessageRef getMessage(MsgId id); - /** - *@brief Return id of new message or of updated message - *@param[in] msg - message that we need to save - *@param[in] updateExisting - true if we need to update our message id DB, - * false if we need to save message with new id - *@param[out] result of storage operation. - *@return MessageId - */ - virtual MsgId saveMessage(Message &msg, bool updateExisting, StorageResult *result); - virtual bool deleteMessage(MsgId id); - virtual bool deleteMessages(const MsgIdList &idList); - virtual MessageListRef searchMessage(const std::string &word); - virtual void setReadStatus(MsgId id, bool status); - virtual MsgReportListRef getMsgReportList(MsgId msgId); - virtual bool isReadReportChecked(MsgId msgId); - virtual bool isDeliverReportChecked(MsgId msgId); + /** + *@brief Return id of new message or of updated message + *@param[in] msg - message that we need to save + *@param[in] updateExisting - true if we need to update our message id DB, + * false if we need to save message with new id + *@param[out] result of storage operation. + *@return MessageId + */ + virtual MsgId saveMessage(Message &msg, bool updateExisting, StorageResult *result); + virtual bool deleteMessage(MsgId id); + virtual bool deleteMessages(const MsgIdList &idList); + virtual MessageListRef searchMessage(const std::string &word); + virtual void setReadStatus(MsgId id, bool status); + virtual MsgReportListRef getMsgReportList(MsgId msgId); + virtual bool isReadReportChecked(MsgId msgId); + virtual bool isDeliverReportChecked(MsgId msgId); - // Conversation: - virtual MsgConversationListRef getConversationList(ThreadId id); - virtual MsgConversationItemRef getConversationItem(MsgId id); + // Conversation: + virtual MsgConversationListRef getConversationList(ThreadId id); + virtual MsgConversationItemRef getConversationItem(MsgId id); - private: - template - using ListenerMethod = void (IMsgStorageListener::*)(const T&); + private: + template + using ListenerMethod = void (IMsgStorageListener::*)(const T&); - template - void notifyListeners(const T& delta, ListenerMethod method); + template + void notifyListeners(const T& delta, ListenerMethod method); - static void msg_storage_change_cb(msg_handle_t handle, msg_storage_change_type_t storageChangeType, msg_id_list_s *pMsgIdList, void *user_param); - static void msg_thread_change_cb(msg_handle_t handle, msg_storage_change_type_t storageChangeType, msg_thread_id_t threadId, void *user_param); + static void msg_storage_change_cb(msg_handle_t handle, msg_storage_change_type_t storageChangeType, msg_id_list_s *pMsgIdList, void *user_param); + static void msg_thread_change_cb(msg_handle_t handle, msg_storage_change_type_t storageChangeType, msg_thread_id_t threadId, void *user_param); - MessageSMS *createSms(); + MessageSMS *createSms(); - private: - msg_handle_t m_ServiceHandle; - }; + private: + msg_handle_t m_ServiceHandle; + }; } #endif /* __MSG_STORAGE_PRIVATE_H__ */ diff --git a/src/Common/MsgEngine/src/private/MsgStructListPrivate.h b/src/Common/MsgEngine/src/private/MsgStructListPrivate.h index cd24a92..5fa5107 100644 --- a/src/Common/MsgEngine/src/private/MsgStructListPrivate.h +++ b/src/Common/MsgEngine/src/private/MsgStructListPrivate.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -22,78 +22,78 @@ #include namespace Msg { - static msg_struct_list_s emptyStructList; - - // class T : public BaseT {} - template - class MsgStructListPrivate - : public MsgList { // implement interface - public: - MsgStructListPrivate(bool release, const msg_struct_list_s &list = emptyStructList) - : m_List(list) - , m_Object(false) // release = false - , m_Release(release) - { - } - - virtual ~MsgStructListPrivate() - { - if (m_Release && m_List.nCount) - msg_release_list_struct(&m_List); - } - - virtual BaseT &at(int i) - { - msg_struct_t msgStruct = m_List.msg_struct_info[i]; - m_Object.set(msgStruct); - return m_Object; - } - - virtual const BaseT &at(int i) const - { - msg_struct_t msgStruct = m_List.msg_struct_info[i]; - m_Object.set(msgStruct); - return m_Object; - } - - virtual int getLength() const - { - return m_List.nCount; - } - - inline void set(msg_struct_list_s &list) - { - m_List = list; - } - - inline operator msg_struct_list_s &() - { - return m_List; - } - - inline operator const msg_struct_list_s &() const - { - return m_List; - } - - inline msg_struct_list_s &get() - { - return m_List; - } - - inline const msg_struct_list_s &get() const - { - return m_List; - } - - MsgStructListPrivate(MsgStructListPrivate&) = delete; - MsgStructListPrivate &operator=(MsgStructListPrivate&) = delete; - - protected: - mutable msg_struct_list_s m_List; - mutable T m_Object; - bool m_Release; - }; + static msg_struct_list_s emptyStructList; + + // class T : public BaseT {} + template + class MsgStructListPrivate + : public MsgList { // implement interface + public: + MsgStructListPrivate(bool release, const msg_struct_list_s &list = emptyStructList) + : m_List(list) + , m_Object(false) // release = false + , m_Release(release) + { + } + + virtual ~MsgStructListPrivate() + { + if (m_Release && m_List.nCount) + msg_release_list_struct(&m_List); + } + + virtual BaseT &at(int i) + { + msg_struct_t msgStruct = m_List.msg_struct_info[i]; + m_Object.set(msgStruct); + return m_Object; + } + + virtual const BaseT &at(int i) const + { + msg_struct_t msgStruct = m_List.msg_struct_info[i]; + m_Object.set(msgStruct); + return m_Object; + } + + virtual int getLength() const + { + return m_List.nCount; + } + + inline void set(msg_struct_list_s &list) + { + m_List = list; + } + + inline operator msg_struct_list_s &() + { + return m_List; + } + + inline operator const msg_struct_list_s &() const + { + return m_List; + } + + inline msg_struct_list_s &get() + { + return m_List; + } + + inline const msg_struct_list_s &get() const + { + return m_List; + } + + MsgStructListPrivate(MsgStructListPrivate&) = delete; + MsgStructListPrivate &operator=(MsgStructListPrivate&) = delete; + + protected: + mutable msg_struct_list_s m_List; + mutable T m_Object; + bool m_Release; + }; } #endif /* _MsgStructListPrivate_H__ */ diff --git a/src/Common/MsgEngine/src/private/MsgStructPrivate.h b/src/Common/MsgEngine/src/private/MsgStructPrivate.h index 9913830..eb5701e 100644 --- a/src/Common/MsgEngine/src/private/MsgStructPrivate.h +++ b/src/Common/MsgEngine/src/private/MsgStructPrivate.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -23,42 +23,42 @@ #include namespace Msg { - class MsgStructPrivate { - public: - inline MsgStructPrivate(bool release, msg_struct_t msgStruct = nullptr); - inline virtual ~MsgStructPrivate(); - inline void set(msg_struct_t msgStruct); - inline operator msg_struct_t() const; + class MsgStructPrivate { + public: + inline MsgStructPrivate(bool release, msg_struct_t msgStruct = nullptr); + inline virtual ~MsgStructPrivate(); + inline void set(msg_struct_t msgStruct); + inline operator msg_struct_t() const; - MsgStructPrivate(MsgStructPrivate&) = delete; - MsgStructPrivate &operator=(MsgStructPrivate&) = delete; + MsgStructPrivate(MsgStructPrivate&) = delete; + MsgStructPrivate &operator=(MsgStructPrivate&) = delete; - protected: - msg_struct_t m_MsgStruct; - bool m_Release; - }; + protected: + msg_struct_t m_MsgStruct; + bool m_Release; + }; - inline MsgStructPrivate::MsgStructPrivate(bool release, msg_struct_t msgStruct) - : m_MsgStruct(msgStruct) - , m_Release(release) - { - } + inline MsgStructPrivate::MsgStructPrivate(bool release, msg_struct_t msgStruct) + : m_MsgStruct(msgStruct) + , m_Release(release) + { + } - inline MsgStructPrivate::~MsgStructPrivate() - { - if (m_Release && m_MsgStruct) - msg_release_struct(&m_MsgStruct); - } + inline MsgStructPrivate::~MsgStructPrivate() + { + if (m_Release && m_MsgStruct) + msg_release_struct(&m_MsgStruct); + } - inline void MsgStructPrivate::set(msg_struct_t msgStruct) - { - m_MsgStruct = msgStruct; - } + inline void MsgStructPrivate::set(msg_struct_t msgStruct) + { + m_MsgStruct = msgStruct; + } - inline MsgStructPrivate::operator msg_struct_t() const - { - return m_MsgStruct; - } + inline MsgStructPrivate::operator msg_struct_t() const + { + return m_MsgStruct; + } } #endif /* _MsgStructPrivate_H__ */ diff --git a/src/Common/MsgEngine/src/private/MsgThreadItemPrivate.cpp b/src/Common/MsgEngine/src/private/MsgThreadItemPrivate.cpp index b906f03..09c85ec 100644 --- a/src/Common/MsgEngine/src/private/MsgThreadItemPrivate.cpp +++ b/src/Common/MsgEngine/src/private/MsgThreadItemPrivate.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -25,8 +25,8 @@ using namespace Msg; MsgThreadItemPrivate::MsgThreadItemPrivate(bool release, msg_struct_t msgStruct) - : MsgStructPrivate(release, msgStruct) - , MsgThreadItem() + : MsgStructPrivate(release, msgStruct) + , MsgThreadItem() { } @@ -36,53 +36,53 @@ MsgThreadItemPrivate::~MsgThreadItemPrivate() ThreadId MsgThreadItemPrivate::getId() const { - int id = ThreadId::invalidId; - msg_get_int_value(m_MsgStruct, MSG_THREAD_ID_INT, &id); - return id; + int id = ThreadId::invalidId; + msg_get_int_value(m_MsgStruct, MSG_THREAD_ID_INT, &id); + return id; } std::string MsgThreadItemPrivate::getName() const { - return MsgUtilsPrivate::getStr(m_MsgStruct, MSG_THREAD_NAME_STR, MAX_DISPLAY_NAME_LEN); + return MsgUtilsPrivate::getStr(m_MsgStruct, MSG_THREAD_NAME_STR, MAX_DISPLAY_NAME_LEN); } std::string MsgThreadItemPrivate::getLastMessage() const { - return MsgUtilsPrivate::getStr(m_MsgStruct, MSG_THREAD_MSG_DATA_STR, MAX_MSG_TEXT_LEN); + return MsgUtilsPrivate::getStr(m_MsgStruct, MSG_THREAD_MSG_DATA_STR, MAX_MSG_TEXT_LEN); } time_t MsgThreadItemPrivate::getTime() const { - int time = 0; - msg_get_int_value(m_MsgStruct, MSG_THREAD_MSG_TIME_INT, &time); - return time; + int time = 0; + msg_get_int_value(m_MsgStruct, MSG_THREAD_MSG_TIME_INT, &time); + return time; } bool MsgThreadItemPrivate::hasDraftMessage() const { - bool val = false; - msg_get_bool_value(m_MsgStruct, MSG_THREAD_DRAFT_BOOL, &val); - return val; + bool val = false; + msg_get_bool_value(m_MsgStruct, MSG_THREAD_DRAFT_BOOL, &val); + return val; } bool MsgThreadItemPrivate::hasFailedMessage() const { - bool val = false; - msg_get_bool_value(m_MsgStruct, MSG_THREAD_SEND_FAILED_BOOL, &val); - return val; + bool val = false; + msg_get_bool_value(m_MsgStruct, MSG_THREAD_SEND_FAILED_BOOL, &val); + return val; } bool MsgThreadItemPrivate::isSending() const { - bool val = false; - msg_get_bool_value(m_MsgStruct, MSG_THREAD_SENDING_BOOL, &val); - return val; + bool val = false; + msg_get_bool_value(m_MsgStruct, MSG_THREAD_SENDING_BOOL, &val); + return val; } int MsgThreadItemPrivate::getUnreadCount() const { - int unread = 0; - msg_get_int_value(m_MsgStruct, MSG_THREAD_UNREAD_COUNT_INT, &unread); - return unread; + int unread = 0; + msg_get_int_value(m_MsgStruct, MSG_THREAD_UNREAD_COUNT_INT, &unread); + return unread; } diff --git a/src/Common/MsgEngine/src/private/MsgThreadItemPrivate.h b/src/Common/MsgEngine/src/private/MsgThreadItemPrivate.h index dfe3ede..2593c9d 100644 --- a/src/Common/MsgEngine/src/private/MsgThreadItemPrivate.h +++ b/src/Common/MsgEngine/src/private/MsgThreadItemPrivate.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -23,25 +23,25 @@ #include "MsgStructPrivate.h" namespace Msg { - class MsgThreadItemPrivate - : public MsgStructPrivate - , public MsgThreadItem { - public: - MsgThreadItemPrivate(bool release, msg_struct_t msgStruct = nullptr); - virtual ~MsgThreadItemPrivate(); + class MsgThreadItemPrivate + : public MsgStructPrivate + , public MsgThreadItem { + public: + MsgThreadItemPrivate(bool release, msg_struct_t msgStruct = nullptr); + virtual ~MsgThreadItemPrivate(); - virtual ThreadId getId() const; - virtual std::string getName() const; - virtual std::string getLastMessage() const; - virtual time_t getTime() const; - virtual bool hasDraftMessage() const; - virtual bool hasFailedMessage() const; - virtual bool isSending() const; - virtual int getUnreadCount() const; - }; + virtual ThreadId getId() const; + virtual std::string getName() const; + virtual std::string getLastMessage() const; + virtual time_t getTime() const; + virtual bool hasDraftMessage() const; + virtual bool hasFailedMessage() const; + virtual bool isSending() const; + virtual int getUnreadCount() const; + }; - typedef class MsgListHandlePrivate MsgThreadListHandlePrivate; - typedef class MsgStructListPrivate MsgThreadStructListPrivate; + typedef class MsgListHandlePrivate MsgThreadListHandlePrivate; + typedef class MsgStructListPrivate MsgThreadStructListPrivate; } #endif /* __MSG_THREAD_ITEM_H__ */ diff --git a/src/Common/MsgEngine/src/private/MsgTransportPrivate.cpp b/src/Common/MsgEngine/src/private/MsgTransportPrivate.cpp index d0dbb16..1c787b6 100644 --- a/src/Common/MsgEngine/src/private/MsgTransportPrivate.cpp +++ b/src/Common/MsgEngine/src/private/MsgTransportPrivate.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -24,22 +24,22 @@ using namespace Msg; namespace { - void getReqestId(msg_struct_t req, RequestId *requestId) - { - if (requestId) { - int id = RequestId::invalidId; - msg_get_int_value(req, MSG_REQUEST_REQUESTID_INT, &id); - *requestId = id; - } - } + void getReqestId(msg_struct_t req, RequestId *requestId) + { + if (requestId) { + int id = RequestId::invalidId; + msg_get_int_value(req, MSG_REQUEST_REQUESTID_INT, &id); + *requestId = id; + } + } } MsgTransportPrivate::MsgTransportPrivate(msg_handle_t serviceHandle) - : MsgTransport() - , m_ServiceHandle(serviceHandle) + : MsgTransport() + , m_ServiceHandle(serviceHandle) { - msg_reg_sent_status_callback(m_ServiceHandle, makeCbLast(&MsgTransportPrivate::onSentStatus), this); + msg_reg_sent_status_callback(m_ServiceHandle, makeCbLast(&MsgTransportPrivate::onSentStatus), this); } MsgTransportPrivate::~MsgTransportPrivate() @@ -48,73 +48,73 @@ MsgTransportPrivate::~MsgTransportPrivate() MsgTransport::SendResult MsgTransportPrivate::sendMessage(Message &msg, ThreadId *threadId, RequestId *requestId) { - msg_struct_t req = msg_create_struct(MSG_STRUCT_REQUEST_INFO); - int err = MSG_SUCCESS; + msg_struct_t req = msg_create_struct(MSG_STRUCT_REQUEST_INFO); + int err = MSG_SUCCESS; - msg_struct_t sendOpt = nullptr; - msg_get_struct_handle(req, MSG_REQUEST_SENDOPT_HND, &sendOpt); - msg_set_bool_value(sendOpt, MSG_SEND_OPT_SETTING_BOOL, false); + msg_struct_t sendOpt = nullptr; + msg_get_struct_handle(req, MSG_REQUEST_SENDOPT_HND, &sendOpt); + msg_set_bool_value(sendOpt, MSG_SEND_OPT_SETTING_BOOL, false); - MessagePrivate &privMsg = dynamic_cast(msg); - privMsg.commit(); + MessagePrivate &privMsg = dynamic_cast(msg); + privMsg.commit(); - msg_set_struct_handle(req, MSG_REQUEST_MESSAGE_HND, privMsg); + msg_set_struct_handle(req, MSG_REQUEST_MESSAGE_HND, privMsg); - if (privMsg.isMms()) { - MSG_LOG("Sending MMS"); - err = msg_mms_send_message(m_ServiceHandle, req); - } else { - MSG_LOG("Sending SMS"); - err = msg_sms_send_message(m_ServiceHandle, req); - } + if (privMsg.isMms()) { + MSG_LOG("Sending MMS"); + err = msg_mms_send_message(m_ServiceHandle, req); + } else { + MSG_LOG("Sending SMS"); + err = msg_sms_send_message(m_ServiceHandle, req); + } - if (threadId) - msg_get_thread_id_by_address2(m_ServiceHandle, privMsg.getAddressList(), (msg_thread_id_t*)threadId); + if (threadId) + msg_get_thread_id_by_address2(m_ServiceHandle, privMsg.getAddressList(), (msg_thread_id_t*)threadId); - getReqestId(req, requestId); - msg_release_struct(&req); + getReqestId(req, requestId); + msg_release_struct(&req); - MsgTransport::SendResult sendRes = MsgUtilsPrivate::nativeToSendResult(err); - MSG_LOG("Send raw result: ", err); - MSG_LOG("Send result: ", sendRes); - return sendRes; + MsgTransport::SendResult sendRes = MsgUtilsPrivate::nativeToSendResult(err); + MSG_LOG("Send raw result: ", err); + MSG_LOG("Send result: ", sendRes); + return sendRes; } MsgTransport::SendResult MsgTransportPrivate::retrieveMessage(MsgId msgId, RequestId *requestId) { - msg_struct_t req = msg_create_struct(MSG_STRUCT_REQUEST_INFO); - msg_struct_t sendOpt = msg_create_struct(MSG_STRUCT_SENDOPT); - msg_struct_t retrieveMsg = msg_create_struct(MSG_STRUCT_MESSAGE_INFO); + msg_struct_t req = msg_create_struct(MSG_STRUCT_REQUEST_INFO); + msg_struct_t sendOpt = msg_create_struct(MSG_STRUCT_SENDOPT); + msg_struct_t retrieveMsg = msg_create_struct(MSG_STRUCT_MESSAGE_INFO); - msg_get_message(m_ServiceHandle, msgId, retrieveMsg, sendOpt); - msg_set_struct_handle(req, MSG_REQUEST_MESSAGE_HND, retrieveMsg); - msg_set_struct_handle(req, MSG_REQUEST_SENDOPT_HND, sendOpt); + msg_get_message(m_ServiceHandle, msgId, retrieveMsg, sendOpt); + msg_set_struct_handle(req, MSG_REQUEST_MESSAGE_HND, retrieveMsg); + msg_set_struct_handle(req, MSG_REQUEST_SENDOPT_HND, sendOpt); - msg_error_t err = msg_mms_retrieve_message(m_ServiceHandle, req); - MSG_LOG("Retrieve message result: ", err); + msg_error_t err = msg_mms_retrieve_message(m_ServiceHandle, req); + MSG_LOG("Retrieve message result: ", err); - getReqestId(req, requestId); + getReqestId(req, requestId); - msg_release_struct(&retrieveMsg); - msg_release_struct(&sendOpt); - msg_release_struct(&req); + msg_release_struct(&retrieveMsg); + msg_release_struct(&sendOpt); + msg_release_struct(&req); - MsgTransport::SendResult sendRes = MsgUtilsPrivate::nativeToSendResult(err); - MSG_LOG("Send result: ", sendRes); - return sendRes; + 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); - MSG_LOG("Send result: ", sendRes); - return sendRes; + msg_error_t err = msg_mms_send_read_report(m_ServiceHandle, msgId, MsgUtilsPrivate::reportReadReportStatusToNative(status)); + MsgTransport::SendResult sendRes = MsgUtilsPrivate::nativeToSendResult(err); + MSG_LOG("Send result: ", sendRes); + return sendRes; } void MsgTransportPrivate::onSentStatus(msg_handle_t handle, msg_struct_t sent_status) { - MSG_LOG(""); - MsgSentStatusPrivate status(sent_status); - notifyListenersOnSentStatus(status); + MSG_LOG(""); + MsgSentStatusPrivate status(sent_status); + notifyListenersOnSentStatus(status); } diff --git a/src/Common/MsgEngine/src/private/MsgTransportPrivate.h b/src/Common/MsgEngine/src/private/MsgTransportPrivate.h index 7d8074f..f3f2dfb 100644 --- a/src/Common/MsgEngine/src/private/MsgTransportPrivate.h +++ b/src/Common/MsgEngine/src/private/MsgTransportPrivate.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -24,25 +24,25 @@ #include namespace Msg { - /** - * @brief Private msg-service API specific implementation of sending messages routine. - */ - class MsgTransportPrivate - : public MsgTransport { - public: - MsgTransportPrivate(msg_handle_t serviceHandle); - virtual ~MsgTransportPrivate(); - - SendResult sendMessage(Message &msg, ThreadId *threadId, RequestId *requestId) override; - SendResult retrieveMessage(MsgId msgId, RequestId *requestId) override; - SendResult sendReadReport(MsgId msgId, MsgReport::ReadStatus status) override; - - private: - void onSentStatus(msg_handle_t handle, msg_struct_t sent_status); - - private: - msg_handle_t m_ServiceHandle; - }; + /** + * @brief Private msg-service API specific implementation of sending messages routine. + */ + class MsgTransportPrivate + : public MsgTransport { + public: + MsgTransportPrivate(msg_handle_t serviceHandle); + virtual ~MsgTransportPrivate(); + + SendResult sendMessage(Message &msg, ThreadId *threadId, RequestId *requestId) override; + SendResult retrieveMessage(MsgId msgId, RequestId *requestId) override; + SendResult sendReadReport(MsgId msgId, MsgReport::ReadStatus status) override; + + private: + void onSentStatus(msg_handle_t handle, msg_struct_t sent_status); + + private: + msg_handle_t m_ServiceHandle; + }; } #endif /* _MSG_TRANSPORT_PRIVATE_H__ */ diff --git a/src/Common/MsgEngine/src/private/MsgUtilsPrivate.cpp b/src/Common/MsgEngine/src/private/MsgUtilsPrivate.cpp index 01d3c6f..557f09d 100644 --- a/src/Common/MsgEngine/src/private/MsgUtilsPrivate.cpp +++ b/src/Common/MsgEngine/src/private/MsgUtilsPrivate.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -21,344 +21,344 @@ using namespace Msg; int MsgUtilsPrivate::directionToNative(Message::Direction direction) { - switch (direction) { - case Message::MD_Sent: - return MSG_DIRECTION_TYPE_MO; - case Message::MD_Received: - return MSG_DIRECTION_TYPE_MT; - } - assert(false); - return MSG_DIRECTION_TYPE_MO; + switch (direction) { + case Message::MD_Sent: + return MSG_DIRECTION_TYPE_MO; + case Message::MD_Received: + return MSG_DIRECTION_TYPE_MT; + } + assert(false); + return MSG_DIRECTION_TYPE_MO; } Message::Direction MsgUtilsPrivate::nativeToDirection(int direction) { - switch (direction) { - case MSG_DIRECTION_TYPE_MO: - return Message::MD_Sent; - case MSG_DIRECTION_TYPE_MT: - return Message::MD_Received; - } - assert(false); - return Message::MD_Sent; + switch (direction) { + case MSG_DIRECTION_TYPE_MO: + return Message::MD_Sent; + case MSG_DIRECTION_TYPE_MT: + return Message::MD_Received; + } + assert(false); + return Message::MD_Sent; } Message::MessageStorageType MsgUtilsPrivate::nativeToMessageStorage(int id) { - switch (id) { - case MSG_STORAGE_PHONE: - return Message::MS_Phone; - case MSG_STORAGE_SIM: - return Message::MS_Sim; - } - assert(false); - return Message::MS_Unknown; + switch (id) { + case MSG_STORAGE_PHONE: + return Message::MS_Phone; + case MSG_STORAGE_SIM: + return Message::MS_Sim; + } + assert(false); + return Message::MS_Unknown; } int MsgUtilsPrivate::addressTypeToNative(MsgAddress::AddressType type) { - switch (type) { - case MsgAddress::Phone: - return MSG_ADDRESS_TYPE_PLMN; - case MsgAddress::Email: - return MSG_ADDRESS_TYPE_EMAIL; - default: - case MsgAddress::UnknownAddressType: - return MSG_ADDRESS_TYPE_UNKNOWN; - } + switch (type) { + case MsgAddress::Phone: + return MSG_ADDRESS_TYPE_PLMN; + case MsgAddress::Email: + return MSG_ADDRESS_TYPE_EMAIL; + default: + case MsgAddress::UnknownAddressType: + return MSG_ADDRESS_TYPE_UNKNOWN; + } } MsgAddress::AddressType MsgUtilsPrivate::nativeToAddressType(int type) { - switch (type) { - case MSG_ADDRESS_TYPE_PLMN: - return MsgAddress::Phone; - case MSG_ADDRESS_TYPE_EMAIL: - return MsgAddress::Email; - default: - case MSG_ADDRESS_TYPE_UNKNOWN: - return MsgAddress::UnknownAddressType; - } + switch (type) { + case MSG_ADDRESS_TYPE_PLMN: + return MsgAddress::Phone; + case MSG_ADDRESS_TYPE_EMAIL: + return MsgAddress::Email; + default: + case MSG_ADDRESS_TYPE_UNKNOWN: + return MsgAddress::UnknownAddressType; + } } MsgReport::DeliveryStatus MsgUtilsPrivate::nativeToReportDeliveryStatus(int status) { - switch (status) { - case MSG_DELIVERY_REPORT_SUCCESS: - return MsgReport::StatusSuccess; - case MSG_DELIVERY_REPORT_EXPIRED: - return MsgReport::StatusExpired; - case MSG_DELIVERY_REPORT_REJECTED: - return MsgReport::StatusRejected; - default: - case MSG_DELIVERY_REPORT_NONE: - return MsgReport::StatusNone; - } + switch (status) { + case MSG_DELIVERY_REPORT_SUCCESS: + return MsgReport::StatusSuccess; + case MSG_DELIVERY_REPORT_EXPIRED: + return MsgReport::StatusExpired; + case MSG_DELIVERY_REPORT_REJECTED: + return MsgReport::StatusRejected; + default: + case MSG_DELIVERY_REPORT_NONE: + return MsgReport::StatusNone; + } } MsgReport::ReadStatus MsgUtilsPrivate::nativeToReportReadStatus(int status) { - switch (status) { - case MSG_READ_REPORT_IS_READ: - return MsgReport::ReadStatusIsRead; - case MSG_READ_REPORT_IS_DELETED: - return MsgReport::ReadStatusIsDeleted; - case MSG_READ_REPORT_REJECT_BY_USER: - return MsgReport::ReadStatusRejectByUser; - default: - case MSG_READ_REPORT_NONE: - return MsgReport::ReadStatusNone; - } + switch (status) { + case MSG_READ_REPORT_IS_READ: + return MsgReport::ReadStatusIsRead; + case MSG_READ_REPORT_IS_DELETED: + return MsgReport::ReadStatusIsDeleted; + case MSG_READ_REPORT_REJECT_BY_USER: + return MsgReport::ReadStatusRejectByUser; + default: + case MSG_READ_REPORT_NONE: + return MsgReport::ReadStatusNone; + } } int MsgUtilsPrivate::reportReadReportStatusToNative(MsgReport::ReadStatus status) { - switch (status) { - case MsgReport::ReadStatusIsRead: - return MSG_READ_REPORT_IS_READ; - case MsgReport::ReadStatusIsDeleted: - return MSG_READ_REPORT_IS_DELETED; - case MsgReport::ReadStatusRejectByUser: - return MSG_READ_REPORT_REJECT_BY_USER; - default: - case MsgReport::ReadStatusNone: - return MSG_READ_REPORT_NONE; - } + switch (status) { + case MsgReport::ReadStatusIsRead: + return MSG_READ_REPORT_IS_READ; + case MsgReport::ReadStatusIsDeleted: + return MSG_READ_REPORT_IS_DELETED; + case MsgReport::ReadStatusRejectByUser: + return MSG_READ_REPORT_REJECT_BY_USER; + default: + case MsgReport::ReadStatusNone: + return MSG_READ_REPORT_NONE; + } } MsgReport::Type MsgUtilsPrivate::nativeToReportType(int type) { - switch (type) { - case MSG_REPORT_TYPE_READ: - return MsgReport::TypeRead; - case MSG_REPORT_TYPE_READ_REPORT_SENT: - return MsgReport::TypeReadReportSent; - default: - case MSG_REPORT_TYPE_DELIVERY: - return MsgReport::TypeDelivery; - } + switch (type) { + case MSG_REPORT_TYPE_READ: + return MsgReport::TypeRead; + case MSG_REPORT_TYPE_READ_REPORT_SENT: + return MsgReport::TypeReadReportSent; + default: + case MSG_REPORT_TYPE_DELIVERY: + return MsgReport::TypeDelivery; + } } int MsgUtilsPrivate::recipientTypeToNative(MsgAddress::RecipientType type) { - switch (type) { - case MsgAddress::To: - return MSG_RECIPIENTS_TYPE_TO; - case MsgAddress::Cc: - return MSG_RECIPIENTS_TYPE_CC; - case MsgAddress::Bcc: - return MSG_RECIPIENTS_TYPE_BCC; - default: - case MsgAddress::UnknownRecipientType: - return MSG_RECIPIENTS_TYPE_UNKNOWN; - } + switch (type) { + case MsgAddress::To: + return MSG_RECIPIENTS_TYPE_TO; + case MsgAddress::Cc: + return MSG_RECIPIENTS_TYPE_CC; + case MsgAddress::Bcc: + return MSG_RECIPIENTS_TYPE_BCC; + default: + case MsgAddress::UnknownRecipientType: + return MSG_RECIPIENTS_TYPE_UNKNOWN; + } } MsgAddress::RecipientType MsgUtilsPrivate::nativeToRecipientType(int type) { - switch (type) { - case MSG_RECIPIENTS_TYPE_TO: - return MsgAddress::To; - case MSG_RECIPIENTS_TYPE_CC: - return MsgAddress::Cc; - case MSG_RECIPIENTS_TYPE_BCC: - return MsgAddress::Bcc; - default: - case MSG_RECIPIENTS_TYPE_UNKNOWN: - return MsgAddress::UnknownRecipientType; - } + switch (type) { + case MSG_RECIPIENTS_TYPE_TO: + return MsgAddress::To; + case MSG_RECIPIENTS_TYPE_CC: + return MsgAddress::Cc; + case MSG_RECIPIENTS_TYPE_BCC: + return MsgAddress::Bcc; + default: + case MSG_RECIPIENTS_TYPE_UNKNOWN: + return MsgAddress::UnknownRecipientType; + } } Message::Type MsgUtilsPrivate::nativeToMessageType(int type) { - switch (type) { - case MSG_TYPE_SMS: - case MSG_TYPE_SMS_CB: - case MSG_TYPE_SMS_JAVACB: - case MSG_TYPE_SMS_WAPPUSH: - case MSG_TYPE_SMS_MWI: - case MSG_TYPE_SMS_SYNCML: - case MSG_TYPE_SMS_REJECT: - case MSG_TYPE_SMS_ETWS_PRIMARY: - case MSG_TYPE_SMS_ETWS_SECONDARY: - case MSG_TYPE_SMS_CMAS_PRESIDENTIAL: - case MSG_TYPE_SMS_CMAS_EXTREME: - case MSG_TYPE_SMS_CMAS_SEVERE: - case MSG_TYPE_SMS_CMAS_AMBER: - case MSG_TYPE_SMS_CMAS_TEST: - case MSG_TYPE_SMS_CMAS_EXERCISE: - case MSG_TYPE_SMS_CMAS_OPERATOR_DEFINED: - return Message::MT_SMS; + switch (type) { + case MSG_TYPE_SMS: + case MSG_TYPE_SMS_CB: + case MSG_TYPE_SMS_JAVACB: + case MSG_TYPE_SMS_WAPPUSH: + case MSG_TYPE_SMS_MWI: + case MSG_TYPE_SMS_SYNCML: + case MSG_TYPE_SMS_REJECT: + case MSG_TYPE_SMS_ETWS_PRIMARY: + case MSG_TYPE_SMS_ETWS_SECONDARY: + case MSG_TYPE_SMS_CMAS_PRESIDENTIAL: + case MSG_TYPE_SMS_CMAS_EXTREME: + case MSG_TYPE_SMS_CMAS_SEVERE: + case MSG_TYPE_SMS_CMAS_AMBER: + case MSG_TYPE_SMS_CMAS_TEST: + case MSG_TYPE_SMS_CMAS_EXERCISE: + case MSG_TYPE_SMS_CMAS_OPERATOR_DEFINED: + return Message::MT_SMS; - case MSG_TYPE_MMS: - case MSG_TYPE_MMS_JAVA: - return Message::MT_MMS; + case MSG_TYPE_MMS: + case MSG_TYPE_MMS_JAVA: + return Message::MT_MMS; - case MSG_TYPE_MMS_NOTI: - return Message::MT_MMS_Noti; + case MSG_TYPE_MMS_NOTI: + return Message::MT_MMS_Noti; - default: - return Message::MT_Unknown; - } + default: + return Message::MT_Unknown; + } } MsgMedia::Type MsgUtilsPrivate::nativeToSmilType(int type) { - switch (type) { - case MMS_SMIL_MEDIA_IMG: - return MsgMedia::ImageType; - case MMS_SMIL_MEDIA_AUDIO: - return MsgMedia::AudioType; - case MMS_SMIL_MEDIA_VIDEO: - return MsgMedia::VideoType; - case MMS_SMIL_MEDIA_TEXT: - return MsgMedia::TextType; - } - return MsgMedia::UnknownType; + switch (type) { + case MMS_SMIL_MEDIA_IMG: + return MsgMedia::ImageType; + case MMS_SMIL_MEDIA_AUDIO: + return MsgMedia::AudioType; + case MMS_SMIL_MEDIA_VIDEO: + return MsgMedia::VideoType; + case MMS_SMIL_MEDIA_TEXT: + return MsgMedia::TextType; + } + return MsgMedia::UnknownType; } int MsgUtilsPrivate::smilTypeToNative(MsgMedia::Type type) { - switch (type) { - case MsgMedia::ImageType: - return MMS_SMIL_MEDIA_IMG; - case MsgMedia::AudioType: - return MMS_SMIL_MEDIA_AUDIO; - case MsgMedia::VideoType: - return MMS_SMIL_MEDIA_VIDEO; - case MsgMedia::TextType: - return MMS_SMIL_MEDIA_TEXT; - case MsgMedia::UnknownType: - break; - } - return MMS_SMIL_MEDIA_INVALID; + switch (type) { + case MsgMedia::ImageType: + return MMS_SMIL_MEDIA_IMG; + case MsgMedia::AudioType: + return MMS_SMIL_MEDIA_AUDIO; + case MsgMedia::VideoType: + return MMS_SMIL_MEDIA_VIDEO; + case MsgMedia::TextType: + return MMS_SMIL_MEDIA_TEXT; + case MsgMedia::UnknownType: + break; + } + return MMS_SMIL_MEDIA_INVALID; } std::string MsgUtilsPrivate::getStr(msg_struct_t msgStruct, int field, int maxStrLen) { - std::string res; - char buf[maxStrLen + 1]; - if (msg_get_str_value(msgStruct, field, buf, maxStrLen) == 0) - res.assign(buf); + std::string res; + char buf[maxStrLen + 1]; + if (msg_get_str_value(msgStruct, field, buf, maxStrLen) == 0) + res.assign(buf); - return res; + return res; } int MsgUtilsPrivate::setStr(msg_struct_t msgStruct, int field, const std::string &text) { - return msg_set_str_value(msgStruct, field, text.c_str(), text.length()); + return msg_set_str_value(msgStruct, field, text.c_str(), text.length()); } Message::NetworkStatus MsgUtilsPrivate::nativeToNetworkStatus(int status) { - switch (status) { - case MSG_NETWORK_NOT_SEND: - return Message::NS_Not_Send; - case MSG_NETWORK_SENDING: - return Message::NS_Sending; - case MSG_NETWORK_SEND_SUCCESS: - return Message::NS_Send_Success; - case MSG_NETWORK_SEND_FAIL: - case MSG_NETWORK_SEND_TIMEOUT: - case MSG_NETWORK_SEND_FAIL_MANDATORY_INFO_MISSING: - case MSG_NETWORK_SEND_FAIL_TEMPORARY: - case MSG_NETWORK_SEND_FAIL_BY_MO_CONTROL_WITH_MOD: - case MSG_NETWORK_SEND_FAIL_BY_MO_CONTROL_NOT_ALLOWED: - return Message::NS_Send_Fail; - case MSG_NETWORK_DELIVER_SUCCESS: - return Message::NS_Deliver_Success; - case MSG_NETWORK_DELIVER_FAIL: - return Message::NS_Deliver_Fail; - case MSG_NETWORK_RECEIVED: - return Message::NS_Received; - case MSG_NETWORK_REQ_CANCELLED: - return Message::NS_Req_Cancelled; - case MSG_NETWORK_RETRIEVING: - return Message::NS_Retrieving; - case MSG_NETWORK_RETRIEVE_SUCCESS: - return Message::NS_Retrieve_Success; - case MSG_NETWORK_RETRIEVE_FAIL: - return Message::NS_Retrieve_Fail; - case MSG_NETWORK_DELIVER_PENDING: - return Message::NS_Deliver_Pending; - case MSG_NETWORK_DELIVER_EXPIRED: - return Message::NS_Deliver_Expired; - case MSG_NETWORK_SEND_PENDING: - return Message::NS_Send_Pending; - default: - break; - }; - return Message::NS_Unknown; + switch (status) { + case MSG_NETWORK_NOT_SEND: + return Message::NS_Not_Send; + case MSG_NETWORK_SENDING: + return Message::NS_Sending; + case MSG_NETWORK_SEND_SUCCESS: + return Message::NS_Send_Success; + case MSG_NETWORK_SEND_FAIL: + case MSG_NETWORK_SEND_TIMEOUT: + case MSG_NETWORK_SEND_FAIL_MANDATORY_INFO_MISSING: + case MSG_NETWORK_SEND_FAIL_TEMPORARY: + case MSG_NETWORK_SEND_FAIL_BY_MO_CONTROL_WITH_MOD: + case MSG_NETWORK_SEND_FAIL_BY_MO_CONTROL_NOT_ALLOWED: + return Message::NS_Send_Fail; + case MSG_NETWORK_DELIVER_SUCCESS: + return Message::NS_Deliver_Success; + case MSG_NETWORK_DELIVER_FAIL: + return Message::NS_Deliver_Fail; + case MSG_NETWORK_RECEIVED: + return Message::NS_Received; + case MSG_NETWORK_REQ_CANCELLED: + return Message::NS_Req_Cancelled; + case MSG_NETWORK_RETRIEVING: + return Message::NS_Retrieving; + case MSG_NETWORK_RETRIEVE_SUCCESS: + return Message::NS_Retrieve_Success; + case MSG_NETWORK_RETRIEVE_FAIL: + return Message::NS_Retrieve_Fail; + case MSG_NETWORK_DELIVER_PENDING: + return Message::NS_Deliver_Pending; + case MSG_NETWORK_DELIVER_EXPIRED: + return Message::NS_Deliver_Expired; + case MSG_NETWORK_SEND_PENDING: + return Message::NS_Send_Pending; + default: + break; + }; + return Message::NS_Unknown; } int MsgUtilsPrivate::activeNotifPolicyToNative(MsgSettings::ActiveNotifPolicy policy) { - switch (policy) { - case MsgSettings::AppBackgroundPolicy: - return -1; - case MsgSettings::AppForegroundPolicy: - return 0; - default: - assert(false); - } - return 0; + switch (policy) { + case MsgSettings::AppBackgroundPolicy: + return -1; + case MsgSettings::AppForegroundPolicy: + return 0; + default: + assert(false); + } + return 0; } MsgTransport::SendResult MsgUtilsPrivate::nativeToSendResult(int sendRes) { - switch (sendRes) { - case MSG_SUCCESS: - return MsgTransport::SendSuccess; - case MSG_ERR_NO_SIM: - return MsgTransport::SendNoSIM; - case MSG_ERR_DPM_RESTRICT: - return MsgTransport::SendDPMRestricted; - case MSG_ERR_READREPORT_NOT_REQUESTED: - return MsgTransport::SendReadReportNotReq; - case MSG_ERR_READREPORT_ALEADY_SENT: - return MsgTransport::SendReadReportAlreadySent; - default: - return MsgTransport::SendFail; - } + switch (sendRes) { + case MSG_SUCCESS: + return MsgTransport::SendSuccess; + case MSG_ERR_NO_SIM: + return MsgTransport::SendNoSIM; + case MSG_ERR_DPM_RESTRICT: + return MsgTransport::SendDPMRestricted; + case MSG_ERR_READREPORT_NOT_REQUESTED: + return MsgTransport::SendReadReportNotReq; + case MSG_ERR_READREPORT_ALEADY_SENT: + return MsgTransport::SendReadReportAlreadySent; + default: + return MsgTransport::SendFail; + } } MsgSettings::RingtoneType MsgUtilsPrivate::nativeToRingtoneType(int type) { - switch (type) { - case MSG_RINGTONE_TYPE_SILENT: - return MsgSettings::SilentRingtone; - case MSG_RINGTONE_TYPE_USER: - return MsgSettings::UserRingtone; - case MSG_RINGTONE_TYPE_DEFAULT: - return MsgSettings::DefaultRingtone; - } - return MsgSettings::DefaultRingtone; + switch (type) { + case MSG_RINGTONE_TYPE_SILENT: + return MsgSettings::SilentRingtone; + case MSG_RINGTONE_TYPE_USER: + return MsgSettings::UserRingtone; + case MSG_RINGTONE_TYPE_DEFAULT: + return MsgSettings::DefaultRingtone; + } + return MsgSettings::DefaultRingtone; } int MsgUtilsPrivate::ringtoneTypeToNative(MsgSettings::RingtoneType type) { - switch (type) { - case MsgSettings::SilentRingtone: - return MSG_RINGTONE_TYPE_SILENT; - case MsgSettings::UserRingtone: - return MSG_RINGTONE_TYPE_USER; - default: - break; - } - return MSG_RINGTONE_TYPE_DEFAULT; + switch (type) { + case MsgSettings::SilentRingtone: + return MSG_RINGTONE_TYPE_SILENT; + case MsgSettings::UserRingtone: + return MSG_RINGTONE_TYPE_USER; + default: + break; + } + return MSG_RINGTONE_TYPE_DEFAULT; } MsgStorage::StorageResult MsgUtilsPrivate::nativeToStorageResult(int resultCode) { - MsgStorage::StorageResult res = MsgStorage::StorageFail; - switch (resultCode) { - case MSG_SUCCESS: - res = MsgStorage::StorageSuccess; - break; - case MSG_ERR_SIM_STORAGE_FULL: - res = MsgStorage::StorageSimFull; - break; - } - return res; + MsgStorage::StorageResult res = MsgStorage::StorageFail; + switch (resultCode) { + case MSG_SUCCESS: + res = MsgStorage::StorageSuccess; + break; + case MSG_ERR_SIM_STORAGE_FULL: + res = MsgStorage::StorageSimFull; + break; + } + return res; } diff --git a/src/Common/MsgEngine/src/private/MsgUtilsPrivate.h b/src/Common/MsgEngine/src/private/MsgUtilsPrivate.h index ea77284..6c1cec2 100644 --- a/src/Common/MsgEngine/src/private/MsgUtilsPrivate.h +++ b/src/Common/MsgEngine/src/private/MsgUtilsPrivate.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -32,32 +32,32 @@ #include namespace Msg { - class MsgUtilsPrivate { - public: - static int directionToNative(Message::Direction direction); - static int addressTypeToNative(MsgAddress::AddressType type); - static int recipientTypeToNative(MsgAddress::RecipientType type); - static Message::Direction nativeToDirection(int direction); - static Message::MessageStorageType nativeToMessageStorage(int id); - static MsgAddress::AddressType nativeToAddressType(int type); - static MsgAddress::RecipientType nativeToRecipientType(int type); - static MsgReport::DeliveryStatus nativeToReportDeliveryStatus(int status); - static MsgReport::ReadStatus nativeToReportReadStatus(int status); - static int reportReadReportStatusToNative(MsgReport::ReadStatus status); - static MsgReport::Type nativeToReportType(int type); - static Message::Type nativeToMessageType(int type); - static MsgMedia::Type nativeToSmilType(int type); - static int smilTypeToNative(MsgMedia::Type type); - static Message::NetworkStatus nativeToNetworkStatus(int status); - static int activeNotifPolicyToNative(MsgSettings::ActiveNotifPolicy policy); - static MsgTransport::SendResult nativeToSendResult(int sendRes); - static MsgSettings::RingtoneType nativeToRingtoneType(int type); - static int ringtoneTypeToNative(MsgSettings::RingtoneType type); - static MsgStorage::StorageResult nativeToStorageResult(int resultCode); + class MsgUtilsPrivate { + public: + static int directionToNative(Message::Direction direction); + static int addressTypeToNative(MsgAddress::AddressType type); + static int recipientTypeToNative(MsgAddress::RecipientType type); + static Message::Direction nativeToDirection(int direction); + static Message::MessageStorageType nativeToMessageStorage(int id); + static MsgAddress::AddressType nativeToAddressType(int type); + static MsgAddress::RecipientType nativeToRecipientType(int type); + static MsgReport::DeliveryStatus nativeToReportDeliveryStatus(int status); + static MsgReport::ReadStatus nativeToReportReadStatus(int status); + static int reportReadReportStatusToNative(MsgReport::ReadStatus status); + static MsgReport::Type nativeToReportType(int type); + static Message::Type nativeToMessageType(int type); + static MsgMedia::Type nativeToSmilType(int type); + static int smilTypeToNative(MsgMedia::Type type); + static Message::NetworkStatus nativeToNetworkStatus(int status); + static int activeNotifPolicyToNative(MsgSettings::ActiveNotifPolicy policy); + static MsgTransport::SendResult nativeToSendResult(int sendRes); + static MsgSettings::RingtoneType nativeToRingtoneType(int type); + static int ringtoneTypeToNative(MsgSettings::RingtoneType type); + static MsgStorage::StorageResult nativeToStorageResult(int resultCode); - static std::string getStr(msg_struct_t msgStruct, int field, int maxStrLen); - static int setStr(msg_struct_t msgStruct, int field, const std::string &text); - }; + static std::string getStr(msg_struct_t msgStruct, int field, int maxStrLen); + static int setStr(msg_struct_t msgStruct, int field, const std::string &text); + }; } #endif /* _MESSAGE_UTILS_PRIVATE_H__ */ diff --git a/src/Common/Recipient/inc/Recipient.h b/src/Common/Recipient/inc/Recipient.h index 5c002c6..f1a1d93 100644 --- a/src/Common/Recipient/inc/Recipient.h +++ b/src/Common/Recipient/inc/Recipient.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -23,61 +23,61 @@ #include namespace Msg { - class Recipient { + class Recipient { - public: - explicit Recipient(std::string address, std::string dispName = {}); - Recipient(); - ~Recipient(); + public: + explicit Recipient(std::string address, std::string dispName = {}); + Recipient(); + ~Recipient(); - void clear(); - const std::string &getAddress() const; - const std::string &getDispName() const; - void setAddress(std::string address); - void setDispName(std::string dispName); - bool isValid() const; - void updateContactInfo(); + void clear(); + const std::string &getAddress() const; + const std::string &getDispName() const; + void setAddress(std::string address); + void setDispName(std::string dispName); + bool isValid() const; + void updateContactInfo(); - /** - * @brief Search first valid recipient in ContactPersonNumber and ContactPersonPhoneLog based on a given search word. - * @param searchWord - search keyword - * @return recipient - */ - static Recipient searchFirst(const std::string &searchWord); + /** + * @brief Search first valid recipient in ContactPersonNumber and ContactPersonPhoneLog based on a given search word. + * @param searchWord - search keyword + * @return recipient + */ + static Recipient searchFirst(const std::string &searchWord); - /** - * @brief Search all recipient in ContactPersonNumber and ContactPersonPhoneLog based on a given search word. - * @param searchWord - search keyword - * @return list of recipients - */ - static std::list searchAll(const std::string &searchWord); + /** + * @brief Search all recipient in ContactPersonNumber and ContactPersonPhoneLog based on a given search word. + * @param searchWord - search keyword + * @return list of recipients + */ + static std::list searchAll(const std::string &searchWord); - /** - * @brief Get recipient by address - * @param address - the match exactly address - * @return recipient - */ - static Recipient getByAddress(const std::string &address); + /** + * @brief Get recipient by address + * @param address - the match exactly address + * @return recipient + */ + static Recipient getByAddress(const std::string &address); - /** - * @brief Get recipient by ThreadId - * @param id valid thread id - * @return recipient - */ - static Recipient getByThreadId(ThreadId id); + /** + * @brief Get recipient by ThreadId + * @param id valid thread id + * @return recipient + */ + static Recipient getByThreadId(ThreadId id); - /** - * @brief Get recipient by contact person number id - * @param id valid contact id - * @return recipient - */ - static Recipient getByContactPersonNmberId(int id); + /** + * @brief Get recipient by contact person number id + * @param id valid contact id + * @return recipient + */ + static Recipient getByContactPersonNmberId(int id); - private: - std::string m_Address; - std::string m_DispName; - }; + private: + std::string m_Address; + std::string m_DispName; + }; } #endif /* RecipInputFrame_h_ */ diff --git a/src/Common/Recipient/src/Recipient.cpp b/src/Common/Recipient/src/Recipient.cpp index 646a06f..5253e10 100644 --- a/src/Common/Recipient/src/Recipient.cpp +++ b/src/Common/Recipient/src/Recipient.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -27,73 +27,73 @@ using namespace Msg; namespace { - template - Recipient toRecip(const ContactRec &rec) - { - Recipient res; - - res.setDispName(rec.getDispName()); - res.setAddress(rec.getAddress()); - - if (res.getDispName().empty()) - res.setDispName(res.getAddress()); - - return res; - } - - template - Recipient toRecip(const std::shared_ptr &rec) - { - Recipient res; - if (rec) - res = toRecip(*rec); - return res; - } - - template - bool isValid(const ContactRec &rec) - { - return rec.isValid() && MsgUtils::isValidAddress(rec.getAddress()); - } - - template - std::shared_ptr searchFirstContact(const std::string &searchWord) - { - if (!searchWord.empty()) { - auto list = App::getInst().getContactManager().search(searchWord); - if (list) { - do { - auto &rec = list->get(); - if (isValid(rec)) { - return std::static_pointer_cast(rec.clone()); - } else { - MSG_LOG("Skip invalid contact: ", rec.getAddress()); - } - } while (list->next()); - } - } - return {}; - } - - template - std::list searchContacts(const std::string &searchWord) - { - std::list results; - if (!searchWord.empty()) { - auto list = App::getInst().getContactManager().search(searchWord); - if (list) { - do { - auto &rec = list->get(); - if (isValid(rec)) { - results.push_back(toRecip(rec)); - } else { - MSG_LOG("Skip invalid contact: ", rec.getAddress()); - } - } while (list->next()); - } - } - return results; - } + template + Recipient toRecip(const ContactRec &rec) + { + Recipient res; + + res.setDispName(rec.getDispName()); + res.setAddress(rec.getAddress()); + + if (res.getDispName().empty()) + res.setDispName(res.getAddress()); + + return res; + } + + template + Recipient toRecip(const std::shared_ptr &rec) + { + Recipient res; + if (rec) + res = toRecip(*rec); + return res; + } + + template + bool isValid(const ContactRec &rec) + { + return rec.isValid() && MsgUtils::isValidAddress(rec.getAddress()); + } + + template + std::shared_ptr searchFirstContact(const std::string &searchWord) + { + if (!searchWord.empty()) { + auto list = App::getInst().getContactManager().search(searchWord); + if (list) { + do { + auto &rec = list->get(); + if (isValid(rec)) { + return std::static_pointer_cast(rec.clone()); + } else { + MSG_LOG("Skip invalid contact: ", rec.getAddress()); + } + } while (list->next()); + } + } + return {}; + } + + template + std::list searchContacts(const std::string &searchWord) + { + std::list results; + if (!searchWord.empty()) { + auto list = App::getInst().getContactManager().search(searchWord); + if (list) { + do { + auto &rec = list->get(); + if (isValid(rec)) { + results.push_back(toRecip(rec)); + } else { + MSG_LOG("Skip invalid contact: ", rec.getAddress()); + } + } while (list->next()); + } + } + return results; + } } Recipient::Recipient() @@ -101,8 +101,8 @@ Recipient::Recipient() } Recipient::Recipient(std::string address, std::string dispName) - : m_Address(address) - , m_DispName(dispName) + : m_Address(address) + , m_DispName(dispName) { } @@ -112,98 +112,98 @@ Recipient::~Recipient() void Recipient::clear() { - m_Address.clear(); - m_DispName.clear(); + m_Address.clear(); + m_DispName.clear(); } const std::string &Recipient::getAddress() const { - return m_Address; + return m_Address; } const std::string &Recipient::getDispName() const { - return m_DispName.empty() ? m_Address : m_DispName; + return m_DispName.empty() ? m_Address : m_DispName; } void Recipient::setAddress(std::string address) { - m_Address = std::move(address); + m_Address = std::move(address); } void Recipient::setDispName(std::string dispName) { - m_DispName = std::move(dispName); + m_DispName = std::move(dispName); } bool Recipient::isValid() const { - return MsgUtils::isValidNumber(m_Address); + return MsgUtils::isValidNumber(m_Address); } void Recipient::updateContactInfo() { - Recipient recip = getByAddress(m_Address); - std::string dispName = recip.getDispName(); - m_DispName = dispName.empty() ? m_Address : dispName; + Recipient recip = getByAddress(m_Address); + std::string dispName = recip.getDispName(); + m_DispName = dispName.empty() ? m_Address : dispName; } Recipient Recipient::searchFirst(const std::string &searchWord) { - Recipient res; + Recipient res; - auto numberRef = searchFirstContact(searchWord); + auto numberRef = searchFirstContact(searchWord); - if (numberRef) { - res.m_Address = numberRef->getAddress(); - res.m_DispName = numberRef->getDispName(); - } else { - auto phoneLogRef = searchFirstContact(searchWord); - if (phoneLogRef) - res.m_Address = phoneLogRef->getAddress(); - } + if (numberRef) { + res.m_Address = numberRef->getAddress(); + res.m_DispName = numberRef->getDispName(); + } else { + auto phoneLogRef = searchFirstContact(searchWord); + if (phoneLogRef) + res.m_Address = phoneLogRef->getAddress(); + } - if (res.m_DispName.empty()) - res.m_DispName = res.m_Address; + if (res.m_DispName.empty()) + res.m_DispName = res.m_Address; - return res; + return res; } std::list Recipient::searchAll(const std::string &searchWord) { - std::list result; - result = searchContacts(searchWord); - result.splice(result.end(), searchContacts(searchWord)); - return result; + std::list result; + result = searchContacts(searchWord); + result.splice(result.end(), searchContacts(searchWord)); + return result; } Recipient Recipient::getByThreadId(ThreadId id) { - Recipient res; - if (id.isValid()) { - MsgAddressListRef list = App::getInst().getMsgEngine().getStorage().getAddressList(id); - if (list && !list->isEmpty()) { - std::string firstAddress = list->at(0).getAddress(); - res.setAddress(firstAddress); - ContactAddressRef contactAddress = App::getInst().getContactManager().getContactAddress(firstAddress); - if (contactAddress) - res.setDispName(contactAddress->getDispName()); - if (res.getDispName().empty()) - res.setDispName(firstAddress); - } - } - return res; + Recipient res; + if (id.isValid()) { + MsgAddressListRef list = App::getInst().getMsgEngine().getStorage().getAddressList(id); + if (list && !list->isEmpty()) { + std::string firstAddress = list->at(0).getAddress(); + res.setAddress(firstAddress); + ContactAddressRef contactAddress = App::getInst().getContactManager().getContactAddress(firstAddress); + if (contactAddress) + res.setDispName(contactAddress->getDispName()); + if (res.getDispName().empty()) + res.setDispName(firstAddress); + } + } + return res; } Recipient Recipient::getByContactPersonNmberId(int id) { - Recipient res; - auto rec = App::getInst().getContactManager().getContactPersonNumber(id); - return toRecip(rec); + Recipient res; + auto rec = App::getInst().getContactManager().getContactPersonNumber(id); + return toRecip(rec); } Recipient Recipient::getByAddress(const std::string &address) { - auto rec = App::getInst().getContactManager().getContactAddress(address); - return toRecip(rec); + auto rec = App::getInst().getContactManager().getContactAddress(address); + return toRecip(rec); } diff --git a/src/Common/SystemSettingsManager/inc/SystemSettingsManager.h b/src/Common/SystemSettingsManager/inc/SystemSettingsManager.h index c012a78..2eda4cd 100644 --- a/src/Common/SystemSettingsManager/inc/SystemSettingsManager.h +++ b/src/Common/SystemSettingsManager/inc/SystemSettingsManager.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -22,98 +22,98 @@ namespace Msg { - class ISystemSettingsManager; - - /** - * @brief Monitors changing of time format and system language. Also reads telephony settings. - */ - class SystemSettingsManager - { - public: - /** - * @brief A constructor initializes telephony handle to make system settings manager instance to read telephony settings. - */ - SystemSettingsManager(); - ~SystemSettingsManager(); - - /** - * @brief Adds a subscriber on system settings change events. - * @param[in] l a listener. - */ - void addListener(ISystemSettingsManager &l); - - /** - * @brief Removes system settings changes listener. - * @param[in] l a listener to be removed. - */ - void removeListener(ISystemSettingsManager&l); - - /** - * @brief Checks whether SIM is inserted or not. - * @return true if SIM is inserted, false otherwise. - */ - bool isSimInserted() const; - - /** - * @brief Checks whether network service is available or not. - * @return true if network service available, false otherwise(service is unavailable or only emergency calls are available). - */ - bool isSimActive() const; - - /** - * @brief Checks whether mobile data is enabled or not. - * @return true if 3g mobile data is enabled, false otherwise. - */ - bool isMobileDataEnabled() const; - - /** - * @brief Checks whether flight mode is enabled or not. - * @return true if flight mode is enabled, false otherwise. - */ - bool isFlightModeEnabled() const; - - /** - * @brief Checks roaming status - * @return true if roaming, false otherwise. - */ - bool isRoaming() const; - - /** - * @brief Checks whether roaming data is enabled or not - * @return true if enabled, false otherwise. - */ - bool isRoamingDataEnabled() const; - - private: - SystemSettingsManager(SystemSettingsManager&) = delete; - SystemSettingsManager &operator =(const SystemSettingsManager&) = delete; - - void onTimeFormatChanged(); - void onLanguageChanged(); - void prepareTel(); - private: - std::vector m_Listeners; - telephony_handle_list_s m_TelHandleList; - }; - - /** - * @brief A listener-interface that should be implemented by subscriber in order to be notified about time format or nsystem language change. - */ - class ISystemSettingsManager - { - public: - virtual ~ISystemSettingsManager() {} - - /** - * @brief Notification about change of time format. - */ - virtual void onTimeFormatChanged() {}; - - /** - * @brief Notification about change of system language. - */ - virtual void onLanguageChanged() {}; - }; + class ISystemSettingsManager; + + /** + * @brief Monitors changing of time format and system language. Also reads telephony settings. + */ + class SystemSettingsManager + { + public: + /** + * @brief A constructor initializes telephony handle to make system settings manager instance to read telephony settings. + */ + SystemSettingsManager(); + ~SystemSettingsManager(); + + /** + * @brief Adds a subscriber on system settings change events. + * @param[in] l a listener. + */ + void addListener(ISystemSettingsManager &l); + + /** + * @brief Removes system settings changes listener. + * @param[in] l a listener to be removed. + */ + void removeListener(ISystemSettingsManager&l); + + /** + * @brief Checks whether SIM is inserted or not. + * @return true if SIM is inserted, false otherwise. + */ + bool isSimInserted() const; + + /** + * @brief Checks whether network service is available or not. + * @return true if network service available, false otherwise(service is unavailable or only emergency calls are available). + */ + bool isSimActive() const; + + /** + * @brief Checks whether mobile data is enabled or not. + * @return true if 3g mobile data is enabled, false otherwise. + */ + bool isMobileDataEnabled() const; + + /** + * @brief Checks whether flight mode is enabled or not. + * @return true if flight mode is enabled, false otherwise. + */ + bool isFlightModeEnabled() const; + + /** + * @brief Checks roaming status + * @return true if roaming, false otherwise. + */ + bool isRoaming() const; + + /** + * @brief Checks whether roaming data is enabled or not + * @return true if enabled, false otherwise. + */ + bool isRoamingDataEnabled() const; + + private: + SystemSettingsManager(SystemSettingsManager&) = delete; + SystemSettingsManager &operator =(const SystemSettingsManager&) = delete; + + void onTimeFormatChanged(); + void onLanguageChanged(); + void prepareTel(); + private: + std::vector m_Listeners; + telephony_handle_list_s m_TelHandleList; + }; + + /** + * @brief A listener-interface that should be implemented by subscriber in order to be notified about time format or nsystem language change. + */ + class ISystemSettingsManager + { + public: + virtual ~ISystemSettingsManager() {} + + /** + * @brief Notification about change of time format. + */ + virtual void onTimeFormatChanged() {}; + + /** + * @brief Notification about change of system language. + */ + virtual void onLanguageChanged() {}; + }; } #endif /* __SystemSettingsManager_h__ */ diff --git a/src/Common/SystemSettingsManager/src/SystemSettingsManager.cpp b/src/Common/SystemSettingsManager/src/SystemSettingsManager.cpp index c7dda86..394401c 100644 --- a/src/Common/SystemSettingsManager/src/SystemSettingsManager.cpp +++ b/src/Common/SystemSettingsManager/src/SystemSettingsManager.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -26,118 +26,118 @@ using namespace Msg; #define CALLBACK(method) [](system_settings_key_e key, void *user_data) \ -{ \ - static_cast(user_data)->method(); \ +{ \ + static_cast(user_data)->method(); \ } SystemSettingsManager::SystemSettingsManager() - : m_TelHandleList() + : m_TelHandleList() { - system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_LOCALE_TIMEFORMAT_24HOUR, CALLBACK(onTimeFormatChanged), this); - system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, CALLBACK(onLanguageChanged), this); + system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_LOCALE_TIMEFORMAT_24HOUR, CALLBACK(onTimeFormatChanged), this); + system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, CALLBACK(onLanguageChanged), this); } SystemSettingsManager::~SystemSettingsManager() { - if (m_TelHandleList.handle != nullptr) - telephony_deinit(&m_TelHandleList); + if (m_TelHandleList.handle != nullptr) + telephony_deinit(&m_TelHandleList); } void SystemSettingsManager::prepareTel() { - if (m_TelHandleList.handle != nullptr) - return; - int err = telephony_init(&m_TelHandleList); - MSG_LOG("telephony_init = ", err); + 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()) - m_Listeners.push_back(&l); + auto it = std::find(m_Listeners.begin(), m_Listeners.end(), &l); + 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()) - m_Listeners.erase(it); + auto it = std::find(m_Listeners.begin(), m_Listeners.end(), &l); + if (it != m_Listeners.end()) + m_Listeners.erase(it); } bool SystemSettingsManager::isSimInserted() const { - bool res = false; - const_cast(this)->prepareTel(); - - if (m_TelHandleList.count > 0) - { - telephony_h handle = m_TelHandleList.handle[0]; - telephony_sim_state_e simState = TELEPHONY_SIM_STATE_UNAVAILABLE; - telephony_sim_get_state(handle, &simState); - res = simState != TELEPHONY_SIM_STATE_UNAVAILABLE && - simState != TELEPHONY_SIM_STATE_UNKNOWN; - } - - return res; + bool res = false; + const_cast(this)->prepareTel(); + + if (m_TelHandleList.count > 0) + { + telephony_h handle = m_TelHandleList.handle[0]; + telephony_sim_state_e simState = TELEPHONY_SIM_STATE_UNAVAILABLE; + telephony_sim_get_state(handle, &simState); + res = simState != TELEPHONY_SIM_STATE_UNAVAILABLE && + simState != TELEPHONY_SIM_STATE_UNKNOWN; + } + + return res; } bool SystemSettingsManager::isSimActive() const { - bool res = false; - const_cast(this)->prepareTel(); - - 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) - { - res = (servState == TELEPHONY_NETWORK_SERVICE_STATE_IN_SERVICE); - MSG_LOG("servState = ", servState); - } - } - - return res; + bool res = false; + const_cast(this)->prepareTel(); + + 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) + { + res = (servState == TELEPHONY_NETWORK_SERVICE_STATE_IN_SERVICE); + MSG_LOG("servState = ", servState); + } + } + + return res; } bool SystemSettingsManager::isMobileDataEnabled() const { - bool res = false; - system_settings_get_value_bool(SYSTEM_SETTINGS_KEY_3G_DATA_NETWORK_ENABLED, &res); - return res; + bool res = false; + system_settings_get_value_bool(SYSTEM_SETTINGS_KEY_3G_DATA_NETWORK_ENABLED, &res); + return res; } bool SystemSettingsManager::isFlightModeEnabled() const { - bool res = false; - system_settings_get_value_bool(SYSTEM_SETTINGS_KEY_NETWORK_FLIGHT_MODE, &res); - return res; + bool res = false; + system_settings_get_value_bool(SYSTEM_SETTINGS_KEY_NETWORK_FLIGHT_MODE, &res); + return res; } bool SystemSettingsManager::isRoaming() const { - bool status = false; - telephony_h telHandle = m_TelHandleList.handle[0]; - telephony_network_get_roaming_status(telHandle, &status); - return status; + bool status = false; + telephony_h telHandle = m_TelHandleList.handle[0]; + telephony_network_get_roaming_status(telHandle, &status); + return status; } bool SystemSettingsManager::isRoamingDataEnabled() const { - int enabled = false; - vconf_get_bool(VCONFKEY_SETAPPL_STATE_DATA_ROAMING_BOOL, &enabled); - return enabled; + int enabled = false; + vconf_get_bool(VCONFKEY_SETAPPL_STATE_DATA_ROAMING_BOOL, &enabled); + return enabled; } void SystemSettingsManager::onTimeFormatChanged() { - for (ISystemSettingsManager *it : m_Listeners) - it->onTimeFormatChanged(); + for (ISystemSettingsManager *it : m_Listeners) + it->onTimeFormatChanged(); } void SystemSettingsManager::onLanguageChanged() { - for (ISystemSettingsManager *it : m_Listeners) - it->onLanguageChanged(); + for (ISystemSettingsManager *it : m_Listeners) + it->onLanguageChanged(); } diff --git a/src/Common/Utils/inc/BidirectUtils.h b/src/Common/Utils/inc/BidirectUtils.h index 048c845..344d655 100644 --- a/src/Common/Utils/inc/BidirectUtils.h +++ b/src/Common/Utils/inc/BidirectUtils.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -20,38 +20,38 @@ #include namespace Msg { - namespace BidiUtils { - constexpr const char *lrmChar = "\u200E"; - constexpr const char *rlmChar = "\u200F"; - - std::string lrm(const std::string &str); // Left-to-right zero-width character - std::string lrm(std::string &&str); - - std::string rlm(const std::string &str); // Right-to-left zero-width non-Arabic character - std::string rlm(std::string &&str); - - inline std::string lrm(const std::string &str) - { - return lrmChar + str; - } - - inline std::string lrm(std::string &&str) - { - str.insert(0, lrmChar); - return std::move(str); - } - - inline std::string rlm(const std::string &str) - { - return rlmChar + str; - } - - inline std::string rlm(std::string &&str) - { - str.insert(0, rlmChar); - return std::move(str); - } - } + namespace BidiUtils { + constexpr const char *lrmChar = "\u200E"; + constexpr const char *rlmChar = "\u200F"; + + std::string lrm(const std::string &str); // Left-to-right zero-width character + std::string lrm(std::string &&str); + + std::string rlm(const std::string &str); // Right-to-left zero-width non-Arabic character + std::string rlm(std::string &&str); + + inline std::string lrm(const std::string &str) + { + return lrmChar + str; + } + + inline std::string lrm(std::string &&str) + { + str.insert(0, lrmChar); + return std::move(str); + } + + inline std::string rlm(const std::string &str) + { + return rlmChar + str; + } + + inline std::string rlm(std::string &&str) + { + str.insert(0, rlmChar); + return std::move(str); + } + } } #endif /* BidirectUtils_h_ */ diff --git a/src/Common/Utils/inc/Callback.h b/src/Common/Utils/inc/Callback.h index faf09b0..3b2643f 100644 --- a/src/Common/Utils/inc/Callback.h +++ b/src/Common/Utils/inc/Callback.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -23,19 +23,19 @@ struct Callback; template struct Callback { - using M = R(C::*)(A...); + using M = R(C::*)(A...); - template - static R stubFirst(void *obj, A... args) - { - return (static_cast(obj)->*m)(args...); - } + template + static R stubFirst(void *obj, A... args) + { + return (static_cast(obj)->*m)(args...); + } - template - static R stubLast(A... args, void *obj) - { - return (static_cast(obj)->*m)(args...); - } + template + static R stubLast(A... args, void *obj) + { + return (static_cast(obj)->*m)(args...); + } }; #define makeCbFirst(method) Callback::stubFirst diff --git a/src/Common/Utils/inc/FileUtils.h b/src/Common/Utils/inc/FileUtils.h index 5e4afea..846860f 100755 --- a/src/Common/Utils/inc/FileUtils.h +++ b/src/Common/Utils/inc/FileUtils.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -21,127 +21,127 @@ #include namespace Msg { - namespace FileUtils { - /** - * @brief Get file size. - * @param[in] path to file - * @retval file size - */ - long long getFileSize(const std::string &file); - - /** - * @brief Check file existing. - * @param[in] path to file - * @retval Returns true if file exist, else false - */ - bool isExists(const std::string &file); - - /** - * @brief Copy file. - * @param[in] src Source - * @param[in] dst dst - * @retval Returns true if file exist, else false - */ - bool copy(const std::string &src, const std::string &dst); - - /** - * @brief Add file to data dir, if file not exists in data dir. - * @param[in] source file path - * @return new path in data dir - */ - std::string addFileToDataDir(const std::string &path); - - /** - * @brief Make Directory. - * @param[in] path to directory - * @retval Returns true if directory created, else false - */ - bool makeDir(const std::string &dir); - - /** - * @brief Check directory. - * @param[in] file File Directory - * @retval Returns true if file is directory, else false - */ - bool isDir(const std::string &file); - - /** - * @brief Strip file extension. - * @param[in] path File Path - * @retval Returns file without extension. - */ - std::string stripExtension(const std::string &path); - - /** - * @brief Split file path (base-path + file-name + file-extension). - * @param[in] file path name - * @param[out] base path(with '/' at end) - * @param[out] file name - * @param[out] extension(without dot) - */ - void splitPath(const std::string &path, std::string &basePath, - std::string &fileName, std::string &extension); - - /** - * @brief Get file name with extension - * @param[in] file path name - * @retval Returns file name with extension - */ - std::string getFileName(const std::string &path); - - /** - * @brief Remove recursive files and directories. - * @param[in] path File or directory - * @param[in] true - remove current dir, false - otherwise - * @retval Returns true if all success, false otherwise - */ - bool remove(const std::string &path, bool removeCurrentDir = true); - - /** - * @brief Read text file - * @param[in] file path name - * @retval Returns text content - */ - std::string readTextFile(const std::string &path); - - /** - * @brief Write text file - * @param[in] file path name - * @param[in] text content - * @return Returns true if all success, false otherwise - */ - bool writeTextFile(const std::string &path, const std::string &text); - - /** - * @brief Generate new file path - * @param[in] storage path - * @param[in] file path name - * @return Returns unique file path in storage directory - */ - std::string genUniqueFilePath(const std::string &storagePath, const std::string &filePath); - - /** - * @brief Gets the MIME type by file ptah/name(with extension) - * @param[in] filePath - * @return Returns The MIME type is 'application/octet-stream' if - * the given file extension is not associated with specific file formats - */ - std::string getMimeType(const std::string &filePath); - - /** - * @brief Save files to default storage directory - * @param[in] file list of file path - * @return Returns true if all ok, false otherwise - */ - bool saveFilesToStorage(const std::list &files); - - /** - * @brief Save file to default storage directory - * @param[in] file path - * @return Returns true if all ok, false otherwise - */ - bool saveFileToStorage(const std::string &file); - }; + namespace FileUtils { + /** + * @brief Get file size. + * @param[in] path to file + * @retval file size + */ + long long getFileSize(const std::string &file); + + /** + * @brief Check file existing. + * @param[in] path to file + * @retval Returns true if file exist, else false + */ + bool isExists(const std::string &file); + + /** + * @brief Copy file. + * @param[in] src Source + * @param[in] dst dst + * @retval Returns true if file exist, else false + */ + bool copy(const std::string &src, const std::string &dst); + + /** + * @brief Add file to data dir, if file not exists in data dir. + * @param[in] source file path + * @return new path in data dir + */ + std::string addFileToDataDir(const std::string &path); + + /** + * @brief Make Directory. + * @param[in] path to directory + * @retval Returns true if directory created, else false + */ + bool makeDir(const std::string &dir); + + /** + * @brief Check directory. + * @param[in] file File Directory + * @retval Returns true if file is directory, else false + */ + bool isDir(const std::string &file); + + /** + * @brief Strip file extension. + * @param[in] path File Path + * @retval Returns file without extension. + */ + std::string stripExtension(const std::string &path); + + /** + * @brief Split file path (base-path + file-name + file-extension). + * @param[in] file path name + * @param[out] base path(with '/' at end) + * @param[out] file name + * @param[out] extension(without dot) + */ + void splitPath(const std::string &path, std::string &basePath, + std::string &fileName, std::string &extension); + + /** + * @brief Get file name with extension + * @param[in] file path name + * @retval Returns file name with extension + */ + std::string getFileName(const std::string &path); + + /** + * @brief Remove recursive files and directories. + * @param[in] path File or directory + * @param[in] true - remove current dir, false - otherwise + * @retval Returns true if all success, false otherwise + */ + bool remove(const std::string &path, bool removeCurrentDir = true); + + /** + * @brief Read text file + * @param[in] file path name + * @retval Returns text content + */ + std::string readTextFile(const std::string &path); + + /** + * @brief Write text file + * @param[in] file path name + * @param[in] text content + * @return Returns true if all success, false otherwise + */ + bool writeTextFile(const std::string &path, const std::string &text); + + /** + * @brief Generate new file path + * @param[in] storage path + * @param[in] file path name + * @return Returns unique file path in storage directory + */ + std::string genUniqueFilePath(const std::string &storagePath, const std::string &filePath); + + /** + * @brief Gets the MIME type by file ptah/name(with extension) + * @param[in] filePath + * @return Returns The MIME type is 'application/octet-stream' if + * the given file extension is not associated with specific file formats + */ + std::string getMimeType(const std::string &filePath); + + /** + * @brief Save files to default storage directory + * @param[in] file list of file path + * @return Returns true if all ok, false otherwise + */ + bool saveFilesToStorage(const std::list &files); + + /** + * @brief Save file to default storage directory + * @param[in] file path + * @return Returns true if all ok, false otherwise + */ + bool saveFileToStorage(const std::string &file); + }; } #endif /* __MSG_FILE_UTIL_H__ */ diff --git a/src/Common/Utils/inc/LangUtils.h b/src/Common/Utils/inc/LangUtils.h index f80e05f..6153bfc 100644 --- a/src/Common/Utils/inc/LangUtils.h +++ b/src/Common/Utils/inc/LangUtils.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -28,160 +28,160 @@ namespace Msg { - struct DText { - - explicit DText(const char *stringId, const char *domainName, ...) - : m_pMsg(m_Buf) - { - va_list args; - va_start(args, domainName); - vsnprintf(m_Buf, maxBufSize, dgettext(domainName, stringId), args); - va_end(args); - } - - const char *get() const - { - return m_pMsg ? m_pMsg : ""; - } - - const char* cStr() const - { - return get(); - } - - operator std::string() const - { - return get(); - } - - private: - DText(DText&) = delete; - DText operator =(DText&) = delete; - - static const int maxBufSize = 1024; - char m_Buf[maxBufSize]; - const char *m_pMsg; - }; - - // Translatable Text - struct TText { - - // Default constructor; - TText() - : m_pDomain(nullptr) - , m_IsTranslatable(false) - { - } - - TText(const DText &text) - : m_pDomain(nullptr) - , m_Str(text.get()) - , m_IsTranslatable(false) - { - } - - // Constructor for nullptr; - TText(std::nullptr_t) - : m_pDomain(nullptr) - , m_IsTranslatable(false) - { - } - - // Copy Constructor; - TText(const TText &text) - : m_pDomain(text.m_pDomain) - , m_Str(text.m_Str) - , m_IsTranslatable(text.m_IsTranslatable) - { - } - - // Move Constructor; - TText(TText &&text) - : m_pDomain(text.m_pDomain) - , m_Str(std::move(text.m_Str)) - , m_IsTranslatable(text.m_IsTranslatable) - { - } - - // Constructor for C string - TText(const char *str, bool translatable = false, const char *domainName = nullptr) - : m_pDomain(domainName) - , m_Str(str ? str : "") - , m_IsTranslatable(translatable) - { - } - - // Constructor for C++ string - TText(std::string str, bool translatable = false, const char *domainName = nullptr) - : m_pDomain(domainName) - , m_Str(std::move(str)) - , m_IsTranslatable(translatable) - { - } - - TText &operator=(const TText &that) - { - m_pDomain = that.m_pDomain; - m_Str = that.m_Str; - m_IsTranslatable = that.m_IsTranslatable; - return *this; - } - - void clear() - { - m_Str.clear(); - m_pDomain = nullptr; - m_IsTranslatable = false; - } - - const char *getMsg() const - { - return m_Str.c_str(); - } - - const char *getDomain() const - { - if (m_pDomain && m_pDomain[0] == 0) - return nullptr; - return m_pDomain; - } - - bool isTranslatable() const - { - return m_IsTranslatable; - } - - template - std::string translate(Args... args) const - { - if (!m_pDomain) - return {}; - - constexpr int maxBufSize = 1024; - char buf[maxBufSize]; - snprintf(buf, maxBufSize, dgettext(m_pDomain, m_Str.c_str()), args...); - return buf; - } - - std::string translate() const - { - return m_pDomain ? dgettext(m_pDomain, m_Str.c_str()) : m_Str; - } - - operator std::string() const - { - return translate(); - } - - private: - const char *m_pDomain; - std::string m_Str; - bool m_IsTranslatable; - }; - - #define msgt(strId) TText(strId, true, MSG_DOMAIN) - #define msg(strId) TText(strId, false, MSG_DOMAIN) - #define msgArgs(strId, ...) DText(strId, MSG_DOMAIN, __VA_ARGS__) + struct DText { + + explicit DText(const char *stringId, const char *domainName, ...) + : m_pMsg(m_Buf) + { + va_list args; + va_start(args, domainName); + vsnprintf(m_Buf, maxBufSize, dgettext(domainName, stringId), args); + va_end(args); + } + + const char *get() const + { + return m_pMsg ? m_pMsg : ""; + } + + const char* cStr() const + { + return get(); + } + + operator std::string() const + { + return get(); + } + + private: + DText(DText&) = delete; + DText operator =(DText&) = delete; + + static const int maxBufSize = 1024; + char m_Buf[maxBufSize]; + const char *m_pMsg; + }; + + // Translatable Text + struct TText { + + // Default constructor; + TText() + : m_pDomain(nullptr) + , m_IsTranslatable(false) + { + } + + TText(const DText &text) + : m_pDomain(nullptr) + , m_Str(text.get()) + , m_IsTranslatable(false) + { + } + + // Constructor for nullptr; + TText(std::nullptr_t) + : m_pDomain(nullptr) + , m_IsTranslatable(false) + { + } + + // Copy Constructor; + TText(const TText &text) + : m_pDomain(text.m_pDomain) + , m_Str(text.m_Str) + , m_IsTranslatable(text.m_IsTranslatable) + { + } + + // Move Constructor; + TText(TText &&text) + : m_pDomain(text.m_pDomain) + , m_Str(std::move(text.m_Str)) + , m_IsTranslatable(text.m_IsTranslatable) + { + } + + // Constructor for C string + TText(const char *str, bool translatable = false, const char *domainName = nullptr) + : m_pDomain(domainName) + , m_Str(str ? str : "") + , m_IsTranslatable(translatable) + { + } + + // Constructor for C++ string + TText(std::string str, bool translatable = false, const char *domainName = nullptr) + : m_pDomain(domainName) + , m_Str(std::move(str)) + , m_IsTranslatable(translatable) + { + } + + TText &operator=(const TText &that) + { + m_pDomain = that.m_pDomain; + m_Str = that.m_Str; + m_IsTranslatable = that.m_IsTranslatable; + return *this; + } + + void clear() + { + m_Str.clear(); + m_pDomain = nullptr; + m_IsTranslatable = false; + } + + const char *getMsg() const + { + return m_Str.c_str(); + } + + const char *getDomain() const + { + if (m_pDomain && m_pDomain[0] == 0) + return nullptr; + return m_pDomain; + } + + bool isTranslatable() const + { + return m_IsTranslatable; + } + + template + std::string translate(Args... args) const + { + if (!m_pDomain) + return {}; + + constexpr int maxBufSize = 1024; + char buf[maxBufSize]; + snprintf(buf, maxBufSize, dgettext(m_pDomain, m_Str.c_str()), args...); + return buf; + } + + std::string translate() const + { + return m_pDomain ? dgettext(m_pDomain, m_Str.c_str()) : m_Str; + } + + operator std::string() const + { + return translate(); + } + + private: + const char *m_pDomain; + std::string m_Str; + bool m_IsTranslatable; + }; + + #define msgt(strId) TText(strId, true, MSG_DOMAIN) + #define msg(strId) TText(strId, false, MSG_DOMAIN) + #define msgArgs(strId, ...) DText(strId, MSG_DOMAIN, __VA_ARGS__) } #endif /* LangUtils_h_ */ diff --git a/src/Common/Utils/inc/Logger.h b/src/Common/Utils/inc/Logger.h index a0ab67a..7701843 100644 --- a/src/Common/Utils/inc/Logger.h +++ b/src/Common/Utils/inc/Logger.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -21,27 +21,27 @@ #include "LoggerImpl.h" #include -#ifndef LOGGER_TAG - #error "Please define LOGGER_TAG" +#ifndef LOGGER_TAG + #error "Please define LOGGER_TAG" #endif #define TRACE\ - LoggerImpl __tmp_logger_unique(LOGGER_TAG, __FILE__, __FUNCTION__, __LINE__);\ + LoggerImpl __tmp_logger_unique(LOGGER_TAG, __FILE__, __FUNCTION__, __LINE__);\ #define MSG_LOG(...)\ - loggerImpl(LogPriority::INFO, LOGGER_TAG, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__); + loggerImpl(LogPriority::INFO, LOGGER_TAG, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__); #define MSG_LOG_INFO(...)\ - loggerImpl(LogPriority::INFO, LOGGER_TAG, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__); + loggerImpl(LogPriority::INFO, LOGGER_TAG, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__); #define MSG_LOG_ERROR(...)\ - loggerImpl(LogPriority::ERROR, LOGGER_TAG, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__); + loggerImpl(LogPriority::ERROR, LOGGER_TAG, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__); #define MSG_LOG_WARN(...)\ - loggerImpl(LogPriority::WARN, LOGGER_TAG, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__); + loggerImpl(LogPriority::WARN, LOGGER_TAG, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__); #define MSG_ASSERT(expr, ...)\ - if (!(expr)) { MSG_LOG_ERROR(__VA_ARGS__); } \ - assert(expr) + if (!(expr)) { MSG_LOG_ERROR(__VA_ARGS__); } \ + assert(expr) #endif /* LOGGER_H_ */ diff --git a/src/Common/Utils/inc/LoggerImpl.h b/src/Common/Utils/inc/LoggerImpl.h index 2f331a5..7655a5d 100644 --- a/src/Common/Utils/inc/LoggerImpl.h +++ b/src/Common/Utils/inc/LoggerImpl.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -23,40 +23,40 @@ enum class LogPriority { - DEFAULT = DLOG_DEFAULT, - VERBOSE = DLOG_VERBOSE, /**< Verbose */ - DEBUG = DLOG_DEBUG, /**< Debug */ - INFO = DLOG_INFO, /**< Info */ - WARN = DLOG_WARN, /**< Warning */ - ERROR = DLOG_ERROR, /**< Error */ - FATAL = DLOG_FATAL, /**< Fatal */ - SILEN = DLOG_SILENT, /**< Silent */ - MAX = DLOG_PRIO_MAX/**< Keep this always at the end. */ + DEFAULT = DLOG_DEFAULT, + VERBOSE = DLOG_VERBOSE, /**< Verbose */ + DEBUG = DLOG_DEBUG, /**< Debug */ + INFO = DLOG_INFO, /**< Info */ + WARN = DLOG_WARN, /**< Warning */ + ERROR = DLOG_ERROR, /**< Error */ + FATAL = DLOG_FATAL, /**< Fatal */ + SILEN = DLOG_SILENT, /**< Silent */ + MAX = DLOG_PRIO_MAX/**< Keep this always at the end. */ }; template void loggerImpl(LogPriority prior - , const char *tag - , const char *file, const char *function, int line - , Tail... msg) + , const char *tag + , const char *file, const char *function, int line + , Tail... msg) { - std::ostringstream messageStr; - (void)std::initializer_list { (messageStr << msg, true)... }; - dlog_print(static_cast(prior) - , tag, "%s: %s(%d) -> %s", file, function, line - , messageStr.str().c_str()); + std::ostringstream messageStr; + (void)std::initializer_list { (messageStr << msg, true)... }; + dlog_print(static_cast(prior) + , tag, "%s: %s(%d) -> %s", file, function, line + , messageStr.str().c_str()); } class LoggerImpl { - public: - LoggerImpl(const char *tag, const char *file, const char *function, int line); - ~LoggerImpl(); + public: + LoggerImpl(const char *tag, const char *file, const char *function, int line); + ~LoggerImpl(); - private: - const std::string m_Tag; - const std::string m_File; - const std::string m_Function; + private: + const std::string m_Tag; + const std::string m_File; + const std::string m_Function; }; #endif /* LOGGERIMPL_H_ */ diff --git a/src/Common/Utils/inc/MediaPlayer.h b/src/Common/Utils/inc/MediaPlayer.h index 27662bc..bfc7219 100644 --- a/src/Common/Utils/inc/MediaPlayer.h +++ b/src/Common/Utils/inc/MediaPlayer.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -23,54 +23,54 @@ #include namespace Msg { - class IMediaPlayerListener; + class IMediaPlayerListener; - class MediaPlayer { - public: - MediaPlayer(); - ~MediaPlayer(); - MediaPlayer(const MediaPlayer&) = delete; - MediaPlayer& operator=(const MediaPlayer&) = delete; + class MediaPlayer { + public: + MediaPlayer(); + ~MediaPlayer(); + MediaPlayer(const MediaPlayer&) = delete; + MediaPlayer& operator=(const MediaPlayer&) = delete; - void setDisplay(Evas_Object *obj); - bool start(); - void stop(); - void pause(); - bool isPlaying() const; - void setUri(const std::string &uri); - void setListener(IMediaPlayerListener *l); - int getDuration() const; // msec - static int getDuration(const std::string &uri); - void setPosition(int msec); - int getPosition() const; // msec - bool getFocus() const; + void setDisplay(Evas_Object *obj); + bool start(); + void stop(); + void pause(); + bool isPlaying() const; + void setUri(const std::string &uri); + void setListener(IMediaPlayerListener *l); + int getDuration() const; // msec + static int getDuration(const std::string &uri); + void setPosition(int msec); + int getPosition() const; // msec + bool getFocus() const; - private: - void onCompleted(); - void onSeek(); + private: + void onCompleted(); + void onSeek(); - // Call from media internal thread: - void onSoundStreamFocusStateChanged(sound_stream_info_h stream_info, - sound_stream_focus_mask_e focus_mask, - sound_stream_focus_state_e focus_state, - sound_stream_focus_change_reason_e reason, - int sound_behavior, - const char *extra_info); - player_state_e getState() const; - static bool isCallReason(sound_stream_focus_change_reason_e reason); + // Call from media internal thread: + void onSoundStreamFocusStateChanged(sound_stream_info_h stream_info, + sound_stream_focus_mask_e focus_mask, + sound_stream_focus_state_e focus_state, + sound_stream_focus_change_reason_e reason, + int sound_behavior, + const char *extra_info); + player_state_e getState() const; + static bool isCallReason(sound_stream_focus_change_reason_e reason); - private: - player_h m_Player; - IMediaPlayerListener *m_pListener; - sound_stream_info_h m_StreamInfo; - }; + private: + player_h m_Player; + IMediaPlayerListener *m_pListener; + sound_stream_info_h m_StreamInfo; + }; - class IMediaPlayerListener { - public: - virtual ~IMediaPlayerListener() {} - virtual void onCompleted(MediaPlayer &player) {}; - virtual void onSoundFocusChanged(MediaPlayer &player) {}; - }; + class IMediaPlayerListener { + public: + virtual ~IMediaPlayerListener() {} + virtual void onCompleted(MediaPlayer &player) {}; + virtual void onSoundFocusChanged(MediaPlayer &player) {}; + }; } #endif // MediaPlayer_h_ diff --git a/src/Common/Utils/inc/MediaPlayerProvider.h b/src/Common/Utils/inc/MediaPlayerProvider.h index 583db2e..b59f1d8 100644 --- a/src/Common/Utils/inc/MediaPlayerProvider.h +++ b/src/Common/Utils/inc/MediaPlayerProvider.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -21,32 +21,32 @@ #include namespace Msg { - class IMediaPlayerProviderClient; - class MediaPlayerProvider; - typedef std::shared_ptr MediaPlayerProviderRef; - - class MediaPlayerProvider { - public: - MediaPlayerProvider(); - ~MediaPlayerProvider(); - MediaPlayerProvider(const MediaPlayerProvider&) = delete; - MediaPlayerProvider& operator=(const MediaPlayerProvider&) = delete; - - MediaPlayer &acquire(IMediaPlayerProviderClient *client); - void release(IMediaPlayerProviderClient *client); - IMediaPlayerProviderClient *getClient() const; - - private: - IMediaPlayerProviderClient *m_pClient; - std::unique_ptr m_Player; - }; - - class IMediaPlayerProviderClient { - public: - virtual ~IMediaPlayerProviderClient() {} - virtual void onAcquire(MediaPlayerProvider &provider) {}; - virtual void onRelease(MediaPlayerProvider &provider) {}; - }; + class IMediaPlayerProviderClient; + class MediaPlayerProvider; + typedef std::shared_ptr MediaPlayerProviderRef; + + class MediaPlayerProvider { + public: + MediaPlayerProvider(); + ~MediaPlayerProvider(); + MediaPlayerProvider(const MediaPlayerProvider&) = delete; + MediaPlayerProvider& operator=(const MediaPlayerProvider&) = delete; + + MediaPlayer &acquire(IMediaPlayerProviderClient *client); + void release(IMediaPlayerProviderClient *client); + IMediaPlayerProviderClient *getClient() const; + + private: + IMediaPlayerProviderClient *m_pClient; + std::unique_ptr m_Player; + }; + + class IMediaPlayerProviderClient { + public: + virtual ~IMediaPlayerProviderClient() {} + virtual void onAcquire(MediaPlayerProvider &provider) {}; + virtual void onRelease(MediaPlayerProvider &provider) {}; + }; } #endif // MediaPlayerProvider_h_ diff --git a/src/Common/Utils/inc/MediaUtils.h b/src/Common/Utils/inc/MediaUtils.h index 94253f7..3d57fe0 100644 --- a/src/Common/Utils/inc/MediaUtils.h +++ b/src/Common/Utils/inc/MediaUtils.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -20,16 +20,16 @@ #include namespace Msg { - namespace MediaUtils { - std::string getTitle(const std::string &path); - int getDuration(const std::string &uri); // msec; - int getDurationSec(const std::string &uri); // sec; - bool getVideoFrame(const std::string &videoFilePath, const std::string &imageFilePath); - bool getFrameSize(const std::string &videoFilePath, int &width, int &height); - long long downgradeImageQuality(const std::string &imagePath); - bool hasAudio(const std::string &path); - bool hasVideo(const std::string &path); - }; + namespace MediaUtils { + std::string getTitle(const std::string &path); + int getDuration(const std::string &uri); // msec; + int getDurationSec(const std::string &uri); // sec; + bool getVideoFrame(const std::string &videoFilePath, const std::string &imageFilePath); + bool getFrameSize(const std::string &videoFilePath, int &width, int &height); + long long downgradeImageQuality(const std::string &imagePath); + bool hasAudio(const std::string &path); + bool hasVideo(const std::string &path); + }; } #endif /* MediaUtils_h_ */ diff --git a/src/Common/Utils/inc/PathUtils.h b/src/Common/Utils/inc/PathUtils.h index 679cb26..f6bb98e 100644 --- a/src/Common/Utils/inc/PathUtils.h +++ b/src/Common/Utils/inc/PathUtils.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -21,53 +21,53 @@ #include "Resource.h" namespace Msg { - namespace PathUtils { - /** - * @brief Gets the absolute path to file in the application resource directory. - * @param[in] path to file in res. dir (without slash at begin/end) - * @return absolute path to file - */ - std::string getResourcePath(const std::string &filePath); + namespace PathUtils { + /** + * @brief Gets the absolute path to file in the application resource directory. + * @param[in] path to file in res. dir (without slash at begin/end) + * @return absolute path to file + */ + std::string getResourcePath(const std::string &filePath); - /** - * @brief Gets the absolute path to file in data directory which is used to store private data of the application. - * @param[in] path to file in data dir (without slash at begin/end) - * @return absolute path to file - */ - std::string getDataPath(const std::string &filePath); + /** + * @brief Gets the absolute path to file in data directory which is used to store private data of the application. + * @param[in] path to file in data dir (without slash at begin/end) + * @return absolute path to file + */ + std::string getDataPath(const std::string &filePath); - /** - * @brief Gets absolute path to application's resource-directory - * @return absolute path in case of success, or empty string otherwise - */ - std::string getResourcePath(); + /** + * @brief Gets absolute path to application's resource-directory + * @return absolute path in case of success, or empty string otherwise + */ + std::string getResourcePath(); - /** - * @brief Gets absolute path to application's locale-directory - * @return absolute path in case of success, or empty string otherwise - */ - std::string getLocalePath(); + /** + * @brief Gets absolute path to application's locale-directory + * @return absolute path in case of success, or empty string otherwise + */ + std::string getLocalePath(); - /** - * @brief Gets absolute path to Dowloads directory - * @return absolute path in case of success, or empty string otherwise - */ - const std::string &getDownloadPath(); + /** + * @brief Gets absolute path to Dowloads directory + * @return absolute path in case of success, or empty string otherwise + */ + const std::string &getDownloadPath(); - /** - * @brief Gets the absolute path to edje file - * @param[in] base edje file name - * @return absolute path to file - */ - std::string getEdjePath(const std::string &fileName); + /** + * @brief Gets the absolute path to edje file + * @param[in] base edje file name + * @return absolute path to file + */ + std::string getEdjePath(const std::string &fileName); - /** - * @brief Gets the absolute path to app. shared resource file - * @param[in] base file name - * @return absolute path to file - */ - std::string getSharedResPath(const std::string &fileName); - }; + /** + * @brief Gets the absolute path to app. shared resource file + * @param[in] base file name + * @return absolute path to file + */ + std::string getSharedResPath(const std::string &fileName); + }; } #endif /* PathUtils_h_ */ diff --git a/src/Common/Utils/inc/PhoneNumberUtils.h b/src/Common/Utils/inc/PhoneNumberUtils.h index b86fbd5..4ecacee 100644 --- a/src/Common/Utils/inc/PhoneNumberUtils.h +++ b/src/Common/Utils/inc/PhoneNumberUtils.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -20,17 +20,17 @@ #include namespace Msg { - class PhoneNumberUtils { - public: - static PhoneNumberUtils &getInst(); - std::string getNormalizedNumber(const std::string &number) const; + class PhoneNumberUtils { + public: + static PhoneNumberUtils &getInst(); + std::string getNormalizedNumber(const std::string &number) const; - private: - PhoneNumberUtils(); - ~PhoneNumberUtils(); - PhoneNumberUtils& operator=(PhoneNumberUtils&) = delete; - PhoneNumberUtils(PhoneNumberUtils&) = delete; - }; + private: + PhoneNumberUtils(); + ~PhoneNumberUtils(); + PhoneNumberUtils& operator=(PhoneNumberUtils&) = delete; + PhoneNumberUtils(PhoneNumberUtils&) = delete; + }; } #endif /* __PhoneNumberUtils_H__ */ diff --git a/src/Common/Utils/inc/TextDecorator.h b/src/Common/Utils/inc/TextDecorator.h index f7a5c7a..2b95ba7 100644 --- a/src/Common/Utils/inc/TextDecorator.h +++ b/src/Common/Utils/inc/TextDecorator.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -20,71 +20,71 @@ #include namespace Msg { - class TextStyle { - public: - enum class Align { - None, - Left, - Center, - Right - }; + class TextStyle { + public: + enum class Align { + None, + Left, + Center, + Right + }; - enum class Weight { - None, - Bold - }; + enum class Weight { + None, + Bold + }; - static const char *defaultColor; - static const char *whiteColor; - static const int defaultFontSize; + static const char *defaultColor; + static const char *whiteColor; + static const int defaultFontSize; - public: - TextStyle(); - TextStyle(const TextStyle&) = default; - TextStyle(TextStyle &&style); - TextStyle(int size, const std::string &color, Align align = Align::None); - ~TextStyle(); + public: + TextStyle(); + TextStyle(const TextStyle&) = default; + TextStyle(TextStyle &&style); + TextStyle(int size, const std::string &color, Align align = Align::None); + ~TextStyle(); - TextStyle &setColor(const std::string &color); - TextStyle &setSize(int size); - TextStyle &setAlign(Align align); - TextStyle &setWeight(Weight weight); - bool isEmpty() const; + TextStyle &setColor(const std::string &color); + TextStyle &setSize(int size); + TextStyle &setAlign(Align align); + TextStyle &setWeight(Weight weight); + bool isEmpty() const; - const std::string &getColor() const; - int getSize() const; - Align getAlign() const; - Weight getWeight() const; + const std::string &getColor() const; + int getSize() const; + Align getAlign() const; + Weight getWeight() const; - private: - Weight m_Weight; - std::string m_Color; - Align m_Align; - int m_Size; - }; + private: + Weight m_Weight; + std::string m_Color; + Align m_Align; + int m_Size; + }; - /** - * @brief Class with text decorator utils - */ - namespace TextDecorator { - std::string make(const std::string &text, const TextStyle &style); - std::string make(const std::string &text, const std::string &color); - std::string make(const std::string &text, - int size = TextStyle::defaultFontSize, - const std::string &color = TextStyle::defaultColor, - TextStyle::Align align = TextStyle::Align::None, - TextStyle::Weight weight = TextStyle::Weight::None); - std::string makePlainText(const std::string &text); + /** + * @brief Class with text decorator utils + */ + namespace TextDecorator { + std::string make(const std::string &text, const TextStyle &style); + std::string make(const std::string &text, const std::string &color); + std::string make(const std::string &text, + int size = TextStyle::defaultFontSize, + const std::string &color = TextStyle::defaultColor, + TextStyle::Align align = TextStyle::Align::None, + TextStyle::Weight weight = TextStyle::Weight::None); + std::string makePlainText(const std::string &text); - /** - * @brief Search first keyword and highlight it - * @param[in] str text with keyword - * @param[in] searchWord word for highlight - * @param[out] true if search word found, false otherwise - * @retval text with highlighted keyword if keyword found, input text otherwise - */ - std::string highlightKeyword(std::string str, const std::string &searchWord, bool *foundRes = nullptr); - }; + /** + * @brief Search first keyword and highlight it + * @param[in] str text with keyword + * @param[in] searchWord word for highlight + * @param[out] true if search word found, false otherwise + * @retval text with highlighted keyword if keyword found, input text otherwise + */ + std::string highlightKeyword(std::string str, const std::string &searchWord, bool *foundRes = nullptr); + }; } #endif /* TextDecorator_h_ */ diff --git a/src/Common/Utils/inc/ThumbnailMaker.h b/src/Common/Utils/inc/ThumbnailMaker.h index e04fdd9..ddcdfd4 100644 --- a/src/Common/Utils/inc/ThumbnailMaker.h +++ b/src/Common/Utils/inc/ThumbnailMaker.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -25,59 +25,59 @@ namespace Msg { - class App; - typedef long ThumbId; - const ThumbId invalidThumbId = -1; + class App; + typedef long ThumbId; + const ThumbId invalidThumbId = -1; - class ThumbnailMaker - : public IContactManagerListener - { - public: - enum DefaultThumbs - { - SingleThumb = 0, // Static thumb - GroupThumb, // Static thumb - OwnerThumb, // Mutable thumb - MaxDefaultThumb - }; + class ThumbnailMaker + : public IContactManagerListener + { + public: + enum DefaultThumbs + { + SingleThumb = 0, // Static thumb + GroupThumb, // Static thumb + OwnerThumb, // Mutable thumb + MaxDefaultThumb + }; - public: - ThumbnailMaker(App &app); - virtual ~ThumbnailMaker(); - ThumbnailMaker(ThumbnailMaker&) = delete; - ThumbnailMaker &operator=(ThumbnailMaker&) = delete; + public: + ThumbnailMaker(App &app); + virtual ~ThumbnailMaker(); + ThumbnailMaker(ThumbnailMaker&) = delete; + ThumbnailMaker &operator=(ThumbnailMaker&) = delete; - ThumbId getThumbId(const MsgAddress &address); - ThumbId getThumbId(const std::string &address); - ThumbId getThumbId(DefaultThumbs thumb); - Evas_Object *getThumb(Evas_Object *parent, ThumbId id, int thumbSize); - Evas_Object *getThumb(Evas_Object *parent, const std::string &path, int thumbSize); + ThumbId getThumbId(const MsgAddress &address); + ThumbId getThumbId(const std::string &address); + ThumbId getThumbId(DefaultThumbs thumb); + Evas_Object *getThumb(Evas_Object *parent, ThumbId id, int thumbSize); + Evas_Object *getThumb(Evas_Object *parent, const std::string &path, int thumbSize); - private: - typedef std::unordered_map ContactsMap; - typedef std::unordered_map OriginsMap; + private: + typedef std::unordered_map ContactsMap; + typedef std::unordered_map OriginsMap; - private: - void invalidate(); - ThumbId getThumbIdFromFile(const std::string &path); - Evas_Object *makeMask(Evas_Object *parent, int size); - Evas_Object *makeImage(Evas_Object *parent, const std::string &path, int size); - Evas_Object *makeOriginThumb(Evas_Object *parent, const std::string &path); - Evas_Object *makeDefaultOriginThumb(Evas_Object *parent, const std::string &path); - const std::string &defaultThumbsToStr(DefaultThumbs thumb); - std::string defaultThumbsToPath(DefaultThumbs thumb); + private: + void invalidate(); + ThumbId getThumbIdFromFile(const std::string &path); + Evas_Object *makeMask(Evas_Object *parent, int size); + Evas_Object *makeImage(Evas_Object *parent, const std::string &path, int size); + Evas_Object *makeOriginThumb(Evas_Object *parent, const std::string &path); + Evas_Object *makeDefaultOriginThumb(Evas_Object *parent, const std::string &path); + const std::string &defaultThumbsToStr(DefaultThumbs thumb); + std::string defaultThumbsToPath(DefaultThumbs thumb); - //IContactManagerListener - void onContactChanged() override; + //IContactManagerListener + void onContactChanged() override; - private: - const int maxStaticThumbId = GroupThumb; + private: + const int maxStaticThumbId = GroupThumb; - App &m_App; - ContactsMap m_ContactsMap; - OriginsMap m_OriginsMap; - ThumbId m_CurrentId; - }; + App &m_App; + ContactsMap m_ContactsMap; + OriginsMap m_OriginsMap; + ThumbId m_CurrentId; + }; } #endif /* ThumbnailMaker_h_ */ diff --git a/src/Common/Utils/inc/TimeUtils.h b/src/Common/Utils/inc/TimeUtils.h index 03c67f5..b7dfcae 100644 --- a/src/Common/Utils/inc/TimeUtils.h +++ b/src/Common/Utils/inc/TimeUtils.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -21,24 +21,24 @@ #include namespace Msg { - namespace TimeUtils { + namespace TimeUtils { - enum TimeFormat { - TimeFormatUnknown, - TimeFormat24H, - TimeFormat12H - }; + enum TimeFormat { + TimeFormatUnknown, + TimeFormat24H, + TimeFormat12H + }; - std::string makeThreadTimeString(time_t msgTime); - std::string makeBubbleTimeString(time_t msgTime); - std::string makeBubbleDateLineString(time_t msgTime); - std::string makeDateTimeString(time_t msgTime); - std::string makeDateString(time_t msgTime); - std::string makeSmsReportTimeString(time_t msgTime); - std::string makeMmsReportTimeString(time_t msgTime); - std::string makeCalEventString(time_t time); - std::string makeCalEventString(int year, int month, int mday, int hour, int min, const char *timezone = nullptr); - }; + std::string makeThreadTimeString(time_t msgTime); + std::string makeBubbleTimeString(time_t msgTime); + std::string makeBubbleDateLineString(time_t msgTime); + std::string makeDateTimeString(time_t msgTime); + std::string makeDateString(time_t msgTime); + std::string makeSmsReportTimeString(time_t msgTime); + std::string makeMmsReportTimeString(time_t msgTime); + std::string makeCalEventString(time_t time); + std::string makeCalEventString(int year, int month, int mday, int hour, int min, const char *timezone = nullptr); + }; } #endif /* __MSG_TIME_UTIL_H__ */ diff --git a/src/Common/Utils/inc/VCalendarParser.h b/src/Common/Utils/inc/VCalendarParser.h index d5c087e..29ddfc1 100644 --- a/src/Common/Utils/inc/VCalendarParser.h +++ b/src/Common/Utils/inc/VCalendarParser.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -22,29 +22,29 @@ #include namespace Msg { - class CalendarEvent { - public: - CalendarEvent(calendar_record_h record); - - const std::string &getSummary() const; - const std::string &getStartDate() const; - - private: - std::string m_Summary; - std::string m_StartDate; - }; - - class VCalendarParser { - public: - static VCalendarParser &getInst(); - std::list parse(const std::string &filePath); - - private: - VCalendarParser(); - ~VCalendarParser(); - VCalendarParser& operator=(VCalendarParser&) = delete; - VCalendarParser(VCalendarParser&) = delete; - }; + class CalendarEvent { + public: + CalendarEvent(calendar_record_h record); + + const std::string &getSummary() const; + const std::string &getStartDate() const; + + private: + std::string m_Summary; + std::string m_StartDate; + }; + + class VCalendarParser { + public: + static VCalendarParser &getInst(); + std::list parse(const std::string &filePath); + + private: + VCalendarParser(); + ~VCalendarParser(); + VCalendarParser& operator=(VCalendarParser&) = delete; + VCalendarParser(VCalendarParser&) = delete; + }; } #endif /* VCalendarParser_h_ */ diff --git a/src/Common/Utils/inc/WorkingDir.h b/src/Common/Utils/inc/WorkingDir.h index e44fb6b..91868a8 100644 --- a/src/Common/Utils/inc/WorkingDir.h +++ b/src/Common/Utils/inc/WorkingDir.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -22,34 +22,34 @@ #include namespace Msg { - class WorkingDir { - public: - WorkingDir(); - ~WorkingDir(); - - WorkingDir(WorkingDir&) = delete; - void operator=(WorkingDir&) = delete; - - bool isValid() const; - const std::string &getPath() const; - - std::string genUniqueFilePath(const std::string &fileName) const; - std::string addFile(const std::string &path); - std::string addTextFile(const std::string &text, const std::string &fileName = ""); - void removeFile(const std::string &path); - void clear(); - - private: - void createWorkingDir(); - void removeWorkingDir(); - std::string getUniqueDirName(const std::string &path); - - private: - std::string m_Path; - mutable std::recursive_mutex m_Mutex; - }; - - typedef std::shared_ptr WorkingDirRef; + class WorkingDir { + public: + WorkingDir(); + ~WorkingDir(); + + WorkingDir(WorkingDir&) = delete; + void operator=(WorkingDir&) = delete; + + bool isValid() const; + const std::string &getPath() const; + + std::string genUniqueFilePath(const std::string &fileName) const; + std::string addFile(const std::string &path); + std::string addTextFile(const std::string &text, const std::string &fileName = ""); + void removeFile(const std::string &path); + void clear(); + + private: + void createWorkingDir(); + void removeWorkingDir(); + std::string getUniqueDirName(const std::string &path); + + private: + std::string m_Path; + mutable std::recursive_mutex m_Mutex; + }; + + typedef std::shared_ptr WorkingDirRef; } #endif /* WorkingDir_h_ */ diff --git a/src/Common/Utils/src/FileUtils.cpp b/src/Common/Utils/src/FileUtils.cpp index d82f7bc..2cc29c3 100755 --- a/src/Common/Utils/src/FileUtils.cpp +++ b/src/Common/Utils/src/FileUtils.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -36,262 +36,262 @@ namespace FileUtils { long long getFileSize(const std::string &file) { - long long size = 0; + long long size = 0; - struct stat st = {}; - if (stat(file.c_str(), &st) == 0) - { - size = st.st_size; - } + struct stat st = {}; + if (stat(file.c_str(), &st) == 0) + { + size = st.st_size; + } - return size; + return size; } bool isExists(const std::string &file) { - bool res = false; - struct stat st = {}; - res = stat(file.c_str(), &st) == 0 || file == "/"; - return res; + bool res = false; + struct stat st = {}; + res = stat(file.c_str(), &st) == 0 || file == "/"; + return res; } bool copy(const std::string &src, const std::string &dst) { - FILE *f1 = nullptr; - FILE *f2 = nullptr; - - const size_t bufSize = 4 * 1024; - char buf[bufSize]; - - size_t num = 0; - bool ret = true; - - f1 = fopen(src.c_str(), "rb"); - if (!f1) - return false; - - f2 = fopen(dst.c_str(), "wb"); - if (!f2) - { - fclose(f1); - return false; - } - - while ((num = fread(buf, 1, sizeof(buf), f1)) > 0) - { - if (fwrite(buf, 1, num, f2) != num) - { - ret = false; - } - } - - fclose(f1); - fclose(f2); - - return ret; + FILE *f1 = nullptr; + FILE *f2 = nullptr; + + const size_t bufSize = 4 * 1024; + char buf[bufSize]; + + size_t num = 0; + bool ret = true; + + f1 = fopen(src.c_str(), "rb"); + if (!f1) + return false; + + f2 = fopen(dst.c_str(), "wb"); + if (!f2) + { + fclose(f1); + return false; + } + + while ((num = fread(buf, 1, sizeof(buf), f1)) > 0) + { + if (fwrite(buf, 1, num, f2) != num) + { + ret = false; + } + } + + fclose(f1); + fclose(f2); + + return ret; } bool makeDir(const std::string &dir) { - bool res = false; + bool res = false; - mode_t mode = S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH; - res = mkdir(dir.c_str(), mode) == 0; + mode_t mode = S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH; + res = mkdir(dir.c_str(), mode) == 0; - return res; + return res; } std::string addFileToDataDir(const std::string &path) { - std::string newPath; - if (isExists(path)) - { - std::string dataPath = PathUtils::getDataPath(""); - if (path.find(dataPath) != std::string::npos) - { - newPath = path; - MSG_LOG("File is already exists: ", newPath); - } else { - newPath = FileUtils::genUniqueFilePath(dataPath, path); - if (!copy(path, newPath)) - newPath.clear(); - } - } - - return newPath; + std::string newPath; + if (isExists(path)) + { + std::string dataPath = PathUtils::getDataPath(""); + if (path.find(dataPath) != std::string::npos) + { + newPath = path; + MSG_LOG("File is already exists: ", newPath); + } else { + newPath = FileUtils::genUniqueFilePath(dataPath, path); + if (!copy(path, newPath)) + newPath.clear(); + } + } + + return newPath; } bool isDir(const std::string &file) { - bool res = false; + bool res = false; - struct stat st = {}; - if (stat(file.c_str(), &st) == 0) - { - res = S_ISDIR(st.st_mode); - } + struct stat st = {}; + if (stat(file.c_str(), &st) == 0) + { + res = S_ISDIR(st.st_mode); + } - return res; + return res; } std::string stripExtension(const std::string &path) { - auto pos = path.find_last_of("."); - return pos == std::string::npos ? path : path.substr(0, pos); + auto pos = path.find_last_of("."); + return pos == std::string::npos ? path : path.substr(0, pos); } void splitPath(const std::string &path, std::string &basePath, - std::string &fileName, std::string &extension) + std::string &fileName, std::string &extension) { - auto pos = path.find_last_of('/'); - - 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) - { - extension = name.substr(pos + 1); - if (pos != 0) - fileName = extension.empty() ? name : name.substr(0, pos); - } else { - fileName = name; - } + auto pos = path.find_last_of('/'); + + 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) + { + extension = name.substr(pos + 1); + if (pos != 0) + fileName = extension.empty() ? name : name.substr(0, pos); + } else { + fileName = name; + } } std::string getFileName(const std::string &path) { - auto pos = path.find_last_of('/'); - return pos != std::string::npos ? path.substr(pos + 1) : path; + auto pos = path.find_last_of('/'); + return pos != std::string::npos ? path.substr(pos + 1) : path; } bool remove(const std::string &path, bool removeCurrentDir) { - bool res = true; - struct dirent *dirData = nullptr; - DIR *dp = opendir(path.c_str()); - - if (dp) { - while (true) { - dirData = readdir(dp); - - if (dirData == nullptr) - break; - - 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) - res &= rmdir(path.c_str()) == 0; - } else { - res &= unlink(path.c_str()) == 0; - } - - return res; + bool res = true; + struct dirent *dirData = nullptr; + DIR *dp = opendir(path.c_str()); + + if (dp) { + while (true) { + dirData = readdir(dp); + + if (dirData == nullptr) + break; + + 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) + res &= rmdir(path.c_str()) == 0; + } else { + res &= unlink(path.c_str()) == 0; + } + + return res; } std::string readTextFile(const std::string &path) { - std::ifstream fs(path, std::ifstream::in | std::ifstream::binary); - return fs.is_open() ? std::string(std::istreambuf_iterator(fs), std::istreambuf_iterator()) : ""; + std::ifstream fs(path, std::ifstream::in | std::ifstream::binary); + return fs.is_open() ? std::string(std::istreambuf_iterator(fs), std::istreambuf_iterator()) : ""; } bool 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()) - file << text; - return file.is_open() && file.good(); + std::ofstream file(path, std::ofstream::trunc | std::ofstream::binary | std::ofstream::out); + if (file.is_open()) + file << text; + return file.is_open() && file.good(); } std::string genUniqueFilePath(const std::string &storagePath, const std::string &filePath) { - std::string res = filePath; - std::string base; - std::string name; - std::string ext; - splitPath(filePath, base, name, ext); - - unsigned i = 0; - do - { - res = storagePath; - if (res.back() != '/') - res += '/'; - - res += name; - if (i > 0) - res += "-" + std::to_string(i); - if (!ext.empty()) - res += '.' + ext; - ++i; - } while (isExists(res)); - return res; + std::string res = filePath; + std::string base; + std::string name; + std::string ext; + splitPath(filePath, base, name, ext); + + unsigned i = 0; + do + { + res = storagePath; + if (res.back() != '/') + res += '/'; + + res += name; + if (i > 0) + res += "-" + std::to_string(i); + if (!ext.empty()) + res += '.' + ext; + ++i; + } while (isExists(res)); + return res; } std::string getMimeType(const std::string &filePath) { - std::string res; - std::string base; - std::string name; - std::string ext; - splitPath(filePath, base, name, ext); - if (!ext.empty()) - { - char *mime = nullptr; - mime_type_get_mime_type(ext.c_str(), &mime); - if (mime) - { - res = mime; - std::transform(res.begin(), res.end(), res.begin(), ::tolower); - free(mime); - } - } - return res; + std::string res; + std::string base; + std::string name; + std::string ext; + splitPath(filePath, base, name, ext); + if (!ext.empty()) + { + char *mime = nullptr; + mime_type_get_mime_type(ext.c_str(), &mime); + if (mime) + { + res = mime; + std::transform(res.begin(), res.end(), res.begin(), ::tolower); + free(mime); + } + } + return res; } static bool saveFileToStoragePrivate(const std::string &file) { - bool res = false; + bool res = false; - std::string dowloadPath = PathUtils::getDownloadPath(); - std::string filePathDst = FileUtils::genUniqueFilePath(dowloadPath, file); + std::string dowloadPath = PathUtils::getDownloadPath(); + std::string filePathDst = FileUtils::genUniqueFilePath(dowloadPath, file); - if (FileUtils::copy(file, filePathDst)) - res = media_content_scan_file(filePathDst.c_str()) == MEDIA_CONTENT_ERROR_NONE; + if (FileUtils::copy(file, filePathDst)) + res = media_content_scan_file(filePathDst.c_str()) == MEDIA_CONTENT_ERROR_NONE; - return res; + return res; } bool saveFilesToStorage(const std::list &files) { - bool res = true; - if (media_content_connect() != 0) - return false; - - for (const std::string &file : files) - { - res &= saveFileToStoragePrivate(file); - } - media_content_disconnect(); - return res; + bool res = true; + if (media_content_connect() != 0) + return false; + + for (const std::string &file : files) + { + res &= saveFileToStoragePrivate(file); + } + media_content_disconnect(); + return res; } bool saveFileToStorage(const std::string &file) { - if (media_content_connect() != 0) - return false; + if (media_content_connect() != 0) + return false; - bool res = saveFileToStoragePrivate(file); + bool res = saveFileToStoragePrivate(file); - media_content_disconnect(); - return res; + media_content_disconnect(); + return res; } } // FileUtils diff --git a/src/Common/Utils/src/LoggerImpl.cpp b/src/Common/Utils/src/LoggerImpl.cpp index d1f89bc..f2a1305 100644 --- a/src/Common/Utils/src/LoggerImpl.cpp +++ b/src/Common/Utils/src/LoggerImpl.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -18,29 +18,29 @@ namespace { - const std::string enterFraseFormat = "%s: %s(%d) -> [ENTER]"; - const std::string leaveFraseFormat = "%s: %s -> [LEAVE]"; - const log_priority defaultPriority = DLOG_DEBUG; + const std::string enterFraseFormat = "%s: %s(%d) -> [ENTER]"; + const std::string leaveFraseFormat = "%s: %s -> [LEAVE]"; + const log_priority defaultPriority = DLOG_DEBUG; } LoggerImpl::LoggerImpl(const char *tag, const char *file, const char *function, int line) - : m_Tag(tag) - , m_File(file) - , m_Function(function) + : m_Tag(tag) + , m_File(file) + , m_Function(function) { - dlog_print(defaultPriority - , m_Tag.c_str() - , enterFraseFormat.c_str() - , m_File.c_str() - , m_Function.c_str() - , line); + dlog_print(defaultPriority + , m_Tag.c_str() + , enterFraseFormat.c_str() + , m_File.c_str() + , m_Function.c_str() + , line); } LoggerImpl::~LoggerImpl() { - dlog_print(defaultPriority - , m_Tag.c_str() - , leaveFraseFormat.c_str() - , m_File.c_str() - , m_Function.c_str()); + dlog_print(defaultPriority + , m_Tag.c_str() + , leaveFraseFormat.c_str() + , m_File.c_str() + , m_Function.c_str()); } diff --git a/src/Common/Utils/src/MediaPlayer.cpp b/src/Common/Utils/src/MediaPlayer.cpp index e2a131b..cd97fe0 100644 --- a/src/Common/Utils/src/MediaPlayer.cpp +++ b/src/Common/Utils/src/MediaPlayer.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -23,187 +23,187 @@ using namespace Msg; MediaPlayer::MediaPlayer() - : m_Player() - , m_pListener(nullptr) - , m_StreamInfo() -{ - sound_manager_create_stream_information(SOUND_STREAM_TYPE_MEDIA, - makeCbLast(&MediaPlayer::onSoundStreamFocusStateChanged), this, &m_StreamInfo); - if (m_StreamInfo) { - player_create(&m_Player); - if (m_Player) { - player_set_sound_type(m_Player, SOUND_TYPE_MEDIA); - player_set_volume(m_Player, 1.0, 1.0); - player_set_looping(m_Player, false); - player_set_sound_stream_info(m_Player, m_StreamInfo); - player_set_completed_cb(m_Player, makeCbLast(&MediaPlayer::onCompleted), this); - } - } + : m_Player() + , m_pListener(nullptr) + , m_StreamInfo() +{ + sound_manager_create_stream_information(SOUND_STREAM_TYPE_MEDIA, + makeCbLast(&MediaPlayer::onSoundStreamFocusStateChanged), this, &m_StreamInfo); + if (m_StreamInfo) { + player_create(&m_Player); + if (m_Player) { + player_set_sound_type(m_Player, SOUND_TYPE_MEDIA); + player_set_volume(m_Player, 1.0, 1.0); + player_set_looping(m_Player, false); + player_set_sound_stream_info(m_Player, m_StreamInfo); + player_set_completed_cb(m_Player, makeCbLast(&MediaPlayer::onCompleted), this); + } + } } MediaPlayer::~MediaPlayer() { - m_pListener = nullptr; - stop(); + m_pListener = nullptr; + stop(); - if (m_StreamInfo) - sound_manager_destroy_stream_information(m_StreamInfo); + if (m_StreamInfo) + sound_manager_destroy_stream_information(m_StreamInfo); - if (m_Player) { - player_unprepare(m_Player); - player_destroy(m_Player); - } + if (m_Player) { + player_unprepare(m_Player); + player_destroy(m_Player); + } } void MediaPlayer::setDisplay(Evas_Object *obj) { - player_set_display_mode(m_Player, PLAYER_DISPLAY_MODE_LETTER_BOX); - player_set_display(m_Player, PLAYER_DISPLAY_TYPE_EVAS, GET_DISPLAY(obj)); - player_set_display_visible(m_Player, obj != nullptr); + player_set_display_mode(m_Player, PLAYER_DISPLAY_MODE_LETTER_BOX); + player_set_display(m_Player, PLAYER_DISPLAY_TYPE_EVAS, GET_DISPLAY(obj)); + player_set_display_visible(m_Player, obj != nullptr); } player_state_e MediaPlayer::getState() const { - player_state_e state = PLAYER_STATE_NONE; - player_get_state(m_Player, &state); - return state; + player_state_e state = PLAYER_STATE_NONE; + player_get_state(m_Player, &state); + return state; } bool MediaPlayer::isCallReason(sound_stream_focus_change_reason_e reason) { - return reason == SOUND_STREAM_FOCUS_CHANGED_BY_RINGTONE || - reason == SOUND_STREAM_FOCUS_CHANGED_BY_VOIP || - reason == SOUND_STREAM_FOCUS_CHANGED_BY_CALL; + return reason == SOUND_STREAM_FOCUS_CHANGED_BY_RINGTONE || + reason == SOUND_STREAM_FOCUS_CHANGED_BY_VOIP || + reason == SOUND_STREAM_FOCUS_CHANGED_BY_CALL; } bool MediaPlayer::getFocus() const { - sound_stream_focus_change_reason_e acquiredBy = SOUND_STREAM_FOCUS_CHANGED_BY_MEDIA; - int flags = 0; - char *extraInfo = nullptr; + sound_stream_focus_change_reason_e acquiredBy = SOUND_STREAM_FOCUS_CHANGED_BY_MEDIA; + int flags = 0; + char *extraInfo = nullptr; - if (sound_manager_get_current_playback_focus(&acquiredBy, &flags, &extraInfo) == SOUND_MANAGER_ERROR_NONE) { - free(extraInfo); - return !isCallReason(acquiredBy); - } + if (sound_manager_get_current_playback_focus(&acquiredBy, &flags, &extraInfo) == SOUND_MANAGER_ERROR_NONE) { + free(extraInfo); + return !isCallReason(acquiredBy); + } - return true; + return true; } bool MediaPlayer::start() { - sound_manager_acquire_focus(m_StreamInfo, SOUND_STREAM_FOCUS_FOR_PLAYBACK, SOUND_BEHAVIOR_NONE, nullptr); - if (getState() == PLAYER_STATE_IDLE) - player_prepare(m_Player); + sound_manager_acquire_focus(m_StreamInfo, SOUND_STREAM_FOCUS_FOR_PLAYBACK, SOUND_BEHAVIOR_NONE, nullptr); + if (getState() == PLAYER_STATE_IDLE) + player_prepare(m_Player); - if (getState() != PLAYER_STATE_PLAYING) - player_start(m_Player); + if (getState() != PLAYER_STATE_PLAYING) + player_start(m_Player); - return getState() == PLAYER_STATE_PLAYING; + return getState() == PLAYER_STATE_PLAYING; } void MediaPlayer::stop() { - sound_manager_release_focus(m_StreamInfo, SOUND_STREAM_FOCUS_FOR_PLAYBACK, SOUND_BEHAVIOR_NONE, nullptr); - player_state_e state = getState(); - if (state == PLAYER_STATE_PLAYING || state == PLAYER_STATE_PAUSED) - player_stop(m_Player); + sound_manager_release_focus(m_StreamInfo, SOUND_STREAM_FOCUS_FOR_PLAYBACK, SOUND_BEHAVIOR_NONE, nullptr); + player_state_e state = getState(); + if (state == PLAYER_STATE_PLAYING || state == PLAYER_STATE_PAUSED) + player_stop(m_Player); } void MediaPlayer::pause() { - if (getState() == PLAYER_STATE_PLAYING) - player_pause(m_Player); + if (getState() == PLAYER_STATE_PLAYING) + player_pause(m_Player); } bool MediaPlayer::isPlaying() const { - return getState() == PLAYER_STATE_PLAYING; + return getState() == PLAYER_STATE_PLAYING; } void MediaPlayer::setUri(const std::string &uri) { - stop(); - player_unprepare(m_Player); - player_set_uri(m_Player, uri.c_str()); + stop(); + player_unprepare(m_Player); + player_set_uri(m_Player, uri.c_str()); } void MediaPlayer::setListener(IMediaPlayerListener *l) { - m_pListener = l; + m_pListener = l; } int MediaPlayer::getDuration() const { - int msec = 0; - player_get_duration(m_Player, &msec); - return msec; + int msec = 0; + player_get_duration(m_Player, &msec); + return msec; } void MediaPlayer::setPosition(int msec) { - if (getState() == PLAYER_STATE_IDLE) - player_prepare(m_Player); + if (getState() == PLAYER_STATE_IDLE) + player_prepare(m_Player); - player_state_e state = getState(); - if (state == PLAYER_STATE_PLAYING || state == PLAYER_STATE_PAUSED || state == PLAYER_STATE_READY) - player_set_play_position(m_Player, msec, true, makeCbLast(&MediaPlayer::onSeek), this); + player_state_e state = getState(); + if (state == PLAYER_STATE_PLAYING || state == PLAYER_STATE_PAUSED || state == PLAYER_STATE_READY) + player_set_play_position(m_Player, msec, true, makeCbLast(&MediaPlayer::onSeek), this); } int MediaPlayer::getPosition() const { - int msec = 0; - player_state_e state = getState(); - if (state == PLAYER_STATE_PLAYING || state == PLAYER_STATE_PAUSED || state == PLAYER_STATE_READY) - player_get_play_position(m_Player, &msec); + int msec = 0; + player_state_e state = getState(); + if (state == PLAYER_STATE_PLAYING || state == PLAYER_STATE_PAUSED || state == PLAYER_STATE_READY) + player_get_play_position(m_Player, &msec); - return msec; + return msec; } int MediaPlayer::getDuration(const std::string &uri) { - int msec = 0; - if (!uri.empty()) { - player_h player = {}; - player_create(&player); - if (player_set_uri(player, uri.c_str()) == PLAYER_ERROR_NONE) { - player_prepare(player); - player_get_duration(player, &msec); - player_unprepare(player); - } - player_destroy(player); - } - return msec; + int msec = 0; + if (!uri.empty()) { + player_h player = {}; + player_create(&player); + if (player_set_uri(player, uri.c_str()) == PLAYER_ERROR_NONE) { + player_prepare(player); + player_get_duration(player, &msec); + player_unprepare(player); + } + player_destroy(player); + } + return msec; } void MediaPlayer::onCompleted() { - stop(); - if (m_pListener) - m_pListener->onCompleted(*this); + stop(); + if (m_pListener) + m_pListener->onCompleted(*this); } void MediaPlayer::onSeek() { - MSG_LOG(""); + MSG_LOG(""); } void MediaPlayer::onSoundStreamFocusStateChanged(sound_stream_info_h stream_info, - sound_stream_focus_mask_e focus_mask, - sound_stream_focus_state_e focus_state, - sound_stream_focus_change_reason_e reason, - int sound_behavior, - const char *extra_info) -{ - MSG_LOG("Interrupted focus change reason = ", reason); - if (isCallReason(reason)) { - ecore_main_loop_thread_safe_call_async( - [](void *data) - { - auto *self = (MediaPlayer*)data; - if (self->m_pListener) - self->m_pListener->onSoundFocusChanged(*self); - }, - this); - } + sound_stream_focus_mask_e focus_mask, + sound_stream_focus_state_e focus_state, + sound_stream_focus_change_reason_e reason, + int sound_behavior, + const char *extra_info) +{ + MSG_LOG("Interrupted focus change reason = ", reason); + if (isCallReason(reason)) { + ecore_main_loop_thread_safe_call_async( + [](void *data) + { + auto *self = (MediaPlayer*)data; + if (self->m_pListener) + self->m_pListener->onSoundFocusChanged(*self); + }, + this); + } } diff --git a/src/Common/Utils/src/MediaPlayerProvider.cpp b/src/Common/Utils/src/MediaPlayerProvider.cpp index d9cf321..4d7f454 100644 --- a/src/Common/Utils/src/MediaPlayerProvider.cpp +++ b/src/Common/Utils/src/MediaPlayerProvider.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -19,7 +19,7 @@ using namespace Msg; MediaPlayerProvider::MediaPlayerProvider() - : m_pClient(nullptr) + : m_pClient(nullptr) { } @@ -29,37 +29,37 @@ MediaPlayerProvider::~MediaPlayerProvider() MediaPlayer &MediaPlayerProvider::acquire(IMediaPlayerProviderClient *client) { - if (!m_Player) - m_Player.reset(new MediaPlayer); + if (!m_Player) + m_Player.reset(new MediaPlayer); - if (m_pClient != client) { - release(m_pClient); + if (m_pClient != client) { + release(m_pClient); - m_pClient = client; + m_pClient = client; - if (m_pClient) - m_pClient->onAcquire(*this); - } + if (m_pClient) + m_pClient->onAcquire(*this); + } - return *m_Player; + return *m_Player; } void MediaPlayerProvider::release(IMediaPlayerProviderClient *client) { - if (m_pClient == client && m_Player) { + if (m_pClient == client && m_Player) { - IMediaPlayerProviderClient *client = m_pClient; - m_pClient = nullptr; + IMediaPlayerProviderClient *client = m_pClient; + m_pClient = nullptr; - if (client) - client->onRelease(*this); + if (client) + client->onRelease(*this); - m_Player->stop(); - m_Player->setListener(nullptr); - } + m_Player->stop(); + m_Player->setListener(nullptr); + } } IMediaPlayerProviderClient *MediaPlayerProvider::getClient() const { - return m_pClient; + return m_pClient; } diff --git a/src/Common/Utils/src/MediaUtils.cpp b/src/Common/Utils/src/MediaUtils.cpp index 6bc29c4..f6d01c7 100644 --- a/src/Common/Utils/src/MediaUtils.cpp +++ b/src/Common/Utils/src/MediaUtils.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -34,307 +34,307 @@ const unsigned int JPEG_HEADER_OFFSET = 20; class MetadataExtractor { - public: - MetadataExtractor(const std::string &path) - : m_Metadata() - { - if (FileUtils::isExists(path)) - { - metadata_extractor_create(&m_Metadata); - if (metadata_extractor_set_path(m_Metadata, path.c_str()) != 0) - { - metadata_extractor_destroy(m_Metadata); - m_Metadata = nullptr; - } - } - } - - ~MetadataExtractor() - { - if (m_Metadata) - metadata_extractor_destroy(m_Metadata); - } - - bool isValid() const - { - return m_Metadata != nullptr; - } - - int getInt(metadata_extractor_attr_e attr) const - { - std::string str = getStr(attr); - return str.empty() ? 0 : atoi(str.c_str()); - } - - int getBool(metadata_extractor_attr_e attr) const - { - std::string str = getStr(attr); - return str == "1"; - } - - std::string getStr(metadata_extractor_attr_e attr) const - { - std::string res; - char *cStr = nullptr; - metadata_extractor_get_metadata(m_Metadata, attr, &cStr); - if (cStr) - { - res = cStr; - free(cStr); - } - return res; - } - - bool getFrame(void **frame, int *size) const - { - return metadata_extractor_get_frame(m_Metadata, frame, size) == 0; - } - - private: - metadata_extractor_h m_Metadata; + public: + MetadataExtractor(const std::string &path) + : m_Metadata() + { + if (FileUtils::isExists(path)) + { + metadata_extractor_create(&m_Metadata); + if (metadata_extractor_set_path(m_Metadata, path.c_str()) != 0) + { + metadata_extractor_destroy(m_Metadata); + m_Metadata = nullptr; + } + } + } + + ~MetadataExtractor() + { + if (m_Metadata) + metadata_extractor_destroy(m_Metadata); + } + + bool isValid() const + { + return m_Metadata != nullptr; + } + + int getInt(metadata_extractor_attr_e attr) const + { + std::string str = getStr(attr); + return str.empty() ? 0 : atoi(str.c_str()); + } + + int getBool(metadata_extractor_attr_e attr) const + { + std::string str = getStr(attr); + return str == "1"; + } + + std::string getStr(metadata_extractor_attr_e attr) const + { + std::string res; + char *cStr = nullptr; + metadata_extractor_get_metadata(m_Metadata, attr, &cStr); + if (cStr) + { + res = cStr; + free(cStr); + } + return res; + } + + bool getFrame(void **frame, int *size) const + { + return metadata_extractor_get_frame(m_Metadata, frame, size) == 0; + } + + private: + metadata_extractor_h m_Metadata; }; std::string getTitle(const std::string &path) { - std::string fileName = FileUtils::getFileName(path); + std::string fileName = FileUtils::getFileName(path); - MetadataExtractor extractor(path); - if (!extractor.isValid()) - return fileName; + MetadataExtractor extractor(path); + if (!extractor.isValid()) + return fileName; - std::string title = extractor.getStr(METADATA_TITLE); - return title.empty() ? fileName : title; + std::string title = extractor.getStr(METADATA_TITLE); + return title.empty() ? fileName : title; } int getDuration(const std::string &uri) { - MetadataExtractor extractor(uri); - int duration = 0; - if (extractor.isValid()) { - duration = extractor.getInt(METADATA_DURATION); - MSG_LOG("Duration msec: ", duration); - } - return duration; + MetadataExtractor extractor(uri); + int duration = 0; + if (extractor.isValid()) { + duration = extractor.getInt(METADATA_DURATION); + MSG_LOG("Duration msec: ", duration); + } + return duration; } int getDurationSec(const std::string &uri) { - double sec = ceil(getDuration(uri) / 1000.0); + double sec = ceil(getDuration(uri) / 1000.0); - MSG_LOG("File: ", uri); - MSG_LOG("Duration sec: ", sec); + MSG_LOG("File: ", uri); + MSG_LOG("Duration sec: ", sec); - if (sec < 0) - return 0; + if (sec < 0) + return 0; - return sec; + return sec; } bool getVideoFrame(const std::string &videoFilePath, const std::string &imageFilePath) { - MetadataExtractor extractor(videoFilePath); - if (!extractor.isValid()) - return false; - - int videoW = extractor.getInt(METADATA_VIDEO_WIDTH); - int videoH = extractor.getInt(METADATA_VIDEO_HEIGHT); - - int thumbSize = 0; - void *thumbnail = nullptr; - extractor.getFrame(&thumbnail, &thumbSize); - - MSG_LOG("File: ", videoFilePath); - MSG_LOG("Frame: width = ", videoW, " height = ", videoH, " size = ", thumbSize); - - 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) - { - free(thumbnail); - return false; - } - - isOk &= image_util_encode_set_resolution(encode_h, videoW, videoH) == IMAGE_UTIL_ERROR_NONE; - isOk &= image_util_encode_set_colorspace(encode_h, IMAGE_UTIL_COLORSPACE_RGB888) == IMAGE_UTIL_ERROR_NONE; - 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) - { - image_util_encode_destroy(encode_h); - free(thumbnail); - return false; - } - - isOk = image_util_encode_run(encode_h, nullptr) == IMAGE_UTIL_ERROR_NONE; - image_util_encode_destroy(encode_h); - free(thumbnail); - return isOk; - } - return false; + MetadataExtractor extractor(videoFilePath); + if (!extractor.isValid()) + return false; + + int videoW = extractor.getInt(METADATA_VIDEO_WIDTH); + int videoH = extractor.getInt(METADATA_VIDEO_HEIGHT); + + int thumbSize = 0; + void *thumbnail = nullptr; + extractor.getFrame(&thumbnail, &thumbSize); + + MSG_LOG("File: ", videoFilePath); + MSG_LOG("Frame: width = ", videoW, " height = ", videoH, " size = ", thumbSize); + + 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) + { + free(thumbnail); + return false; + } + + isOk &= image_util_encode_set_resolution(encode_h, videoW, videoH) == IMAGE_UTIL_ERROR_NONE; + isOk &= image_util_encode_set_colorspace(encode_h, IMAGE_UTIL_COLORSPACE_RGB888) == IMAGE_UTIL_ERROR_NONE; + 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) + { + image_util_encode_destroy(encode_h); + free(thumbnail); + return false; + } + + isOk = image_util_encode_run(encode_h, nullptr) == IMAGE_UTIL_ERROR_NONE; + image_util_encode_destroy(encode_h); + free(thumbnail); + return isOk; + } + return false; } bool getFrameSize(const std::string &videoFilePath, int &width, int &height) { - MetadataExtractor extractor(videoFilePath); - if (!extractor.isValid()) - return false; + MetadataExtractor extractor(videoFilePath); + 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) - std::swap(width, height); + width = extractor.getInt(METADATA_VIDEO_WIDTH); + height = extractor.getInt(METADATA_VIDEO_HEIGHT); + int orient = extractor.getInt(METADATA_ROTATE); + if (orient == 90 || orient == 270) + std::swap(width, height); - MSG_LOG("File: ", videoFilePath); - MSG_LOG("Frame: width = ", width, " height = ", height); + MSG_LOG("File: ", videoFilePath); + MSG_LOG("Frame: width = ", width, " height = ", height); - return true; + return true; } bool hasAudio(const std::string &path) { - MetadataExtractor extractor(path); - if (!extractor.isValid()) - return false; + MetadataExtractor extractor(path); + if (!extractor.isValid()) + return false; - return extractor.getBool(METADATA_HAS_AUDIO); + return extractor.getBool(METADATA_HAS_AUDIO); } bool hasVideo(const std::string &path) { - MetadataExtractor extractor(path); - if (!extractor.isValid()) - return false; + MetadataExtractor extractor(path); + if (!extractor.isValid()) + return false; - return extractor.getBool(METADATA_HAS_VIDEO); + return extractor.getBool(METADATA_HAS_VIDEO); } long long downgradeImageQuality(const std::string &imagePath) { - image_util_decode_h decode_h = {}; - image_util_encode_h encode_h = {}; - unsigned char *buffer = nullptr; - unsigned long width = 0; - unsigned long height = 0; - int res = IMAGE_UTIL_ERROR_NONE; - ExifData *exifData = nullptr; - unsigned char *exifBuff = nullptr; - unsigned int exifBuffLen = 0; - unsigned char *jpegBuff = nullptr; - unsigned long long int jpegBuffLen = 0; - std::ofstream outputFile; - - exifData = exif_data_new_from_file(imagePath.c_str()); - if (exifData) - { - exif_data_save_data(exifData, &exifBuff, &exifBuffLen); - } - - res = image_util_decode_create(&decode_h); - 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) - { - 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) - { - 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) - { - return FileUtils::getFileSize(imagePath); - } - - res = image_util_encode_create(IMAGE_UTIL_JPEG, &encode_h); - 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) - { - 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) - { - 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) - { - 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) - { - 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) - { - free(buffer); - free(jpegBuff); - return FileUtils::getFileSize(imagePath); - } - - outputFile.open(imagePath.c_str()); - if (!outputFile.is_open()) - { - MSG_LOG_ERROR("Can't open file for write"); - free(buffer); - free(jpegBuff); - return FileUtils::getFileSize(imagePath); - } - if (exifData) - { - // Write EXIF header - outputFile.write((char *)EXIF_HEADER, EXIF_HEADER_LEN); - // Write EXIF block length in big-endian order - outputFile.put((exifBuffLen+2) >> 8); - outputFile.put((exifBuffLen+2) & 0xff); - // Write EXIF data block - outputFile.write((char *)exifBuff, exifBuffLen); - // Write JPEG image data, skipping the non-EXIF header - outputFile.write((char *)jpegBuff + JPEG_HEADER_OFFSET, jpegBuffLen - JPEG_HEADER_OFFSET); - free(exifBuff); - exif_data_unref(exifData); - } else { - // Write JPEG image data - outputFile.write((char *)jpegBuff, jpegBuffLen); - } - outputFile.close(); - free(buffer); - free(jpegBuff); - - return FileUtils::getFileSize(imagePath); + image_util_decode_h decode_h = {}; + image_util_encode_h encode_h = {}; + unsigned char *buffer = nullptr; + unsigned long width = 0; + unsigned long height = 0; + int res = IMAGE_UTIL_ERROR_NONE; + ExifData *exifData = nullptr; + unsigned char *exifBuff = nullptr; + unsigned int exifBuffLen = 0; + unsigned char *jpegBuff = nullptr; + unsigned long long int jpegBuffLen = 0; + std::ofstream outputFile; + + exifData = exif_data_new_from_file(imagePath.c_str()); + if (exifData) + { + exif_data_save_data(exifData, &exifBuff, &exifBuffLen); + } + + res = image_util_decode_create(&decode_h); + 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) + { + 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) + { + 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) + { + return FileUtils::getFileSize(imagePath); + } + + res = image_util_encode_create(IMAGE_UTIL_JPEG, &encode_h); + 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) + { + 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) + { + 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) + { + 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) + { + 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) + { + free(buffer); + free(jpegBuff); + return FileUtils::getFileSize(imagePath); + } + + outputFile.open(imagePath.c_str()); + if (!outputFile.is_open()) + { + MSG_LOG_ERROR("Can't open file for write"); + free(buffer); + free(jpegBuff); + return FileUtils::getFileSize(imagePath); + } + if (exifData) + { + // Write EXIF header + outputFile.write((char *)EXIF_HEADER, EXIF_HEADER_LEN); + // Write EXIF block length in big-endian order + outputFile.put((exifBuffLen+2) >> 8); + outputFile.put((exifBuffLen+2) & 0xff); + // Write EXIF data block + outputFile.write((char *)exifBuff, exifBuffLen); + // Write JPEG image data, skipping the non-EXIF header + outputFile.write((char *)jpegBuff + JPEG_HEADER_OFFSET, jpegBuffLen - JPEG_HEADER_OFFSET); + free(exifBuff); + exif_data_unref(exifData); + } else { + // Write JPEG image data + outputFile.write((char *)jpegBuff, jpegBuffLen); + } + outputFile.close(); + free(buffer); + free(jpegBuff); + + return FileUtils::getFileSize(imagePath); } } // MediaUtils diff --git a/src/Common/Utils/src/PathUtils.cpp b/src/Common/Utils/src/PathUtils.cpp index 8dd599e..0bbce10 100644 --- a/src/Common/Utils/src/PathUtils.cpp +++ b/src/Common/Utils/src/PathUtils.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -26,124 +26,124 @@ namespace PathUtils { std::string getResourcePath(const std::string &filePath) { - std::string res; - static std::string basePath; - if (basePath.empty()) - { - char *path = app_get_resource_path(); - if (path) - { - basePath = path; - free(path); - } - } - - res += basePath; - res += filePath; - - return res; + std::string res; + static std::string basePath; + if (basePath.empty()) + { + char *path = app_get_resource_path(); + if (path) + { + basePath = path; + free(path); + } + } + + res += basePath; + res += filePath; + + return res; } std::string getDataPath(const std::string &filePath) { - std::string res; - static std::string basePath; - if (basePath.empty()) - { - char *path = app_get_data_path(); - if (path) - { - basePath = path; - free(path); - } - } - - res += basePath; - res += filePath; - - return res; + std::string res; + static std::string basePath; + if (basePath.empty()) + { + char *path = app_get_data_path(); + if (path) + { + basePath = path; + free(path); + } + } + + res += basePath; + res += filePath; + + return res; } std::string getResourcePath() { - std::string res; - char* resPath = app_get_resource_path(); - if (resPath) - { - res = resPath; - free(resPath); - } - - return res; + std::string res; + char* resPath = app_get_resource_path(); + if (resPath) + { + res = resPath; + free(resPath); + } + + return res; } std::string getLocalePath() { - std::string resPath(getResourcePath()); - if (!resPath.empty()) - { - resPath.append("locale"); - } + std::string resPath(getResourcePath()); + if (!resPath.empty()) + { + resPath.append("locale"); + } - return resPath; + return resPath; } static bool storageCb(int storageId, storage_type_e type, storage_state_e state, const char *path, void *userData) { - if (type == STORAGE_TYPE_INTERNAL && - state == STORAGE_STATE_MOUNTED) - { - int *internalStorage = (int *)userData; - *internalStorage = storageId; - return false; - } - return true; + if (type == STORAGE_TYPE_INTERNAL && + state == STORAGE_STATE_MOUNTED) + { + int *internalStorage = (int *)userData; + *internalStorage = storageId; + return false; + } + return true; } const std::string &getDownloadPath() { - static std::string downloadPath; + static std::string downloadPath; - if (!downloadPath.empty()) - return downloadPath; + if (!downloadPath.empty()) + return downloadPath; - char *dirPath = nullptr; - int storageId = -1; + char *dirPath = nullptr; + int storageId = -1; - int error = storage_foreach_device_supported(storageCb, &storageId); - if (error == STORAGE_ERROR_NONE && storageId != -1) - storage_get_directory(storageId, STORAGE_DIRECTORY_DOWNLOADS, &dirPath); + int error = storage_foreach_device_supported(storageCb, &storageId); + if (error == STORAGE_ERROR_NONE && storageId != -1) + storage_get_directory(storageId, STORAGE_DIRECTORY_DOWNLOADS, &dirPath); - if (dirPath) - { - downloadPath = dirPath; - free(dirPath); - } + if (dirPath) + { + downloadPath = dirPath; + free(dirPath); + } - return downloadPath; + return downloadPath; } std::string getEdjePath(const std::string &fileName) { - return getResourcePath(EDJ_PATH"/" + fileName); + return getResourcePath(EDJ_PATH"/" + fileName); } std::string getSharedResPath(const std::string &fileName) { - std::string res; - static std::string basePath; - if (basePath.empty()) { - char *path = app_get_shared_resource_path(); - if (path) { - basePath = path; - free(path); - } - } - - res += basePath; - res += fileName; - - return res; + std::string res; + static std::string basePath; + if (basePath.empty()) { + char *path = app_get_shared_resource_path(); + if (path) { + basePath = path; + free(path); + } + } + + res += basePath; + res += fileName; + + return res; } } // PathUtils diff --git a/src/Common/Utils/src/PhoneNumberUtils.cpp b/src/Common/Utils/src/PhoneNumberUtils.cpp index b9c6bb0..86d093b 100644 --- a/src/Common/Utils/src/PhoneNumberUtils.cpp +++ b/src/Common/Utils/src/PhoneNumberUtils.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -24,30 +24,30 @@ using namespace Msg; PhoneNumberUtils &PhoneNumberUtils::getInst() { - static PhoneNumberUtils inst; - return inst; + static PhoneNumberUtils inst; + return inst; } std::string PhoneNumberUtils::getNormalizedNumber(const std::string &number) const { - std::string res; - char *normalizedNum = nullptr; - phone_number_get_normalized_number(number.c_str(), &normalizedNum); - if (normalizedNum) - { - res = normalizedNum; - free(normalizedNum); - } - return res; + std::string res; + char *normalizedNum = nullptr; + phone_number_get_normalized_number(number.c_str(), &normalizedNum); + if (normalizedNum) + { + res = normalizedNum; + free(normalizedNum); + } + return res; } PhoneNumberUtils::PhoneNumberUtils() { - int res = phone_number_connect(); - MSG_LOG("phone_number_connect = ", res); + int res = phone_number_connect(); + MSG_LOG("phone_number_connect = ", res); } PhoneNumberUtils::~PhoneNumberUtils() { - phone_number_disconnect(); + phone_number_disconnect(); } diff --git a/src/Common/Utils/src/TextDecorator.cpp b/src/Common/Utils/src/TextDecorator.cpp index c7345da..5b36793 100644 --- a/src/Common/Utils/src/TextDecorator.cpp +++ b/src/Common/Utils/src/TextDecorator.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -32,62 +32,62 @@ const int TextStyle::defaultFontSize = 28; namespace { - const char *alignAsString(TextStyle::Align align) - { - switch (align) - { - case TextStyle::Align::Center: - return "center"; - case TextStyle::Align::Left: - return "left"; - case TextStyle::Align::Right: - return "right"; - case TextStyle::Align::None: - default: - break; - } - - assert(false); - return ""; - } - - const char *weightAsString(TextStyle::Weight wight) - { - switch (wight) - { - case TextStyle::Weight::Bold: - return "bold"; - case TextStyle::Weight::None: - default: - break; - } - - assert(false); - return ""; - } + const char *alignAsString(TextStyle::Align align) + { + switch (align) + { + case TextStyle::Align::Center: + return "center"; + case TextStyle::Align::Left: + return "left"; + case TextStyle::Align::Right: + return "right"; + case TextStyle::Align::None: + default: + break; + } + + assert(false); + return ""; + } + + const char *weightAsString(TextStyle::Weight wight) + { + switch (wight) + { + case TextStyle::Weight::Bold: + return "bold"; + case TextStyle::Weight::None: + default: + break; + } + + assert(false); + return ""; + } } TextStyle::TextStyle() - : m_Weight(Weight::None) - , m_Color(defaultColor) - , m_Align(Align::None) - , m_Size(defaultFontSize) + : m_Weight(Weight::None) + , m_Color(defaultColor) + , m_Align(Align::None) + , m_Size(defaultFontSize) { } TextStyle::TextStyle(TextStyle &&style) - : m_Weight(style.m_Weight) - , m_Color(std::move(style.m_Color)) - , m_Align(style.m_Align) - , m_Size(style.m_Size) + : m_Weight(style.m_Weight) + , m_Color(std::move(style.m_Color)) + , m_Align(style.m_Align) + , m_Size(style.m_Size) { } TextStyle::TextStyle(int size, const std::string &color, Align align) - : m_Weight(Weight::None) - , m_Color(color) - , m_Align(align) - , m_Size(size) + : m_Weight(Weight::None) + , m_Color(color) + , m_Align(align) + , m_Size(size) { } @@ -97,54 +97,54 @@ TextStyle::~TextStyle() TextStyle &TextStyle::setColor(const std::string &color) { - m_Color = color; - return *this; + m_Color = color; + return *this; } TextStyle &TextStyle::setSize(int size) { - m_Size = size; - return *this; + m_Size = size; + return *this; } TextStyle &TextStyle::setAlign(Align align) { - m_Align = align; - return *this; + m_Align = align; + return *this; } TextStyle &TextStyle::setWeight(Weight weight) { - m_Weight = weight; - return *this; + m_Weight = weight; + return *this; } bool TextStyle::isEmpty() const { - return m_Weight == Weight::None && - m_Align == Align::None && - m_Color.empty() && - m_Size == 0; + return m_Weight == Weight::None && + m_Align == Align::None && + m_Color.empty() && + m_Size == 0; } const std::string &TextStyle::getColor() const { - return m_Color; + return m_Color; } int TextStyle::getSize() const { - return m_Size; + return m_Size; } TextStyle::Align TextStyle::getAlign() const { - return m_Align; + return m_Align; } TextStyle::Weight TextStyle::getWeight() const { - return m_Weight; + return m_Weight; } namespace Msg { @@ -152,84 +152,84 @@ namespace TextDecorator { std::string make(const std::string &text, const TextStyle &style) { - if (style.isEmpty()) - return text; - return make(text, style.getSize(), style.getColor(), style.getAlign(), style.getWeight()); + if (style.isEmpty()) + return text; + return make(text, style.getSize(), style.getColor(), style.getAlign(), style.getWeight()); } std::string make(const std::string &text, const std::string &color) { - std::string res = OPEN_TAG_STR("color", color) + text + CLOSE_TAG("color"); - return res; + std::string res = OPEN_TAG_STR("color", color) + text + CLOSE_TAG("color"); + return res; } std::string make(const std::string &text, - int size, - const std::string &color, - TextStyle::Align align, - TextStyle::Weight weight) + int size, + const std::string &color, + TextStyle::Align align, + TextStyle::Weight weight) { - std::ostringstream ss; - bool isAlign = align != TextStyle::Align::None; - bool isWeight = weight != TextStyle::Weight::None; + std::ostringstream ss; + bool isAlign = align != TextStyle::Align::None; + bool isWeight = weight != TextStyle::Weight::None; - ss << OPEN_TAG("font_size", size); - ss << OPEN_TAG("color", color); + ss << OPEN_TAG("font_size", size); + ss << OPEN_TAG("color", color); - if (isAlign) - ss << OPEN_TAG("align", alignAsString(align)); + if (isAlign) + ss << OPEN_TAG("align", alignAsString(align)); - if (isWeight) - ss << OPEN_TAG("font_weight", weightAsString(weight)); + if (isWeight) + ss << OPEN_TAG("font_weight", weightAsString(weight)); - ss << text; - if (isAlign) - ss << CLOSE_TAG("align"); - if (isWeight) - ss << CLOSE_TAG("font_weight"); + ss << text; + if (isAlign) + ss << CLOSE_TAG("align"); + if (isWeight) + ss << CLOSE_TAG("font_weight"); - ss << CLOSE_TAG("color"); - ss << CLOSE_TAG("font_size"); - return ss.str(); + ss << CLOSE_TAG("color"); + ss << CLOSE_TAG("font_size"); + return ss.str(); } std::string makePlainText(const std::string &text) { - std::regex tags("<[^<]*>"); - std::string plainText; - std::regex_replace(std::back_inserter(plainText), text.begin(), text.end(), tags, ""); - return plainText; + std::regex tags("<[^<]*>"); + std::string plainText; + std::regex_replace(std::back_inserter(plainText), text.begin(), text.end(), tags, ""); + return plainText; } std::string highlightKeyword(std::string str, const std::string &searchWord, bool *foundRes) { - if (foundRes) - *foundRes = false; + if (foundRes) + *foundRes = false; - if (str.empty() || searchWord.empty()) - return str; + if (str.empty() || searchWord.empty()) + return str; - char *found = strcasestr((char*)str.c_str(), (char*)searchWord.c_str()); - if (!found) - return str; + char *found = strcasestr((char*)str.c_str(), (char*)searchWord.c_str()); + if (!found) + return str; - if (foundRes) - *foundRes = true; + if (foundRes) + *foundRes = true; - std::string res; - res.reserve(str.length() + 32); // Reserve string length + highlight tags length + std::string res; + res.reserve(str.length() + 32); // Reserve string length + highlight tags length - int diff = found - str.c_str(); - std::string firstPart = std::string(str.begin(), str.begin() + diff); - std::string lastPart = std::string(str.begin() + diff + searchWord.length(), str.end()); + int diff = found - str.c_str(); + std::string firstPart = std::string(str.begin(), str.begin() + diff); + std::string lastPart = std::string(str.begin() + diff + searchWord.length(), str.end()); - res += firstPart; - res += ""; - res += std::string(found, searchWord.length()); - res += ""; - res += lastPart; + res += firstPart; + res += ""; + res += std::string(found, searchWord.length()); + res += ""; + res += lastPart; - return res; + return res; } } // TextDecorator diff --git a/src/Common/Utils/src/ThumbnailMaker.cpp b/src/Common/Utils/src/ThumbnailMaker.cpp index 5766e11..45e5ef0 100644 --- a/src/Common/Utils/src/ThumbnailMaker.cpp +++ b/src/Common/Utils/src/ThumbnailMaker.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -28,206 +28,206 @@ const int defaultCache = 512; #define COLOR_BLUE 61, 185, 204, 255 #define RAND (rand() % 220) #define COLOR_RAND RAND, RAND, RAND, 255 -#define MSG_THUMB_STYLE_LIST "list_ic_user_thumb_masking" +#define MSG_THUMB_STYLE_LIST "list_ic_user_thumb_masking" ThumbnailMaker::ThumbnailMaker(App &app) - : m_App(app) - , m_ContactsMap() - , m_OriginsMap() - , m_CurrentId(-1) + : m_App(app) + , m_ContactsMap() + , m_OriginsMap() + , m_CurrentId(-1) { - m_App.getContactManager().addListener(*this); - m_ContactsMap.reserve(defaultCache); - m_OriginsMap.reserve(defaultCache); + m_App.getContactManager().addListener(*this); + m_ContactsMap.reserve(defaultCache); + m_OriginsMap.reserve(defaultCache); - for (int i = 0; i <= maxStaticThumbId; i++) { - getThumbId((DefaultThumbs)i); - } + for (int i = 0; i <= maxStaticThumbId; i++) { + getThumbId((DefaultThumbs)i); + } } ThumbnailMaker::~ThumbnailMaker() { - m_App.getContactManager().removeListener(*this); + m_App.getContactManager().removeListener(*this); } ThumbId ThumbnailMaker::getThumbId(const MsgAddress &address) { - return getThumbId(address.getAddress()); + return getThumbId(address.getAddress()); } ThumbId ThumbnailMaker::getThumbId(const std::string &address) { - ContactAddressRef contact = m_App.getContactManager().getContactAddress(address); - return contact ? getThumbIdFromFile(contact->getThumbnailPath()) : getThumbId(SingleThumb); + ContactAddressRef contact = m_App.getContactManager().getContactAddress(address); + return contact ? getThumbIdFromFile(contact->getThumbnailPath()) : getThumbId(SingleThumb); } ThumbId ThumbnailMaker::getThumbIdFromFile(const std::string &path) { - if (path.empty()) { - return getThumbId(SingleThumb); - } else { - auto it = m_ContactsMap.find(path); - if (it != m_ContactsMap.end()) - return it->second; + if (path.empty()) { + return getThumbId(SingleThumb); + } else { + auto it = m_ContactsMap.find(path); + if (it != m_ContactsMap.end()) + return it->second; - Evas_Object *origin = makeOriginThumb(m_App.getWindow(), path); - m_OriginsMap[++m_CurrentId] = origin; - m_ContactsMap[path] = m_CurrentId; - return m_CurrentId; - } + Evas_Object *origin = makeOriginThumb(m_App.getWindow(), path); + m_OriginsMap[++m_CurrentId] = origin; + m_ContactsMap[path] = m_CurrentId; + return m_CurrentId; + } } ThumbId ThumbnailMaker::getThumbId(DefaultThumbs thumb) { - auto it = m_ContactsMap.find(defaultThumbsToStr(thumb)); - if (it != m_ContactsMap.end()) { - return it->second; - } else { - Evas_Object *origin = nullptr; - if (thumb != OwnerThumb) { - origin = makeDefaultOriginThumb(m_App.getWindow(), defaultThumbsToPath(thumb)); - } else { - ContactMyProfileRef ownerProfile = m_App.getContactManager().getOwnerProfile(); - origin = ownerProfile ? makeOriginThumb(m_App.getWindow(), ownerProfile->getThumbnailPath()) : - makeDefaultOriginThumb(m_App.getWindow(), defaultThumbsToPath(SingleThumb)); - } - m_OriginsMap[++m_CurrentId] = origin; - m_ContactsMap[defaultThumbsToStr(thumb)] = m_CurrentId; - return m_CurrentId; - } + auto it = m_ContactsMap.find(defaultThumbsToStr(thumb)); + if (it != m_ContactsMap.end()) { + return it->second; + } else { + Evas_Object *origin = nullptr; + if (thumb != OwnerThumb) { + origin = makeDefaultOriginThumb(m_App.getWindow(), defaultThumbsToPath(thumb)); + } else { + ContactMyProfileRef ownerProfile = m_App.getContactManager().getOwnerProfile(); + origin = ownerProfile ? makeOriginThumb(m_App.getWindow(), ownerProfile->getThumbnailPath()) : + makeDefaultOriginThumb(m_App.getWindow(), defaultThumbsToPath(SingleThumb)); + } + m_OriginsMap[++m_CurrentId] = origin; + m_ContactsMap[defaultThumbsToStr(thumb)] = m_CurrentId; + return m_CurrentId; + } } Evas_Object *ThumbnailMaker::getThumb(Evas_Object *parent, ThumbId id, int thumbSize) { - auto it = m_OriginsMap.find(id); - if (it == m_OriginsMap.end()) - { - MSG_LOG_ERROR("Invalid thumbnail id"); - return nullptr; - } + auto it = m_OriginsMap.find(id); + if (it == m_OriginsMap.end()) + { + MSG_LOG_ERROR("Invalid thumbnail id"); + return nullptr; + } - Evas_Object *origin = it->second; - Evas_Object *ic = evas_object_image_filled_add(evas_object_evas_get(parent)); - evas_object_image_source_set(ic, origin); - int scaledThumbSize = ELM_SCALE_SIZE(thumbSize); - evas_object_size_hint_min_set(ic, scaledThumbSize, scaledThumbSize); - evas_object_size_hint_max_set(ic, scaledThumbSize, scaledThumbSize); - View::expand(ic); - evas_object_show(ic); - return ic; + Evas_Object *origin = it->second; + Evas_Object *ic = evas_object_image_filled_add(evas_object_evas_get(parent)); + evas_object_image_source_set(ic, origin); + int scaledThumbSize = ELM_SCALE_SIZE(thumbSize); + evas_object_size_hint_min_set(ic, scaledThumbSize, scaledThumbSize); + evas_object_size_hint_max_set(ic, scaledThumbSize, scaledThumbSize); + View::expand(ic); + evas_object_show(ic); + return ic; } Evas_Object *ThumbnailMaker::getThumb(Evas_Object *parent, const std::string &path, int thumbSize) { - int scaledThumbSize = ELM_SCALE_SIZE(thumbSize); + int scaledThumbSize = ELM_SCALE_SIZE(thumbSize); - Evas_Object *ic = makeMask(parent, scaledThumbSize); - Evas_Object *img = makeImage(ic, path, scaledThumbSize); - elm_object_part_content_set(ic, "content", img); - return ic; + Evas_Object *ic = makeMask(parent, scaledThumbSize); + Evas_Object *img = makeImage(ic, path, scaledThumbSize); + elm_object_part_content_set(ic, "content", img); + return ic; } Evas_Object *ThumbnailMaker::makeOriginThumb(Evas_Object *parent, const std::string &path) { - Evas_Object *ic = makeMask(parent, DEFAULT_THUMB_SIZE); - Evas_Object *img = makeImage(ic, path, DEFAULT_THUMB_SIZE); - elm_object_part_content_set(ic, "content", img); - evas_object_move(ic, -DEFAULT_THUMB_SIZE, -DEFAULT_THUMB_SIZE); - return ic; + Evas_Object *ic = makeMask(parent, DEFAULT_THUMB_SIZE); + Evas_Object *img = makeImage(ic, path, DEFAULT_THUMB_SIZE); + elm_object_part_content_set(ic, "content", img); + evas_object_move(ic, -DEFAULT_THUMB_SIZE, -DEFAULT_THUMB_SIZE); + return ic; } Evas_Object *ThumbnailMaker::makeDefaultOriginThumb(Evas_Object *parent, const std::string &path) { - Evas_Object *img = makeImage(parent, path, DEFAULT_THUMB_SIZE); - evas_object_color_set(img, COLOR_BLUE); - evas_object_resize(img, DEFAULT_THUMB_SIZE, DEFAULT_THUMB_SIZE); - evas_object_move(img, -DEFAULT_THUMB_SIZE, -DEFAULT_THUMB_SIZE); - evas_object_show(img); - return img; + Evas_Object *img = makeImage(parent, path, DEFAULT_THUMB_SIZE); + evas_object_color_set(img, COLOR_BLUE); + evas_object_resize(img, DEFAULT_THUMB_SIZE, DEFAULT_THUMB_SIZE); + evas_object_move(img, -DEFAULT_THUMB_SIZE, -DEFAULT_THUMB_SIZE); + evas_object_show(img); + return img; } Evas_Object *ThumbnailMaker::makeImage(Evas_Object *parent, const std::string &path, int size) { - Evas_Object *img = elm_image_add(parent); - elm_image_file_set(img, path.c_str(), nullptr); - evas_object_size_hint_min_set(img, size, size); - evas_object_size_hint_max_set(img, size, size); - elm_image_aspect_fixed_set(img, true); - elm_image_fill_outside_set(img, true); - return img; + Evas_Object *img = elm_image_add(parent); + elm_image_file_set(img, path.c_str(), nullptr); + evas_object_size_hint_min_set(img, size, size); + evas_object_size_hint_max_set(img, size, size); + elm_image_aspect_fixed_set(img, true); + elm_image_fill_outside_set(img, true); + return img; } Evas_Object *ThumbnailMaker::makeMask(Evas_Object *parent, int size) { - Evas_Object *ic = elm_layout_add(parent); - static std::string edjePath = PathUtils::getResourcePath(THUMBNAIL_EDJ_PATH); - elm_layout_file_set(ic, edjePath.c_str(), MSG_THUMB_STYLE_LIST); - evas_object_resize(ic, size, size); - evas_object_show(ic); - return ic; + Evas_Object *ic = elm_layout_add(parent); + static std::string edjePath = PathUtils::getResourcePath(THUMBNAIL_EDJ_PATH); + elm_layout_file_set(ic, edjePath.c_str(), MSG_THUMB_STYLE_LIST); + evas_object_resize(ic, size, size); + evas_object_show(ic); + return ic; } void ThumbnailMaker::invalidate() { - MSG_LOG(""); + MSG_LOG(""); - // m_OriginsMap: - auto originsIt = m_OriginsMap.begin(); + // m_OriginsMap: + auto originsIt = m_OriginsMap.begin(); - for (; originsIt != m_OriginsMap.end();) { - if (originsIt->first > maxStaticThumbId) { - MSG_LOG(originsIt->first); - evas_object_del(originsIt->second); - originsIt = m_OriginsMap.erase(originsIt); - } else { - ++originsIt; - } - } + for (; originsIt != m_OriginsMap.end();) { + if (originsIt->first > maxStaticThumbId) { + MSG_LOG(originsIt->first); + evas_object_del(originsIt->second); + originsIt = m_OriginsMap.erase(originsIt); + } else { + ++originsIt; + } + } - // m_ContactsMap: - auto contactsIt = m_ContactsMap.begin(); - for (; contactsIt != m_ContactsMap.end();) { - if (contactsIt->second > maxStaticThumbId) - contactsIt = m_ContactsMap.erase(contactsIt); - else - ++contactsIt; - } + // m_ContactsMap: + auto contactsIt = m_ContactsMap.begin(); + for (; contactsIt != m_ContactsMap.end();) { + if (contactsIt->second > maxStaticThumbId) + contactsIt = m_ContactsMap.erase(contactsIt); + else + ++contactsIt; + } } const std::string &ThumbnailMaker::defaultThumbsToStr(DefaultThumbs thumb) { - static const std::string sThumb = "SingleThumb"; - static const std::string gThumb = "GroupThumb"; - static const std::string oThumb = "OwnerThumb"; - static const std::string emptyThumb = ""; - switch (thumb) - { - case SingleThumb: - return sThumb; - case GroupThumb: - return gThumb; - case OwnerThumb: - return oThumb; - default : - return emptyThumb; - } + static const std::string sThumb = "SingleThumb"; + static const std::string gThumb = "GroupThumb"; + static const std::string oThumb = "OwnerThumb"; + static const std::string emptyThumb = ""; + switch (thumb) + { + case SingleThumb: + return sThumb; + case GroupThumb: + return gThumb; + case OwnerThumb: + return oThumb; + default : + return emptyThumb; + } } std::string ThumbnailMaker::defaultThumbsToPath(DefaultThumbs thumb) { - switch (thumb) - { - case SingleThumb: - return PathUtils::getResourcePath(THUMB_CONTACT_IMG_PATH); - case GroupThumb: - return PathUtils::getResourcePath(THUMB_GROUP_IMG_PATH); - default : - return ""; - } + switch (thumb) + { + case SingleThumb: + return PathUtils::getResourcePath(THUMB_CONTACT_IMG_PATH); + case GroupThumb: + return PathUtils::getResourcePath(THUMB_GROUP_IMG_PATH); + default : + return ""; + } } void ThumbnailMaker::onContactChanged() { - invalidate(); + invalidate(); } diff --git a/src/Common/Utils/src/TimeUtils.cpp b/src/Common/Utils/src/TimeUtils.cpp index ebdef57..99ba66a 100644 --- a/src/Common/Utils/src/TimeUtils.cpp +++ b/src/Common/Utils/src/TimeUtils.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -54,231 +54,231 @@ i18n_udate_format_h getDateFormat(const std::string &locale, const i18n_uchar *p std::string makeThreadTimeString(time_t msgTime) { - tm msgTimeTm = {}; - tm curTimeTm = {}; - const std::string &locale = getDefaultLocale(); + tm msgTimeTm = {}; + tm curTimeTm = {}; + const std::string &locale = getDefaultLocale(); - time_t curTime = time(nullptr); + time_t curTime = time(nullptr); - localtime_r(&msgTime, &msgTimeTm); - localtime_r(&curTime, &curTimeTm); + localtime_r(&msgTime, &msgTimeTm); + localtime_r(&curTime, &curTimeTm); - int msgDay = (msgTimeTm.tm_year - 1900) * 365 + msgTimeTm.tm_yday + (msgTimeTm.tm_year - 1900 - 1) / 4; - int curDay = (curTimeTm.tm_year - 1900) * 365 + curTimeTm.tm_yday + (curTimeTm.tm_year - 1900 - 1) / 4; + int msgDay = (msgTimeTm.tm_year - 1900) * 365 + msgTimeTm.tm_yday + (msgTimeTm.tm_year - 1900 - 1) / 4; + int curDay = (curTimeTm.tm_year - 1900) * 365 + curTimeTm.tm_yday + (curTimeTm.tm_year - 1900 - 1) / 4; - bool isToday = (curDay - msgDay == 0); + bool isToday = (curDay - msgDay == 0); - if (isToday) - { - const std::string &timeFormat = getTimeFormat() == TimeFormat24H ? time24H : time12H; - return getFormattedDate(locale, getDateBestPattern(locale, timeFormat), msgTime); - } else { - bool notThisYear = (msgTimeTm.tm_year - curTimeTm.tm_year != 0); - const std::string &date = notThisYear ? dateListYear : dateListDefault; - return getFormattedDate(locale, getDateBestPattern(locale, date), msgTime); - } + if (isToday) + { + const std::string &timeFormat = getTimeFormat() == TimeFormat24H ? time24H : time12H; + return getFormattedDate(locale, getDateBestPattern(locale, timeFormat), msgTime); + } else { + bool notThisYear = (msgTimeTm.tm_year - curTimeTm.tm_year != 0); + const std::string &date = notThisYear ? dateListYear : dateListDefault; + return getFormattedDate(locale, getDateBestPattern(locale, date), msgTime); + } } std::string makeBubbleTimeString(time_t msgTime) { - const std::string &locale = getDefaultLocale(); - const std::string &timeFormat = getTimeFormat() == TimeFormat24H ? time24H : time12H; - return getFormattedDate(locale, getDateBestPattern(locale, timeFormat), msgTime); + const std::string &locale = getDefaultLocale(); + const std::string &timeFormat = getTimeFormat() == TimeFormat24H ? time24H : time12H; + return getFormattedDate(locale, getDateBestPattern(locale, timeFormat), msgTime); } std::string makeBubbleDateLineString(time_t msgTime) { - const std::string &locale = getDefaultLocale(); - return getFormattedDate(locale, getDateBestPattern(locale, dateYear), msgTime); + const std::string &locale = getDefaultLocale(); + return getFormattedDate(locale, getDateBestPattern(locale, dateYear), msgTime); } std::string makeDateString(time_t msgTime) { - const std::string &locale = getDefaultLocale(); - return getFormattedDate(locale, getDateBestPattern(locale, dateTimeSceleton), msgTime); + const std::string &locale = getDefaultLocale(); + return getFormattedDate(locale, getDateBestPattern(locale, dateTimeSceleton), msgTime); } std::string makeDateTimeString(time_t msgTime) //the same for Sim Message List { - const std::string &locale = getDefaultLocale(); - std::string res = getFormattedDate(locale, getDateBestPattern(locale, dateTimeSceleton), msgTime); + const std::string &locale = getDefaultLocale(); + std::string res = getFormattedDate(locale, getDateBestPattern(locale, dateTimeSceleton), msgTime); - res.append(" "); - const std::string &timeFormat = getTimeFormat() == TimeFormat24H ? time24H : time12H; - res += getFormattedDate(locale, getDateBestPattern(locale, timeFormat), msgTime); + res.append(" "); + const std::string &timeFormat = getTimeFormat() == TimeFormat24H ? time24H : time12H; + res += getFormattedDate(locale, getDateBestPattern(locale, timeFormat), msgTime); - return res; + return res; } std::string makeSmsReportTimeString(time_t msgTime) { - const std::string &locale = getDefaultLocale(); - const std::string &timeFormat = getTimeFormat() == TimeFormat24H ? delivReportSms24H : delivReportSms12H; - return getFormattedDate(locale, getDateBestPattern(locale, timeFormat), msgTime); + const std::string &locale = getDefaultLocale(); + const std::string &timeFormat = getTimeFormat() == TimeFormat24H ? delivReportSms24H : delivReportSms12H; + return getFormattedDate(locale, getDateBestPattern(locale, timeFormat), msgTime); } std::string makeMmsReportTimeString(time_t msgTime) { - const std::string &locale = getDefaultLocale(); - const std::string &timeFormat = getTimeFormat() == TimeFormat24H ? delivReportMms24H : delivReportMms12H; - return getFormattedDate(locale, getDateBestPattern(locale, timeFormat), msgTime); + const std::string &locale = getDefaultLocale(); + const std::string &timeFormat = getTimeFormat() == TimeFormat24H ? delivReportMms24H : delivReportMms12H; + return getFormattedDate(locale, getDateBestPattern(locale, timeFormat), msgTime); } std::string makeCalEventString(time_t time) { - const std::string &locale = getDefaultLocale(); - return getFormattedDate(locale, getDateBestPattern(locale, dateYear), time); + const std::string &locale = getDefaultLocale(); + return getFormattedDate(locale, getDateBestPattern(locale, dateYear), time); } std::string makeCalEventString(int year, int month, int mday, int hour, int min, const char *timezone) { - struct tm time = {}; - time.tm_year = year - 1900; - time.tm_mon = month - 1; - time.tm_mday = mday; - time.tm_hour = hour; - time.tm_min = min; - const std::string &locale = getDefaultLocale(); - return getFormattedDate(locale, getDateBestPattern(locale, dateYear), mktime(&time), timezone); + struct tm time = {}; + time.tm_year = year - 1900; + time.tm_mon = month - 1; + time.tm_mday = mday; + time.tm_hour = hour; + time.tm_min = min; + const std::string &locale = getDefaultLocale(); + return getFormattedDate(locale, getDateBestPattern(locale, dateYear), mktime(&time), timezone); } int getTimeFormat() { - bool timeFormat = false; - if (system_settings_get_value_bool(SYSTEM_SETTINGS_KEY_LOCALE_TIMEFORMAT_24HOUR, &timeFormat) < 0) - return TimeFormatUnknown; - return timeFormat ? TimeFormat24H : TimeFormat12H; + bool timeFormat = false; + if (system_settings_get_value_bool(SYSTEM_SETTINGS_KEY_LOCALE_TIMEFORMAT_24HOUR, &timeFormat) < 0) + return TimeFormatUnknown; + return timeFormat ? TimeFormat24H : TimeFormat12H; } const std::string &getDefaultLocale() { - static std::string res; - - char *str = nullptr; - system_settings_get_value_string(SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, &str); - - if (str) - { - i18n_ulocale_set_default(str); - res = str; - size_t i = res.find("."); - if (i != std::string::npos) - res = res.substr(i); - - free(str); - } else { - res.clear(); - } - return res; + static std::string res; + + char *str = nullptr; + system_settings_get_value_string(SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, &str); + + if (str) + { + i18n_ulocale_set_default(str); + res = str; + size_t i = res.find("."); + if (i != std::string::npos) + res = res.substr(i); + + free(str); + } else { + res.clear(); + } + return res; } std::string getTimezone() { - char buf[defBufLen] = {}; - ssize_t len = readlink("/opt/etc/localtime", buf, sizeof(buf) - 1); - int filePathLength = 20; - - if (len != -1) - { - buf[len] = '\0'; - } 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) - { - res = time_zone; - free(time_zone); - } - - return res; - } - - return buf + filePathLength; + char buf[defBufLen] = {}; + ssize_t len = readlink("/opt/etc/localtime", buf, sizeof(buf) - 1); + int filePathLength = 20; + + if (len != -1) + { + buf[len] = '\0'; + } 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) + { + res = time_zone; + free(time_zone); + } + + return res; + } + + return buf + filePathLength; } std::string getDateBestPattern(const std::string &locale, const std::string &skeleton) { - i18n_udatepg_h generator = nullptr; - i18n_uchar bestPattern[maxUcharLen] = {}; - char bestPatternString[maxCharLen] = {}; - int32_t bestPatternCapacity = maxUcharLen; - int bestPatternLen = 0; - i18n_uchar customSkeleton[maxUcharLen] = {}; - int skeletonLength = 0; - - skeletonLength = skeleton.length(); - /* convert char to uchar */ - if (skeletonLength <= maxUcharLen) - i18n_ustring_copy_ua_n(customSkeleton, skeleton.c_str(), skeletonLength); - else - i18n_ustring_copy_ua_n(customSkeleton, skeleton.c_str(), maxUcharLen); - - i18n_udatepg_create(locale.c_str(), &generator); - - /* get bestpattern from customskeletom of uchar */ - skeletonLength = i18n_ustring_get_length(customSkeleton); - i18n_udatepg_get_best_pattern(generator, customSkeleton, skeletonLength, bestPattern, bestPatternCapacity, &bestPatternLen); - /* convert uchar to char to know bestPattern */ - i18n_ustring_copy_au(bestPatternString, bestPattern); - - i18n_udatepg_destroy(generator); - - return bestPatternString; + i18n_udatepg_h generator = nullptr; + i18n_uchar bestPattern[maxUcharLen] = {}; + char bestPatternString[maxCharLen] = {}; + int32_t bestPatternCapacity = maxUcharLen; + int bestPatternLen = 0; + i18n_uchar customSkeleton[maxUcharLen] = {}; + int skeletonLength = 0; + + skeletonLength = skeleton.length(); + /* convert char to uchar */ + if (skeletonLength <= maxUcharLen) + i18n_ustring_copy_ua_n(customSkeleton, skeleton.c_str(), skeletonLength); + else + i18n_ustring_copy_ua_n(customSkeleton, skeleton.c_str(), maxUcharLen); + + i18n_udatepg_create(locale.c_str(), &generator); + + /* get bestpattern from customskeletom of uchar */ + skeletonLength = i18n_ustring_get_length(customSkeleton); + i18n_udatepg_get_best_pattern(generator, customSkeleton, skeletonLength, bestPattern, bestPatternCapacity, &bestPatternLen); + /* convert uchar to char to know bestPattern */ + i18n_ustring_copy_au(bestPatternString, bestPattern); + + i18n_udatepg_destroy(generator); + + return bestPatternString; } std::string getFormattedDate(const std::string &locale, const std::string &bestPattern, time_t time, const char *timezone) { - int status = I18N_ERROR_NONE; - i18n_udate date; - i18n_udate_format_h dateFormat = nullptr; - i18n_uchar utimezoneId[defBufLen] = {}; - i18n_uchar uBestPattern[maxUcharLen] = {}; - i18n_uchar formatted[maxUcharLen] = {}; - char formattedString[maxCharLen] = {}; - int32_t formattedCapacity = maxUcharLen; - int formattedLength = 0; - int patternLength = bestPattern.length(); - - /* convert char to uchar */ - if (patternLength <= maxUcharLen) - i18n_ustring_copy_ua_n(uBestPattern, bestPattern.c_str(), patternLength); - else - i18n_ustring_copy_ua_n(uBestPattern, bestPattern.c_str(), maxUcharLen); - - /* get current timezone and set as default timezone */ - i18n_ustring_copy_ua(utimezoneId, timezone ? timezone : getTimezone().c_str()); - - status = i18n_ucalendar_set_default_timezone(utimezoneId); - if (status != I18N_ERROR_NONE) - MSG_LOG_ERROR("default timezone set error"); - - /* convert time_t to UDate, if it is */ - if (time) - date = (i18n_udate)time * 1000; - else - i18n_ucalendar_get_now(&date); - - dateFormat = getDateFormat(locale, uBestPattern, &status); - if (status == I18N_ERROR_NONE) - { - /* get formatted string */ - i18n_udate_format_date(dateFormat, date, formatted, formattedCapacity, nullptr, &formattedLength); - /* convert uchar to char */ - i18n_ustring_copy_au(formattedString, formatted); - } - - return formattedString; + int status = I18N_ERROR_NONE; + i18n_udate date; + i18n_udate_format_h dateFormat = nullptr; + i18n_uchar utimezoneId[defBufLen] = {}; + i18n_uchar uBestPattern[maxUcharLen] = {}; + i18n_uchar formatted[maxUcharLen] = {}; + char formattedString[maxCharLen] = {}; + int32_t formattedCapacity = maxUcharLen; + int formattedLength = 0; + int patternLength = bestPattern.length(); + + /* convert char to uchar */ + if (patternLength <= maxUcharLen) + i18n_ustring_copy_ua_n(uBestPattern, bestPattern.c_str(), patternLength); + else + i18n_ustring_copy_ua_n(uBestPattern, bestPattern.c_str(), maxUcharLen); + + /* get current timezone and set as default timezone */ + i18n_ustring_copy_ua(utimezoneId, timezone ? timezone : getTimezone().c_str()); + + status = i18n_ucalendar_set_default_timezone(utimezoneId); + if (status != I18N_ERROR_NONE) + MSG_LOG_ERROR("default timezone set error"); + + /* convert time_t to UDate, if it is */ + if (time) + date = (i18n_udate)time * 1000; + else + i18n_ucalendar_get_now(&date); + + dateFormat = getDateFormat(locale, uBestPattern, &status); + if (status == I18N_ERROR_NONE) + { + /* get formatted string */ + i18n_udate_format_date(dateFormat, date, formatted, formattedCapacity, nullptr, &formattedLength); + /* convert uchar to char */ + i18n_ustring_copy_au(formattedString, formatted); + } + + return formattedString; } i18n_udate_format_h getDateFormat(const std::string &locale, const i18n_uchar *pattern, int *status) { - i18n_udate_format_h dateFormat = nullptr; - *status = i18n_udate_create(I18N_UDATE_PATTERN, I18N_UDATE_PATTERN, locale.c_str(), nullptr, -1, pattern, -1, &dateFormat); - return dateFormat; + i18n_udate_format_h dateFormat = nullptr; + *status = i18n_udate_create(I18N_UDATE_PATTERN, I18N_UDATE_PATTERN, locale.c_str(), nullptr, -1, pattern, -1, &dateFormat); + return dateFormat; } } // TimeUtils diff --git a/src/Common/Utils/src/VCalendarParser.cpp b/src/Common/Utils/src/VCalendarParser.cpp index b40cbaf..df6d656 100644 --- a/src/Common/Utils/src/VCalendarParser.cpp +++ b/src/Common/Utils/src/VCalendarParser.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -25,85 +25,85 @@ using namespace Msg; CalendarEvent::CalendarEvent(calendar_record_h record) { - char *summary = nullptr; - calendar_record_get_str_p(record, _calendar_event.summary, &summary); - if (summary) - m_Summary = summary; - - calendar_time_s start = {}; - if (calendar_record_get_caltime(record, _calendar_event.start_time, &start) == 0) { - if (start.type == CALENDAR_TIME_UTIME) { // Unix time - m_StartDate = TimeUtils::makeCalEventString(start.time.utime); - } else { // Local time - m_StartDate = TimeUtils::makeCalEventString - ( - start.time.date.year, - start.time.date.month, - start.time.date.mday, - start.time.date.hour, - start.time.date.minute, - nullptr); - } - } + char *summary = nullptr; + calendar_record_get_str_p(record, _calendar_event.summary, &summary); + if (summary) + m_Summary = summary; + + calendar_time_s start = {}; + if (calendar_record_get_caltime(record, _calendar_event.start_time, &start) == 0) { + if (start.type == CALENDAR_TIME_UTIME) { // Unix time + m_StartDate = TimeUtils::makeCalEventString(start.time.utime); + } else { // Local time + m_StartDate = TimeUtils::makeCalEventString + ( + start.time.date.year, + start.time.date.month, + start.time.date.mday, + start.time.date.hour, + start.time.date.minute, + nullptr); + } + } } const std::string &CalendarEvent::getSummary() const { - return m_Summary; + return m_Summary; } const std::string &CalendarEvent::getStartDate() const { - return m_StartDate; + return m_StartDate; } VCalendarParser::VCalendarParser() { - calendar_connect(); + calendar_connect(); } VCalendarParser::~VCalendarParser() { - calendar_disconnect(); + calendar_disconnect(); } VCalendarParser &VCalendarParser::getInst() { - static VCalendarParser inst; - return inst; + static VCalendarParser inst; + return inst; } std::list VCalendarParser::parse(const std::string &filePath) { - if (filePath.empty()) - return {}; - - std::list list; - std::string text = FileUtils::readTextFile(filePath); - - calendar_list_h records = nullptr; - int parseRes = calendar_vcalendar_parse_to_calendar(text.c_str(), &records); - MSG_LOG("Parse results: ", parseRes); - - int count = 0; - calendar_list_get_count(records, &count); - calendar_list_first(records); - - for (int i = 0; i < count; ++i) { - calendar_record_h record = nullptr; - calendar_list_get_current_record_p(records, &record); - if (record) { - char *viewUri = nullptr; - calendar_record_get_uri_p(record, &viewUri); - if (viewUri && !strcmp(viewUri, _calendar_event._uri)) - list.emplace_back(record); - } - } - - if (records) - calendar_list_destroy(records, true); - - return list; + if (filePath.empty()) + return {}; + + std::list list; + std::string text = FileUtils::readTextFile(filePath); + + calendar_list_h records = nullptr; + int parseRes = calendar_vcalendar_parse_to_calendar(text.c_str(), &records); + MSG_LOG("Parse results: ", parseRes); + + int count = 0; + calendar_list_get_count(records, &count); + calendar_list_first(records); + + for (int i = 0; i < count; ++i) { + calendar_record_h record = nullptr; + calendar_list_get_current_record_p(records, &record); + if (record) { + char *viewUri = nullptr; + calendar_record_get_uri_p(record, &viewUri); + if (viewUri && !strcmp(viewUri, _calendar_event._uri)) + list.emplace_back(record); + } + } + + if (records) + calendar_list_destroy(records, true); + + return list; } diff --git a/src/Common/Utils/src/WorkingDir.cpp b/src/Common/Utils/src/WorkingDir.cpp index 3fdad53..0b151af 100644 --- a/src/Common/Utils/src/WorkingDir.cpp +++ b/src/Common/Utils/src/WorkingDir.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -30,122 +30,122 @@ const std::string textFileName = "mms.txt"; WorkingDir::WorkingDir() { - MSG_LOG(""); - createWorkingDir(); + MSG_LOG(""); + createWorkingDir(); } WorkingDir::~WorkingDir() { - MSG_LOG(""); - removeWorkingDir(); + MSG_LOG(""); + removeWorkingDir(); } void WorkingDir::createWorkingDir() { - // Create common dir. if not exists: - std::string commonDir = PathUtils::getDataPath(commonWorkingDirName); - bool isCommonExists = FileUtils::isExists(commonDir); - if (!isCommonExists) { - isCommonExists = FileUtils::makeDir(commonDir); - MSG_ASSERT(isCommonExists, "Can't create common working dir: ", commonDir); - } - - // Create current dir: - if (isCommonExists) { - std::string uniqueDir = getUniqueDirName(commonDir + "/" + currentWorkingDirPrefix); - FileUtils::makeDir(uniqueDir); - bool isExists = FileUtils::isExists(uniqueDir); - MSG_ASSERT(isExists, "Can't create current working dir: ", uniqueDir); - if (isExists) - m_Path = uniqueDir; - } + // Create common dir. if not exists: + std::string commonDir = PathUtils::getDataPath(commonWorkingDirName); + bool isCommonExists = FileUtils::isExists(commonDir); + if (!isCommonExists) { + isCommonExists = FileUtils::makeDir(commonDir); + MSG_ASSERT(isCommonExists, "Can't create common working dir: ", commonDir); + } + + // Create current dir: + if (isCommonExists) { + std::string uniqueDir = getUniqueDirName(commonDir + "/" + currentWorkingDirPrefix); + FileUtils::makeDir(uniqueDir); + bool isExists = FileUtils::isExists(uniqueDir); + MSG_ASSERT(isExists, "Can't create current working dir: ", uniqueDir); + if (isExists) + m_Path = uniqueDir; + } } void WorkingDir::removeWorkingDir() { - if (!m_Path.empty()) { - bool res = FileUtils::remove(m_Path, true); - MSG_LOG("Working dir remove with result = ", res); - } + if (!m_Path.empty()) { + bool res = FileUtils::remove(m_Path, true); + MSG_LOG("Working dir remove with result = ", res); + } } bool WorkingDir::isValid() const { - return !m_Path.empty() && FileUtils::isExists(m_Path); + return !m_Path.empty() && FileUtils::isExists(m_Path); } const std::string &WorkingDir::getPath() const { - return m_Path; + return m_Path; } std::string WorkingDir::genUniqueFilePath(const std::string &path) const { - std::lock_guard _lock(m_Mutex); - return FileUtils::genUniqueFilePath(m_Path, path); + std::lock_guard _lock(m_Mutex); + return FileUtils::genUniqueFilePath(m_Path, path); } std::string WorkingDir::addFile(const std::string &path) { - std::lock_guard _lock(m_Mutex); - std::string newPath; - - if (FileUtils::isExists(path)) { - if (path.find(m_Path) != std::string::npos) { - newPath = path; - MSG_LOG("File is already exists: ", newPath); - } else { - newPath = genUniqueFilePath(path); - if (FileUtils::copy(path, newPath)) { - MSG_LOG("File added: ", newPath); - } else { - MSG_LOG_ERROR("Can't copy to working dir: ", path); - newPath.clear(); - } - } - } - - return newPath; + std::lock_guard _lock(m_Mutex); + std::string newPath; + + if (FileUtils::isExists(path)) { + if (path.find(m_Path) != std::string::npos) { + newPath = path; + MSG_LOG("File is already exists: ", newPath); + } else { + newPath = genUniqueFilePath(path); + if (FileUtils::copy(path, newPath)) { + MSG_LOG("File added: ", newPath); + } else { + MSG_LOG_ERROR("Can't copy to working dir: ", path); + newPath.clear(); + } + } + } + + return newPath; } std::string WorkingDir::addTextFile(const std::string &text, const std::string &fileName) { - std::lock_guard _lock(m_Mutex); - std::string result; - result = fileName.empty() ? textFileName : fileName; - - std::string path = genUniqueFilePath(result); - std::ofstream file(path, std::ofstream::trunc | std::ofstream::binary | std::ofstream::out); - if (file.is_open()) { - file << text; - MSG_LOG("Text file added: ", path); - } else { - path.clear(); - } - - return path; + std::lock_guard _lock(m_Mutex); + std::string result; + result = fileName.empty() ? textFileName : fileName; + + std::string path = genUniqueFilePath(result); + std::ofstream file(path, std::ofstream::trunc | std::ofstream::binary | std::ofstream::out); + if (file.is_open()) { + file << text; + MSG_LOG("Text file added: ", path); + } else { + path.clear(); + } + + return path; } void WorkingDir::removeFile(const std::string &path) { - std::lock_guard _lock(m_Mutex); - if (!path.empty()) - FileUtils::remove(path); + std::lock_guard _lock(m_Mutex); + if (!path.empty()) + FileUtils::remove(path); } void WorkingDir::clear() { - std::lock_guard _lock(m_Mutex); - FileUtils::remove(m_Path, false); + std::lock_guard _lock(m_Mutex); + FileUtils::remove(m_Path, false); } std::string WorkingDir::getUniqueDirName(const std::string &path) { - std::string res; - unsigned i = 0; - do { - res = path + "-" + std::to_string(i); - ++i; - } while (FileUtils::isExists(res)); - return res; + std::string res; + unsigned i = 0; + do { + res = path + "-" + std::to_string(i); + ++i; + } while (FileUtils::isExists(res)); + return res; } diff --git a/src/Common/View/inc/Atspi.h b/src/Common/View/inc/Atspi.h index 244c4dd..a4bf464 100644 --- a/src/Common/View/inc/Atspi.h +++ b/src/Common/View/inc/Atspi.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -24,123 +24,123 @@ namespace Msg { - /** - * @brief Wrapper for Elm_Interface_Atspi_Accessible interface (Screen reader) - */ - class Atspi { - public: - Atspi(); - Atspi(Elm_Interface_Atspi_Accessible *obj); - void wrap(Elm_Interface_Atspi_Accessible *obj); - Elm_Interface_Atspi_Accessible *getEo() const; - operator Elm_Interface_Atspi_Accessible *() const; - - void setDescription(const TText &text); - void setName(const TText &text); - void setRole(Elm_Atspi_Role role); - void setReadingInfo(Elm_Accessible_Reading_Info_Type type); - void appendRel(Elm_Atspi_Relation_Type type, const Elm_Interface_Atspi_Accessible *obj); - void removeRel(Elm_Atspi_Relation_Type type, const Elm_Interface_Atspi_Accessible *obj); - void canHighlight(bool canHighlight); - void setActionCb(const Elm_Access_Action_Type type, const Elm_Access_Action_Cb cb, const void *data); - - void makeStartPosition(Elm_Interface_Atspi_Accessible *obj); - void appendFlowRel(Elm_Interface_Atspi_Accessible *obj); - void removeFlowRel(Elm_Interface_Atspi_Accessible *obj); - - // TODO: impl. other methods if needed - - private: - Elm_Interface_Atspi_Accessible *m_pEo; - }; - - inline Atspi::Atspi() - : m_pEo(nullptr) - { - } - - inline Atspi::Atspi(Elm_Interface_Atspi_Accessible *obj) - : m_pEo(obj) - { - } - - inline void Atspi::wrap(Elm_Interface_Atspi_Accessible *obj) - { - m_pEo = obj; - } - - inline Elm_Interface_Atspi_Accessible *Atspi::getEo() const - { - return m_pEo; - } - - inline Atspi::operator Elm_Interface_Atspi_Accessible *() const - { - return getEo(); - } - - inline void Atspi::setDescription(const TText &text) - { - if (text.getDomain()) - elm_atspi_accessible_translation_domain_set(m_pEo, text.getDomain()); - elm_atspi_accessible_description_set(m_pEo, text.translate().c_str()); - } - - inline void Atspi::setName(const TText &text) - { - if (text.getDomain()) - elm_atspi_accessible_translation_domain_set(m_pEo, text.getDomain()); - elm_atspi_accessible_name_set(m_pEo, text.translate().c_str()); - } - - inline void Atspi::setRole(Elm_Atspi_Role role) - { - elm_atspi_accessible_role_set(m_pEo, role); - } - - inline void Atspi::setReadingInfo(Elm_Accessible_Reading_Info_Type type) - { - elm_atspi_accessible_reading_info_type_set(m_pEo, type); - } - - inline void Atspi::appendRel(Elm_Atspi_Relation_Type type, const Elm_Interface_Atspi_Accessible *obj) - { - elm_atspi_accessible_relationship_append(m_pEo, type, obj); - } - - inline void Atspi::removeRel(Elm_Atspi_Relation_Type type, const Elm_Interface_Atspi_Accessible *obj) - { - elm_atspi_accessible_relationship_remove(m_pEo, type, obj); - } - - inline void Atspi::canHighlight(bool canHighlight) - { - elm_atspi_accessible_can_highlight_set(m_pEo, canHighlight); - } - - inline void Atspi::setActionCb(const Elm_Access_Action_Type type, const Elm_Access_Action_Cb cb, const void *data) - { - elm_access_action_cb_set(m_pEo, type, cb, data); - } - - inline void Atspi::makeStartPosition(Elm_Interface_Atspi_Accessible *obj) - { - elm_atspi_accessible_relationship_append(m_pEo, ELM_ATSPI_RELATION_FLOWS_FROM, m_pEo); - elm_atspi_accessible_relationship_append(m_pEo, ELM_ATSPI_RELATION_FLOWS_TO, obj); - elm_atspi_accessible_relationship_append(obj, ELM_ATSPI_RELATION_FLOWS_FROM, m_pEo); - } - - inline void Atspi::appendFlowRel(Elm_Interface_Atspi_Accessible *obj) - { - elm_atspi_accessible_relationship_append(m_pEo, ELM_ATSPI_RELATION_FLOWS_TO, obj); - elm_atspi_accessible_relationship_append(obj, ELM_ATSPI_RELATION_FLOWS_FROM, m_pEo); - } - - inline void Atspi::removeFlowRel(Elm_Interface_Atspi_Accessible *obj) - { - elm_atspi_accessible_relationship_remove(m_pEo, ELM_ATSPI_RELATION_FLOWS_TO, obj); - elm_atspi_accessible_relationship_remove(obj, ELM_ATSPI_RELATION_FLOWS_FROM, m_pEo); - } + /** + * @brief Wrapper for Elm_Interface_Atspi_Accessible interface (Screen reader) + */ + class Atspi { + public: + Atspi(); + Atspi(Elm_Interface_Atspi_Accessible *obj); + void wrap(Elm_Interface_Atspi_Accessible *obj); + Elm_Interface_Atspi_Accessible *getEo() const; + operator Elm_Interface_Atspi_Accessible *() const; + + void setDescription(const TText &text); + void setName(const TText &text); + void setRole(Elm_Atspi_Role role); + void setReadingInfo(Elm_Accessible_Reading_Info_Type type); + void appendRel(Elm_Atspi_Relation_Type type, const Elm_Interface_Atspi_Accessible *obj); + void removeRel(Elm_Atspi_Relation_Type type, const Elm_Interface_Atspi_Accessible *obj); + void canHighlight(bool canHighlight); + void setActionCb(const Elm_Access_Action_Type type, const Elm_Access_Action_Cb cb, const void *data); + + void makeStartPosition(Elm_Interface_Atspi_Accessible *obj); + void appendFlowRel(Elm_Interface_Atspi_Accessible *obj); + void removeFlowRel(Elm_Interface_Atspi_Accessible *obj); + + // TODO: impl. other methods if needed + + private: + Elm_Interface_Atspi_Accessible *m_pEo; + }; + + inline Atspi::Atspi() + : m_pEo(nullptr) + { + } + + inline Atspi::Atspi(Elm_Interface_Atspi_Accessible *obj) + : m_pEo(obj) + { + } + + inline void Atspi::wrap(Elm_Interface_Atspi_Accessible *obj) + { + m_pEo = obj; + } + + inline Elm_Interface_Atspi_Accessible *Atspi::getEo() const + { + return m_pEo; + } + + inline Atspi::operator Elm_Interface_Atspi_Accessible *() const + { + return getEo(); + } + + inline void Atspi::setDescription(const TText &text) + { + if (text.getDomain()) + elm_atspi_accessible_translation_domain_set(m_pEo, text.getDomain()); + elm_atspi_accessible_description_set(m_pEo, text.translate().c_str()); + } + + inline void Atspi::setName(const TText &text) + { + if (text.getDomain()) + elm_atspi_accessible_translation_domain_set(m_pEo, text.getDomain()); + elm_atspi_accessible_name_set(m_pEo, text.translate().c_str()); + } + + inline void Atspi::setRole(Elm_Atspi_Role role) + { + elm_atspi_accessible_role_set(m_pEo, role); + } + + inline void Atspi::setReadingInfo(Elm_Accessible_Reading_Info_Type type) + { + elm_atspi_accessible_reading_info_type_set(m_pEo, type); + } + + inline void Atspi::appendRel(Elm_Atspi_Relation_Type type, const Elm_Interface_Atspi_Accessible *obj) + { + elm_atspi_accessible_relationship_append(m_pEo, type, obj); + } + + inline void Atspi::removeRel(Elm_Atspi_Relation_Type type, const Elm_Interface_Atspi_Accessible *obj) + { + elm_atspi_accessible_relationship_remove(m_pEo, type, obj); + } + + inline void Atspi::canHighlight(bool canHighlight) + { + elm_atspi_accessible_can_highlight_set(m_pEo, canHighlight); + } + + inline void Atspi::setActionCb(const Elm_Access_Action_Type type, const Elm_Access_Action_Cb cb, const void *data) + { + elm_access_action_cb_set(m_pEo, type, cb, data); + } + + inline void Atspi::makeStartPosition(Elm_Interface_Atspi_Accessible *obj) + { + elm_atspi_accessible_relationship_append(m_pEo, ELM_ATSPI_RELATION_FLOWS_FROM, m_pEo); + elm_atspi_accessible_relationship_append(m_pEo, ELM_ATSPI_RELATION_FLOWS_TO, obj); + elm_atspi_accessible_relationship_append(obj, ELM_ATSPI_RELATION_FLOWS_FROM, m_pEo); + } + + inline void Atspi::appendFlowRel(Elm_Interface_Atspi_Accessible *obj) + { + elm_atspi_accessible_relationship_append(m_pEo, ELM_ATSPI_RELATION_FLOWS_TO, obj); + elm_atspi_accessible_relationship_append(obj, ELM_ATSPI_RELATION_FLOWS_FROM, m_pEo); + } + + inline void Atspi::removeFlowRel(Elm_Interface_Atspi_Accessible *obj) + { + elm_atspi_accessible_relationship_remove(m_pEo, ELM_ATSPI_RELATION_FLOWS_TO, obj); + elm_atspi_accessible_relationship_remove(obj, ELM_ATSPI_RELATION_FLOWS_FROM, m_pEo); + } } #endif /* Atspi_h_ */ diff --git a/src/Common/View/inc/BasePopup.h b/src/Common/View/inc/BasePopup.h index f8b1c25..cea4d82 100644 --- a/src/Common/View/inc/BasePopup.h +++ b/src/Common/View/inc/BasePopup.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -21,37 +21,37 @@ namespace Msg { - class PopupManager; + class PopupManager; - class BasePopup - : public View { + class BasePopup + : public View { - friend class PopupManager; + friend class PopupManager; - public: - BasePopup(Evas_Object *popup); - virtual ~BasePopup(); + public: + BasePopup(Evas_Object *popup); + virtual ~BasePopup(); - void destroy(bool anim = true); + void destroy(bool anim = true); - void setDismissByOutsideTapFlag(bool value); - bool getDismissByOutsideTapFlag() const; + void setDismissByOutsideTapFlag(bool value); + bool getDismissByOutsideTapFlag() const; - void setDismissByPauseAppFlag(bool value); - bool getDismissByPauseAppFlag() const; + void setDismissByPauseAppFlag(bool value); + bool getDismissByPauseAppFlag() const; - void setDismissByBackButtonFlag(bool value); - bool getDismissByBackButtonFlag() const; + void setDismissByBackButtonFlag(bool value); + bool getDismissByBackButtonFlag() const; - protected: - static Evas_Object *getWindow(); - virtual void dismiss(); + protected: + static Evas_Object *getWindow(); + virtual void dismiss(); - private: - bool m_OutsideTapDismiss; - bool m_PauseAppDismiss; - bool m_BackButtonDismiss; - }; + private: + bool m_OutsideTapDismiss; + bool m_PauseAppDismiss; + bool m_BackButtonDismiss; + }; } #endif /* BasePopup_h_ */ diff --git a/src/Common/View/inc/BaseView.h b/src/Common/View/inc/BaseView.h index 0f71e12..3af501a 100644 --- a/src/Common/View/inc/BaseView.h +++ b/src/Common/View/inc/BaseView.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -23,60 +23,60 @@ namespace Msg { - /** - * @brief Basic interface for all visual objects used across the whole application. - */ - class BaseView - { - public: - BaseView(); - virtual ~BaseView() {}; + /** + * @brief Basic interface for all visual objects used across the whole application. + */ + class BaseView + { + public: + BaseView(); + virtual ~BaseView() {}; - operator Evas_Object *() const; - Eo *getEo() const; + operator Evas_Object *() const; + Eo *getEo() const; - /** - * @brief Gets AtspiAccessibleInterface wrapper - * @return wrapper to AtspiAccessibleInterface - */ - Atspi getAtspi() const; + /** + * @brief Gets AtspiAccessibleInterface wrapper + * @return wrapper to AtspiAccessibleInterface + */ + Atspi getAtspi() const; - protected: - void setEo(Eo *eo); + protected: + void setEo(Eo *eo); - /** - * @brief Performs self-removing by request from children-classes. - */ - virtual void onViewDestroyed() { delete this; }; + /** + * @brief Performs self-removing by request from children-classes. + */ + virtual void onViewDestroyed() { delete this; }; - protected: - Eo *m_pEo; - }; + protected: + Eo *m_pEo; + }; - inline BaseView::BaseView() - : m_pEo(nullptr) - { - } + inline BaseView::BaseView() + : m_pEo(nullptr) + { + } - inline Atspi BaseView::getAtspi() const - { - return Atspi(m_pEo); - } + inline Atspi BaseView::getAtspi() const + { + return Atspi(m_pEo); + } - inline BaseView::operator Eo *() const - { - return m_pEo; - } + inline BaseView::operator Eo *() const + { + return m_pEo; + } - inline Eo *BaseView::getEo() const - { - return m_pEo; - } + inline Eo *BaseView::getEo() const + { + return m_pEo; + } - inline void BaseView::setEo(Eo *eo) - { - m_pEo = eo; - } + inline void BaseView::setEo(Eo *eo) + { + m_pEo = eo; + } } #endif /* BaseView_h_ */ diff --git a/src/Common/View/inc/BottomButton.h b/src/Common/View/inc/BottomButton.h index e198182..62fe835 100644 --- a/src/Common/View/inc/BottomButton.h +++ b/src/Common/View/inc/BottomButton.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -20,19 +20,19 @@ #include "View.h" namespace Msg { - class BottomButton - : public View { + class BottomButton + : public View { - public: - BottomButton(Evas_Object *parent); - Evas_Object *getInnerButton() const; + public: + BottomButton(Evas_Object *parent); + Evas_Object *getInnerButton() const; - void setText(const TText &text); - void disabled(bool value); + void setText(const TText &text); + void disabled(bool value); - private: - Evas_Object *m_pButton; - }; + private: + Evas_Object *m_pButton; + }; } #endif /* BottomButton_h_ */ diff --git a/src/Common/View/inc/CtxPopup.h b/src/Common/View/inc/CtxPopup.h index 86e64f0..d4aad3e 100644 --- a/src/Common/View/inc/CtxPopup.h +++ b/src/Common/View/inc/CtxPopup.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -21,51 +21,51 @@ #include "ViewItem.h" namespace Msg { - class CtxPopup; - class CtxPopupItem; - class Window; + class CtxPopup; + class CtxPopupItem; + class Window; - typedef void (*CtxPopupItemPressedCb)(CtxPopupItem &item, void *userData); + typedef void (*CtxPopupItemPressedCb)(CtxPopupItem &item, void *userData); - class CtxPopupItem - : public ViewItem { + class CtxPopupItem + : public ViewItem { - friend class CtxPopup; + friend class CtxPopup; - public: - CtxPopup &getParent(); + public: + CtxPopup &getParent(); - private: - CtxPopupItem(CtxPopup &parent, CtxPopupItemPressedCb userCb, void *userData); - virtual ~CtxPopupItem(); + private: + CtxPopupItem(CtxPopup &parent, CtxPopupItemPressedCb userCb, void *userData); + virtual ~CtxPopupItem(); - private: - CtxPopup &m_Parent; - CtxPopupItemPressedCb m_pUserCb; - void *m_pUserData; - }; + private: + CtxPopup &m_Parent; + CtxPopupItemPressedCb m_pUserCb; + void *m_pUserData; + }; - class CtxPopup - : public BasePopup { + class CtxPopup + : public BasePopup { - public: - CtxPopup(); - virtual ~CtxPopup(); + public: + CtxPopup(); + virtual ~CtxPopup(); - CtxPopupItem *appendItem(const TText &text, Evas_Object *icon = nullptr, - CtxPopupItemPressedCb cb = nullptr, void *userData = nullptr); - void setDirectionPriority(Elm_Ctxpopup_Direction first, Elm_Ctxpopup_Direction second, - Elm_Ctxpopup_Direction third, Elm_Ctxpopup_Direction fourth); - void align(Window &win); - void align(Evas_Object *obj); + CtxPopupItem *appendItem(const TText &text, Evas_Object *icon = nullptr, + CtxPopupItemPressedCb cb = nullptr, void *userData = nullptr); + void setDirectionPriority(Elm_Ctxpopup_Direction first, Elm_Ctxpopup_Direction second, + Elm_Ctxpopup_Direction third, Elm_Ctxpopup_Direction fourth); + void align(Window &win); + void align(Evas_Object *obj); - Elm_Ctxpopup_Direction getDirection() const; + Elm_Ctxpopup_Direction getDirection() const; - private: - void createCtxPopup(Evas_Object *parent); - static void on_dismissed_cb(void *data, Evas_Object *obj, void *event_info); - static void on_item_pressed_cb(void *data, Evas_Object * obj, void *event_info); - }; + private: + void createCtxPopup(Evas_Object *parent); + static void on_dismissed_cb(void *data, Evas_Object *obj, void *event_info); + static void on_item_pressed_cb(void *data, Evas_Object * obj, void *event_info); + }; } #endif // CtxPopup_h_ diff --git a/src/Common/View/inc/DefaultLayout.h b/src/Common/View/inc/DefaultLayout.h index ec3bf0e..bbf6fd3 100644 --- a/src/Common/View/inc/DefaultLayout.h +++ b/src/Common/View/inc/DefaultLayout.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -20,25 +20,25 @@ #include "View.h" namespace Msg { - class DefaultLayout - : public View { + class DefaultLayout + : public View { - public: - DefaultLayout(Evas_Object *parent); - virtual ~DefaultLayout(); + public: + DefaultLayout(Evas_Object *parent); + virtual ~DefaultLayout(); - void setContent(Evas_Object *obj); - void setNoContent(Evas_Object *obj); - void setMoreOption(Evas_Object *obj); - void setSelectButton(Evas_Object *obj); - void setBottomButton(Evas_Object *obj); + void setContent(Evas_Object *obj); + void setNoContent(Evas_Object *obj); + void setMoreOption(Evas_Object *obj); + void setSelectButton(Evas_Object *obj); + void setBottomButton(Evas_Object *obj); - void showContent(bool show); - void showNoContent(bool show); - void showMoreOption(bool show); - void showSelectButton(bool show); - void showBottomButton(bool show); - }; + void showContent(bool show); + void showNoContent(bool show); + void showMoreOption(bool show); + void showSelectButton(bool show); + void showBottomButton(bool show); + }; } #endif /* DefaultLayout_h_ */ diff --git a/src/Common/View/inc/Entry.h b/src/Common/View/inc/Entry.h index 1046441..d73e703 100644 --- a/src/Common/View/inc/Entry.h +++ b/src/Common/View/inc/Entry.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -20,50 +20,50 @@ #include "View.h" namespace Msg { - class Entry - : public View { + class Entry + : public View { - public: - typedef void (*InputPanelEventCb) (void *data, Ecore_IMF_Context *ctx, int value); + public: + typedef void (*InputPanelEventCb) (void *data, Ecore_IMF_Context *ctx, int value); - public: - Entry(Evas_Object *parent); - virtual ~Entry(); + public: + Entry(Evas_Object *parent); + virtual ~Entry(); - void setInputPanelReturnType(Elm_Input_Panel_Return_Key_Type retType); - void setGuideText(const TText &text); - std::string getText() const; - void setText(const std::string &text); - const char *getEntry() const; - void setEditable(bool value); - void enabledInputPanel(bool value); - void showInputPanel(bool value); - void setScrollerPolicy(Elm_Scroller_Policy policyH, Elm_Scroller_Policy policyV); - void setAutocapitalType(Elm_Autocapital_Type type); - void setScrollable(bool value); - void setSingleLine(bool value); - void setCursorPos(int pos); - void setCursorPosToEnd(); - int getCursorPos() const; - void setEditInfo(Entry &entry); - bool isEmpty() const; - void clear(); - void setLimit(int charCount, int byteCount = 0); - void disabledReturnKey(bool disabled); + void setInputPanelReturnType(Elm_Input_Panel_Return_Key_Type retType); + void setGuideText(const TText &text); + std::string getText() const; + void setText(const std::string &text); + const char *getEntry() const; + void setEditable(bool value); + void enabledInputPanel(bool value); + void showInputPanel(bool value); + void setScrollerPolicy(Elm_Scroller_Policy policyH, Elm_Scroller_Policy policyV); + void setAutocapitalType(Elm_Autocapital_Type type); + void setScrollable(bool value); + void setSingleLine(bool value); + void setCursorPos(int pos); + void setCursorPosToEnd(); + int getCursorPos() const; + void setEditInfo(Entry &entry); + bool isEmpty() const; + void clear(); + void setLimit(int charCount, int byteCount = 0); + void disabledReturnKey(bool disabled); - void addMarkupFilterCb(Elm_Entry_Filter_Cb, void *data); - void addPreeditCb(Evas_Smart_Cb cb, void *data); - void addActivatedCb(Evas_Smart_Cb cb, void *data); - void addMaxlengthReachedCb(Evas_Smart_Cb cb, void *data); - void addFocusedCb(Evas_Smart_Cb cb, void *data); - void addUnfocusedCb(Evas_Smart_Cb cb, void *data); - void addChangedCb(Evas_Smart_Cb cb, void *data); - void addKeyDownCb(Evas_Object_Event_Cb cb, void *data); - void addInputPanelEventCb(Ecore_IMF_Input_Panel_Event type, InputPanelEventCb cb, const void *data); - void delInputPanelEventCb(Ecore_IMF_Input_Panel_Event type, InputPanelEventCb cb); - }; + void addMarkupFilterCb(Elm_Entry_Filter_Cb, void *data); + void addPreeditCb(Evas_Smart_Cb cb, void *data); + void addActivatedCb(Evas_Smart_Cb cb, void *data); + void addMaxlengthReachedCb(Evas_Smart_Cb cb, void *data); + void addFocusedCb(Evas_Smart_Cb cb, void *data); + void addUnfocusedCb(Evas_Smart_Cb cb, void *data); + void addChangedCb(Evas_Smart_Cb cb, void *data); + void addKeyDownCb(Evas_Object_Event_Cb cb, void *data); + void addInputPanelEventCb(Ecore_IMF_Input_Panel_Event type, InputPanelEventCb cb, const void *data); + void delInputPanelEventCb(Ecore_IMF_Input_Panel_Event type, InputPanelEventCb cb); + }; - bool isPreedit(const char *str); + bool isPreedit(const char *str); } #endif /* Entry_h_ */ diff --git a/src/Common/View/inc/IconTextPopup.h b/src/Common/View/inc/IconTextPopup.h index abe4491..fcae670 100644 --- a/src/Common/View/inc/IconTextPopup.h +++ b/src/Common/View/inc/IconTextPopup.h @@ -21,31 +21,31 @@ #include "StandardPopup.h" namespace Msg { - class IconTextPopup - : public StandardPopup { - public: - enum IconType { - NoneIcon, - ProgressIcon, - CheckIcon, - FailedIcon - }; - public: - IconTextPopup(); - virtual ~IconTextPopup(); + class IconTextPopup + : public StandardPopup { + public: + enum IconType { + NoneIcon, + ProgressIcon, + CheckIcon, + FailedIcon + }; + public: + IconTextPopup(); + virtual ~IconTextPopup(); - void setText(const TText &text); - void setIcon(IconType type); + void setText(const TText &text); + void setIcon(IconType type); - private: - void showProgressBar(); - void showCheckItem(); - void showFailItem(); + private: + void showProgressBar(); + void showCheckItem(); + void showFailItem(); - private: - Evas_Object *m_pLayout; - IconType m_IconType; - }; + private: + Evas_Object *m_pLayout; + IconType m_IconType; + }; } #endif /* IconTextPopup_h_ */ diff --git a/src/Common/View/inc/InputLayout.h b/src/Common/View/inc/InputLayout.h index a2c470a..9dac04e 100644 --- a/src/Common/View/inc/InputLayout.h +++ b/src/Common/View/inc/InputLayout.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -20,17 +20,17 @@ #include "Entry.h" namespace Msg { - class InputLayout - : public View { + class InputLayout + : public View { - public: - InputLayout(Evas_Object *parent); - virtual ~InputLayout(); + public: + InputLayout(Evas_Object *parent); + virtual ~InputLayout(); - void setPredictBar(Evas_Object *obj); - void setEntry(Evas_Object *obj); - void showPredictBar(bool value); - }; + void setPredictBar(Evas_Object *obj); + void setEntry(Evas_Object *obj); + void showPredictBar(bool value); + }; } #endif /* InputLayout_h_ */ diff --git a/src/Common/View/inc/LineListViewItem.h b/src/Common/View/inc/LineListViewItem.h index bcc61ba..bf27406 100644 --- a/src/Common/View/inc/LineListViewItem.h +++ b/src/Common/View/inc/LineListViewItem.h @@ -21,23 +21,23 @@ #include namespace Msg { - class LineListViewItem - : public ListItem { - public: - LineListViewItem(std::string titleText = std::string()); - virtual ~LineListViewItem(); + class LineListViewItem + : public ListItem { + public: + LineListViewItem(std::string titleText = std::string()); + virtual ~LineListViewItem(); - void setText(std::string text); + void setText(std::string text); - protected: - void onAttached(ViewItem &item) override; + protected: + void onAttached(ViewItem &item) override; - private: - std::string getText(ListItem &item, const char *part) override; + private: + std::string getText(ListItem &item, const char *part) override; - private: - std::string m_TitleText; - }; + private: + std::string m_TitleText; + }; } #endif /* LineListViewItem_h_ */ diff --git a/src/Common/View/inc/ListItem.h b/src/Common/View/inc/ListItem.h index 2c179e4..8d9f0af 100644 --- a/src/Common/View/inc/ListItem.h +++ b/src/Common/View/inc/ListItem.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -27,198 +27,198 @@ namespace Msg { - class ListView; - class ListItemStyle; - class ListItem; - typedef std::shared_ptr ListItemStyleRef; - typedef std::vector ListItemCollection; - - class ListItemStyle - { - public: - ListItemStyle(const char *itemStyle, - const char *decorateItemStyle = nullptr, - const char *decorateAllItemStyle = nullptr); - virtual ~ListItemStyle(); - - static ListItemStyleRef create(const char *itemStyle, - const char *decorateItemStyle = nullptr, - const char *decorateAllItemStyle = nullptr); - private: - friend class ListView; - friend class ListItem; - - void registerCallback(); - void unregisterCallback(); - void setStyle(const char *itemStyle, const char *decorateItemStyle, const char *decorateAllItemStyle); - - private: - Elm_Genlist_Item_Class *m_pGenlistItemClass; - }; - - /** - * @brief Wraps all basic genlist item operations. - */ - class ListItem - : public ViewItem - { - friend class ListItemStyle; - friend class ListView; - - public: - using OnSelectedCb = std::function; - - /** - * @brief Creates instance of ListItem of specified genlist-item type. - * @param[in] type genlist item-type. - */ - ListItem(Elm_Genlist_Item_Type type = ELM_GENLIST_ITEM_NONE); - - /** - * @brief Creates instance of ListItem of specified genlist-item type with predefined style. - * @param[in] itemStyle predefined item style. - * @param[in] type genlist item-type. - */ - ListItem(const ListItemStyleRef &itemStyle, Elm_Genlist_Item_Type type = ELM_GENLIST_ITEM_NONE); - virtual ~ListItem(); - - // Base elm methods: - /** - * @brief Gets list-item style. - * @return item style. - */ - const ListItemStyleRef &getStyle() const; - - /** - * @brief Sets specified style to list-item. - * @param[in] style a style to be set. - */ - void setStyle(ListItemStyleRef &style); - - /** - * @brief Makes list-item selected(unselected). - * @param[in] selected if true makes list-item selected, if false - unselects it. - */ - void setSelected(bool selected); - - /** - * @brief Checks whether list-item is selected or not. - * @return true if list-item is selected, false otherwise. - */ - bool getSelected() const; - - /** - * @brief Makes list-item able to be selected. - * @param[in] selectable if true makes list-item able to be selected, if false - list-item will ignore selection. - */ - void setSelectable(bool selectable); - - /** - * @brief Checks whether list-item is able to be selected or not. - * @return true if list-item is selectable, false otherwise. - */ - bool getSelectable() const; - - /** - * @brief Sets the expanded state of an list-item. - * @param[in] expand expanded state. - */ - void setExpanded(bool expand); - - /** - * @brief Update all the contents of an item. - */ - void update(); - - /** - * @brief Updates specified parts in list-item. - * @param[in] parts a parts to be updated. Used for globbing to match '*', '?', and '.'. - * @param[in] type The type of item's part type. - */ - void updateFields(const char *parts, Elm_Genlist_Item_Field_Type type); - - /** - * @brief Gets a ListView instance that owns this list-item. - * @return owner ListView. - */ - ListView *getOwner() const; - - /** - * @brief Gets type of nested genlist-item. - * @return genlist item type. - */ - Elm_Genlist_Item_Type getType() const; - - // Check(Select) methods: - /** - * @brief Changes checked state of list-item. Also item optionally can update full it's content. - * @param[in] updateUi if true all list-item's content will be forced to update. - */ - void changeCheckedState(bool updateUi); - - /** - * @brief Updates list-item's checked state with state specified. Also item optionally can update full it's content. - * @param[in] state a new checked-state to be applied. - * @param[in] updateUi if true all list-item's content will be forced to update. - */ - virtual void setCheckedState(bool state, bool updateUi); - - /** - * @brief Checks whether list- item is checked or not. - * @return true if list-item is checked, false otherwise. - */ - bool getCheckedState() const; - - /** - * @brief Checks whether item is Checkable - * @return true if checkable, false otherwise. - */ - virtual bool isCheckable() const; - - /** - * @brief Compare two items - * @param[in] item for compare - * @return true if items is same, false otherwise - */ - bool isSame(const ListItem &item) const; - - /** - * @brief Sets custom selected callback to item - * @param[in] cb OnSelectedCb callback - */ - void setOnSelectedCb(OnSelectedCb cb); - - protected: - virtual std::string getText(ListItem &item, const char *part); - virtual Evas_Object *getContent(ListItem &item, const char *part); - virtual bool getState(ListItem &item, const char *part); - virtual void onDelete(ListItem &item); - virtual const char *getCheckPart(ListItem &item); - virtual bool getFilter(ListItem &item, void *key); - - virtual void onRealized(ListItem &item) {}; - virtual void onUnrealized(ListItem &item) {}; - - OnSelectedCb &getOnSelectedCb(); - - private: - virtual void onViewDestroyed(); - Evas_Object *addCheck(); - void onCheckChanged(Evas_Object *obj, void *eventInfo); - - static char * elm_gen_item_text_get_cb(void * data, Evas_Object * obj, const char * part); - static Evas_Object * elm_gen_item_content_get_cb(void * data, Evas_Object * obj, const char * part); - static Eina_Bool elm_gen_item_state_get_cb(void * data, Evas_Object * obj, const char * part); - static void elm_gen_item_del_cb(void *data, Evas_Object *obj); - static Eina_Bool elm_gen_item_filter_cb(void *data, Evas_Object *obj, void *key); - - private: - ListView *m_pOwner; - ListItemStyleRef m_ItemStyle; - Elm_Genlist_Item_Type m_Type; - bool m_Checked; - OnSelectedCb m_OnSelectedCb; - }; + class ListView; + class ListItemStyle; + class ListItem; + typedef std::shared_ptr ListItemStyleRef; + typedef std::vector ListItemCollection; + + class ListItemStyle + { + public: + ListItemStyle(const char *itemStyle, + const char *decorateItemStyle = nullptr, + const char *decorateAllItemStyle = nullptr); + virtual ~ListItemStyle(); + + static ListItemStyleRef create(const char *itemStyle, + const char *decorateItemStyle = nullptr, + const char *decorateAllItemStyle = nullptr); + private: + friend class ListView; + friend class ListItem; + + void registerCallback(); + void unregisterCallback(); + void setStyle(const char *itemStyle, const char *decorateItemStyle, const char *decorateAllItemStyle); + + private: + Elm_Genlist_Item_Class *m_pGenlistItemClass; + }; + + /** + * @brief Wraps all basic genlist item operations. + */ + class ListItem + : public ViewItem + { + friend class ListItemStyle; + friend class ListView; + + public: + using OnSelectedCb = std::function; + + /** + * @brief Creates instance of ListItem of specified genlist-item type. + * @param[in] type genlist item-type. + */ + ListItem(Elm_Genlist_Item_Type type = ELM_GENLIST_ITEM_NONE); + + /** + * @brief Creates instance of ListItem of specified genlist-item type with predefined style. + * @param[in] itemStyle predefined item style. + * @param[in] type genlist item-type. + */ + ListItem(const ListItemStyleRef &itemStyle, Elm_Genlist_Item_Type type = ELM_GENLIST_ITEM_NONE); + virtual ~ListItem(); + + // Base elm methods: + /** + * @brief Gets list-item style. + * @return item style. + */ + const ListItemStyleRef &getStyle() const; + + /** + * @brief Sets specified style to list-item. + * @param[in] style a style to be set. + */ + void setStyle(ListItemStyleRef &style); + + /** + * @brief Makes list-item selected(unselected). + * @param[in] selected if true makes list-item selected, if false - unselects it. + */ + void setSelected(bool selected); + + /** + * @brief Checks whether list-item is selected or not. + * @return true if list-item is selected, false otherwise. + */ + bool getSelected() const; + + /** + * @brief Makes list-item able to be selected. + * @param[in] selectable if true makes list-item able to be selected, if false - list-item will ignore selection. + */ + void setSelectable(bool selectable); + + /** + * @brief Checks whether list-item is able to be selected or not. + * @return true if list-item is selectable, false otherwise. + */ + bool getSelectable() const; + + /** + * @brief Sets the expanded state of an list-item. + * @param[in] expand expanded state. + */ + void setExpanded(bool expand); + + /** + * @brief Update all the contents of an item. + */ + void update(); + + /** + * @brief Updates specified parts in list-item. + * @param[in] parts a parts to be updated. Used for globbing to match '*', '?', and '.'. + * @param[in] type The type of item's part type. + */ + void updateFields(const char *parts, Elm_Genlist_Item_Field_Type type); + + /** + * @brief Gets a ListView instance that owns this list-item. + * @return owner ListView. + */ + ListView *getOwner() const; + + /** + * @brief Gets type of nested genlist-item. + * @return genlist item type. + */ + Elm_Genlist_Item_Type getType() const; + + // Check(Select) methods: + /** + * @brief Changes checked state of list-item. Also item optionally can update full it's content. + * @param[in] updateUi if true all list-item's content will be forced to update. + */ + void changeCheckedState(bool updateUi); + + /** + * @brief Updates list-item's checked state with state specified. Also item optionally can update full it's content. + * @param[in] state a new checked-state to be applied. + * @param[in] updateUi if true all list-item's content will be forced to update. + */ + virtual void setCheckedState(bool state, bool updateUi); + + /** + * @brief Checks whether list- item is checked or not. + * @return true if list-item is checked, false otherwise. + */ + bool getCheckedState() const; + + /** + * @brief Checks whether item is Checkable + * @return true if checkable, false otherwise. + */ + virtual bool isCheckable() const; + + /** + * @brief Compare two items + * @param[in] item for compare + * @return true if items is same, false otherwise + */ + bool isSame(const ListItem &item) const; + + /** + * @brief Sets custom selected callback to item + * @param[in] cb OnSelectedCb callback + */ + void setOnSelectedCb(OnSelectedCb cb); + + protected: + virtual std::string getText(ListItem &item, const char *part); + virtual Evas_Object *getContent(ListItem &item, const char *part); + virtual bool getState(ListItem &item, const char *part); + virtual void onDelete(ListItem &item); + virtual const char *getCheckPart(ListItem &item); + virtual bool getFilter(ListItem &item, void *key); + + virtual void onRealized(ListItem &item) {}; + virtual void onUnrealized(ListItem &item) {}; + + OnSelectedCb &getOnSelectedCb(); + + private: + virtual void onViewDestroyed(); + Evas_Object *addCheck(); + void onCheckChanged(Evas_Object *obj, void *eventInfo); + + static char * elm_gen_item_text_get_cb(void * data, Evas_Object * obj, const char * part); + static Evas_Object * elm_gen_item_content_get_cb(void * data, Evas_Object * obj, const char * part); + static Eina_Bool elm_gen_item_state_get_cb(void * data, Evas_Object * obj, const char * part); + static void elm_gen_item_del_cb(void *data, Evas_Object *obj); + static Eina_Bool elm_gen_item_filter_cb(void *data, Evas_Object *obj, void *key); + + private: + ListView *m_pOwner; + ListItemStyleRef m_ItemStyle; + Elm_Genlist_Item_Type m_Type; + bool m_Checked; + OnSelectedCb m_OnSelectedCb; + }; } #endif // ListItem_65152b60_4142_11e3_aa6e_0800200c9a66_h_ diff --git a/src/Common/View/inc/ListView.h b/src/Common/View/inc/ListView.h index ea7bbff..f9767a8 100644 --- a/src/Common/View/inc/ListView.h +++ b/src/Common/View/inc/ListView.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -25,376 +25,376 @@ namespace Msg { - class IListViewListener; - - /** - * @brief Wraps all basic genlist operations. - */ - class ListView - : public View - { - public: - /**@brief Function of comparing two list-items, used for sorted item insertion.*/ - typedef int (*CmpFunc)(const ListItem &item1, const ListItem &item2); - - public: - /** - * @brief A constructor of ListView object based on outside parent object. - * @param[in] parent an object responsible for automatic removing of ListView instance. - * @param[in] parent circle surface - */ - ListView(Evas_Object *parent, Eext_Circle_Surface *parentCircleSurface = nullptr); - virtual ~ListView(); - - /** - * @brief Sets subscriber that will be notified on list-view events. - * @param[in] listener a listener. - */ - void setListener(IListViewListener *listener); - - /** - * @brief Appends specified list-view item into list-view. - * @param[in] listItem an item to be appended. - * @param[in] parent a parent item. - * @return true in case of success, false otherwise. - */ - bool appendItem(ListItem &listItem, ListItem *parent = nullptr); - - /** - * @brief Inserts an item before another in a genlist widget - * @param[in] listItem an item to be appended. - * @param[in] before the item before which to place this new one - * @param[in] parent a parent item. - * @return true in case of success, false otherwise. - */ - bool insertBeforeItem(ListItem &listItem, ListItem &before, ListItem *parent = nullptr); - - /** - * @brief Prepends specified list-view item into list-view. - * @param[in] listItem an item to be prepended. - * @param[in] parent a parent item. - * @return true in case of success, false otherwise. - */ - bool prependItem(ListItem &listItem, ListItem *parent = nullptr); - - /** - * @brief Performs sorted item insertion. - * @param[in] listItem an item to be inserted. - * @param[in] parent a parent item. - * @return true in case of success, false otherwise. - */ - bool sortedInsertItem(ListItem &listItem, ListItem *parent = nullptr); - - /** - * @brief Sets item compare function to make work of sortedInsertItem() correct. - * @param[in] fn items compare function. - */ - void setCmpFunc(CmpFunc fn); - - /** - * @brief Deletes item from list-view. - * @param[in, out] listItem item to be deleted. - */ - void deleteItem(ListItem &listItem); - - /** - * @brief Gets all list-view items. - * @return list-view items. - */ - ListItemCollection getItems() const; - - /** - * @brief Gets realized list-view items. - * @return list-view items. - */ - ListItemCollection getRealizedItems() const; - - /** - * @brief Gets first list-view item. - * @return first list-view item. - */ - ListItem *getFirstItem() const; - - /** - * @brief Gets last list-view item. - * @return last list-view item. - */ - ListItem *getLastItem() const; - - /** - * @brief Shows list-view item. This causes list-view to jump to the given item @c it and show it (by jumping - * to that position), if it is not fully visible. - * @param[in] listItem an item to be shown. - * @param[in] type The position to bring in, the given item to. - */ - void showItem(ListItem &listItem, Elm_Genlist_Item_Scrollto_Type type); - - /** - * @brief Enables(disables) multiselection. - * @param[in] value if true enables multiselection, otherwise disables it. - */ - void setMultiSelection(bool value); - - /** - * @brief Checks whether multiselection is turned on or not. - * @return true if multiselection is enabled, otherwise false. - */ - bool getMultiSelection() const; - - /** - * @brief Removes all list-items. - */ - void clear(); - - /** - * @brief Checks whether list-view contains at least one item or not. - * @return true if list-view has no items, otherwise false. - */ - bool isEmpty() const; - - /** - * @brief Passes mode to nested genlist. - * @param[in] mode a mode to be applied. - */ - void setMode(Elm_List_Mode mode); - - /** - * @brief Enable(disable) genlist homogeneous mode. - * @param[in] isHomogeneous if true turns on homogeneous mode, otherwise turns it off. - */ - void setHomogeneous(bool isHomogeneous); - - /** - * @brief Gets selected view-item. - * @return selected list-view item or nullptr if no item is selected. - */ - ListItem *getSelectedItem() const; - - /** - * @brief Gets number of items. - * @return number of items. - */ - unsigned getItemsCount() const; - - /** - * @brief Gets list-view item next to specified one. - * @param[in] item an item in genlist. - * @return next item to the specified one. If there's no next item nullptr is returned. - */ - ListItem *getNextItem(ListItem &item) const; - - /** - * @brief Gets list-view item previous to specified one. - * @param[in] item an item in genlist. - * @return next item to the specified one. If there's no previous item nullptr is returned. - */ - ListItem *getPrevItem(ListItem &item) const; - - /** - * @brief Demotes specified list-view item to the end of the list. - * @param[in] item an item to be demoted. - */ - void demoteItem(ListItem &item); - - /** - * @brief Promotes specified list-view item to the begin of the list. - * @param[in] item an item to be promoted. - */ - void promoteItem(ListItem &item); - - /** - * @brief Set filter for items - * @param[in] key The filter key - */ - void setFilter(void *key); - - /** - * @brief Enables(disables selection mode). Makes all list-view items to show(hide) a check-box. - * @param[in] check if true makes all items to show checkbox, otherwise make them to hide it. - */ - void setCheckMode(bool check); - - /** - * @brief Checks wheather selection mode is enabled or not. - * @return true if selection mode is enabled, false otherwise. - */ - bool getCheckMode() const; - - /** - * @brief Checks(unchecks) all list-view items in selection mode and updates realized items. - * @param[in] check if true all items will be checked, if false - unchecks all items. - * @param[in] updateUi if true Ui will be forced update. - */ - void checkAllItems(bool check, bool updateUi = true); - - - /** - * @brief Sets the scroll item align state. - * @remarks If the object's scroll item align is enabled, the nearest - * item to the end of the scroll will be located according to - * its vertical align.1 - * @param[in] enabled The scroll item align state - */ - void enabledAlign(bool enabled); - - void setRealizationMode(bool mode); - - template - std::vector getItems() const; - - template - unsigned getItemsCount() const; - - template - bool hasItem() const; - - template - T *findNextItem(ListItem &item) const; - - template - T *findPrevItem(ListItem &item) const; - - /** - * @brief Gets all checked items count. - * @return count of checked items. - */ - unsigned getCheckedItemsCount() const; - - /** - * @brief Gets all checkable items count. - * @return count of checkable items. - */ - unsigned getCheckableItemsCount() const; - - /** - * @brief Updates the contents of all realized items. - */ - void updateRealizedItems(); - - private: - typedef void (IListViewListener::*ListenerMethod)(ListItem &item); - - public: - static void notifyListener(void *data, Evas_Object *obj, void *event_info, ListenerMethod method); - - private: - void createListView(Evas_Object *parent, Eext_Circle_Surface *parentCircleSurface); - - static void on_item_selected_cb(void *data, Evas_Object *obj, void *event_info); - static void on_realized_cb(void *data, Evas_Object *obj, void *event_info); - static void on_unrealized_cb(void *data, Evas_Object *obj, void *event_info); - static void on_longpressed_cb(void *data, Evas_Object *obj, void *event_info); - - private: - IListViewListener *m_pListener; - bool m_CheckMode; - CmpFunc m_CmpFunc; - Evas_Object *m_pCircleGenlist; - }; - - /** - * @brief A listener-interface aimed to make subscribers to get notified about genlist events. - */ - class IListViewListener - { - public: - virtual ~IListViewListener() {}; - - /** - * @brief Notification about insertion of new item into genlist. - * @param[in, out] listItem inserted item - */ - virtual void onListItemSelected(ListItem &listItem) {}; - - /** - * @brief Notification about genlist-item longpress event. - * @param[in, out] listItem lingpressed item - */ - virtual void onListItemLongPressed(ListItem &listItem) {}; - - /** - * @brief Notification occured after changing check-state of check-box placed on genlist-item. - * @param[in, out] listItem checked item - */ - virtual void onListItemChecked(ListItem &listItem) {}; - }; - - template - std::vector ListView::getItems() const - { - std::vector list; - list.reserve(elm_genlist_items_count(getEo())); - Elm_Object_Item *elmItem = elm_genlist_first_item_get(getEo()); - while (elmItem) - { - void *data = elm_object_item_data_get(elmItem); - if (data) - { - T *listItem = dynamic_cast(static_cast(data)); - if (listItem) - list.push_back(listItem); - } - elmItem = elm_genlist_item_next_get(elmItem); - } - - return list; - } - - template - unsigned ListView::getItemsCount() const - { - Elm_Object_Item *elmItem = elm_genlist_first_item_get(getEo()); - unsigned count = 0; - while (elmItem) - { - void *data = elm_object_item_data_get(elmItem); - if (data) - { - T *listItem = dynamic_cast(static_cast(data)); - if (listItem) - ++count; - } - elmItem = elm_genlist_item_next_get(elmItem); - } - return count; - } - - template - T *ListView::findNextItem(ListItem &item) const - { - T *res = nullptr; - ListItem *next = &item; - do - { - next = getNextItem(*next); - res = dynamic_cast(next); - } while (next && !res); - - return res; - } - - template - T *ListView::findPrevItem(ListItem &item) const - { - T *res = nullptr; - ListItem *prev = &item; - do - { - prev = getPrevItem(*prev); - res = dynamic_cast(prev); - } while (prev && !res); - - return res; - } - - template - bool ListView::hasItem() const - { - auto item = getFirstItem(); - if (item) - return findNextItem(*item) != nullptr; - return false; - } + class IListViewListener; + + /** + * @brief Wraps all basic genlist operations. + */ + class ListView + : public View + { + public: + /**@brief Function of comparing two list-items, used for sorted item insertion.*/ + typedef int (*CmpFunc)(const ListItem &item1, const ListItem &item2); + + public: + /** + * @brief A constructor of ListView object based on outside parent object. + * @param[in] parent an object responsible for automatic removing of ListView instance. + * @param[in] parent circle surface + */ + ListView(Evas_Object *parent, Eext_Circle_Surface *parentCircleSurface = nullptr); + virtual ~ListView(); + + /** + * @brief Sets subscriber that will be notified on list-view events. + * @param[in] listener a listener. + */ + void setListener(IListViewListener *listener); + + /** + * @brief Appends specified list-view item into list-view. + * @param[in] listItem an item to be appended. + * @param[in] parent a parent item. + * @return true in case of success, false otherwise. + */ + bool appendItem(ListItem &listItem, ListItem *parent = nullptr); + + /** + * @brief Inserts an item before another in a genlist widget + * @param[in] listItem an item to be appended. + * @param[in] before the item before which to place this new one + * @param[in] parent a parent item. + * @return true in case of success, false otherwise. + */ + bool insertBeforeItem(ListItem &listItem, ListItem &before, ListItem *parent = nullptr); + + /** + * @brief Prepends specified list-view item into list-view. + * @param[in] listItem an item to be prepended. + * @param[in] parent a parent item. + * @return true in case of success, false otherwise. + */ + bool prependItem(ListItem &listItem, ListItem *parent = nullptr); + + /** + * @brief Performs sorted item insertion. + * @param[in] listItem an item to be inserted. + * @param[in] parent a parent item. + * @return true in case of success, false otherwise. + */ + bool sortedInsertItem(ListItem &listItem, ListItem *parent = nullptr); + + /** + * @brief Sets item compare function to make work of sortedInsertItem() correct. + * @param[in] fn items compare function. + */ + void setCmpFunc(CmpFunc fn); + + /** + * @brief Deletes item from list-view. + * @param[in, out] listItem item to be deleted. + */ + void deleteItem(ListItem &listItem); + + /** + * @brief Gets all list-view items. + * @return list-view items. + */ + ListItemCollection getItems() const; + + /** + * @brief Gets realized list-view items. + * @return list-view items. + */ + ListItemCollection getRealizedItems() const; + + /** + * @brief Gets first list-view item. + * @return first list-view item. + */ + ListItem *getFirstItem() const; + + /** + * @brief Gets last list-view item. + * @return last list-view item. + */ + ListItem *getLastItem() const; + + /** + * @brief Shows list-view item. This causes list-view to jump to the given item @c it and show it (by jumping + * to that position), if it is not fully visible. + * @param[in] listItem an item to be shown. + * @param[in] type The position to bring in, the given item to. + */ + void showItem(ListItem &listItem, Elm_Genlist_Item_Scrollto_Type type); + + /** + * @brief Enables(disables) multiselection. + * @param[in] value if true enables multiselection, otherwise disables it. + */ + void setMultiSelection(bool value); + + /** + * @brief Checks whether multiselection is turned on or not. + * @return true if multiselection is enabled, otherwise false. + */ + bool getMultiSelection() const; + + /** + * @brief Removes all list-items. + */ + void clear(); + + /** + * @brief Checks whether list-view contains at least one item or not. + * @return true if list-view has no items, otherwise false. + */ + bool isEmpty() const; + + /** + * @brief Passes mode to nested genlist. + * @param[in] mode a mode to be applied. + */ + void setMode(Elm_List_Mode mode); + + /** + * @brief Enable(disable) genlist homogeneous mode. + * @param[in] isHomogeneous if true turns on homogeneous mode, otherwise turns it off. + */ + void setHomogeneous(bool isHomogeneous); + + /** + * @brief Gets selected view-item. + * @return selected list-view item or nullptr if no item is selected. + */ + ListItem *getSelectedItem() const; + + /** + * @brief Gets number of items. + * @return number of items. + */ + unsigned getItemsCount() const; + + /** + * @brief Gets list-view item next to specified one. + * @param[in] item an item in genlist. + * @return next item to the specified one. If there's no next item nullptr is returned. + */ + ListItem *getNextItem(ListItem &item) const; + + /** + * @brief Gets list-view item previous to specified one. + * @param[in] item an item in genlist. + * @return next item to the specified one. If there's no previous item nullptr is returned. + */ + ListItem *getPrevItem(ListItem &item) const; + + /** + * @brief Demotes specified list-view item to the end of the list. + * @param[in] item an item to be demoted. + */ + void demoteItem(ListItem &item); + + /** + * @brief Promotes specified list-view item to the begin of the list. + * @param[in] item an item to be promoted. + */ + void promoteItem(ListItem &item); + + /** + * @brief Set filter for items + * @param[in] key The filter key + */ + void setFilter(void *key); + + /** + * @brief Enables(disables selection mode). Makes all list-view items to show(hide) a check-box. + * @param[in] check if true makes all items to show checkbox, otherwise make them to hide it. + */ + void setCheckMode(bool check); + + /** + * @brief Checks wheather selection mode is enabled or not. + * @return true if selection mode is enabled, false otherwise. + */ + bool getCheckMode() const; + + /** + * @brief Checks(unchecks) all list-view items in selection mode and updates realized items. + * @param[in] check if true all items will be checked, if false - unchecks all items. + * @param[in] updateUi if true Ui will be forced update. + */ + void checkAllItems(bool check, bool updateUi = true); + + + /** + * @brief Sets the scroll item align state. + * @remarks If the object's scroll item align is enabled, the nearest + * item to the end of the scroll will be located according to + * its vertical align.1 + * @param[in] enabled The scroll item align state + */ + void enabledAlign(bool enabled); + + void setRealizationMode(bool mode); + + template + std::vector getItems() const; + + template + unsigned getItemsCount() const; + + template + bool hasItem() const; + + template + T *findNextItem(ListItem &item) const; + + template + T *findPrevItem(ListItem &item) const; + + /** + * @brief Gets all checked items count. + * @return count of checked items. + */ + unsigned getCheckedItemsCount() const; + + /** + * @brief Gets all checkable items count. + * @return count of checkable items. + */ + unsigned getCheckableItemsCount() const; + + /** + * @brief Updates the contents of all realized items. + */ + void updateRealizedItems(); + + private: + typedef void (IListViewListener::*ListenerMethod)(ListItem &item); + + public: + static void notifyListener(void *data, Evas_Object *obj, void *event_info, ListenerMethod method); + + private: + void createListView(Evas_Object *parent, Eext_Circle_Surface *parentCircleSurface); + + static void on_item_selected_cb(void *data, Evas_Object *obj, void *event_info); + static void on_realized_cb(void *data, Evas_Object *obj, void *event_info); + static void on_unrealized_cb(void *data, Evas_Object *obj, void *event_info); + static void on_longpressed_cb(void *data, Evas_Object *obj, void *event_info); + + private: + IListViewListener *m_pListener; + bool m_CheckMode; + CmpFunc m_CmpFunc; + Evas_Object *m_pCircleGenlist; + }; + + /** + * @brief A listener-interface aimed to make subscribers to get notified about genlist events. + */ + class IListViewListener + { + public: + virtual ~IListViewListener() {}; + + /** + * @brief Notification about insertion of new item into genlist. + * @param[in, out] listItem inserted item + */ + virtual void onListItemSelected(ListItem &listItem) {}; + + /** + * @brief Notification about genlist-item longpress event. + * @param[in, out] listItem lingpressed item + */ + virtual void onListItemLongPressed(ListItem &listItem) {}; + + /** + * @brief Notification occured after changing check-state of check-box placed on genlist-item. + * @param[in, out] listItem checked item + */ + virtual void onListItemChecked(ListItem &listItem) {}; + }; + + template + std::vector ListView::getItems() const + { + std::vector list; + list.reserve(elm_genlist_items_count(getEo())); + Elm_Object_Item *elmItem = elm_genlist_first_item_get(getEo()); + while (elmItem) + { + void *data = elm_object_item_data_get(elmItem); + if (data) + { + T *listItem = dynamic_cast(static_cast(data)); + if (listItem) + list.push_back(listItem); + } + elmItem = elm_genlist_item_next_get(elmItem); + } + + return list; + } + + template + unsigned ListView::getItemsCount() const + { + Elm_Object_Item *elmItem = elm_genlist_first_item_get(getEo()); + unsigned count = 0; + while (elmItem) + { + void *data = elm_object_item_data_get(elmItem); + if (data) + { + T *listItem = dynamic_cast(static_cast(data)); + if (listItem) + ++count; + } + elmItem = elm_genlist_item_next_get(elmItem); + } + return count; + } + + template + T *ListView::findNextItem(ListItem &item) const + { + T *res = nullptr; + ListItem *next = &item; + do + { + next = getNextItem(*next); + res = dynamic_cast(next); + } while (next && !res); + + return res; + } + + template + T *ListView::findPrevItem(ListItem &item) const + { + T *res = nullptr; + ListItem *prev = &item; + do + { + prev = getPrevItem(*prev); + res = dynamic_cast(prev); + } while (prev && !res); + + return res; + } + + template + bool ListView::hasItem() const + { + auto item = getFirstItem(); + if (item) + return findNextItem(*item) != nullptr; + return false; + } } #endif // ListView_15152b60_4142_11b3_aa6e_080a200c9a62_h_ diff --git a/src/Common/View/inc/MbeRecipientViewItem.h b/src/Common/View/inc/MbeRecipientViewItem.h index 3d54c21..d3a8e3c 100644 --- a/src/Common/View/inc/MbeRecipientViewItem.h +++ b/src/Common/View/inc/MbeRecipientViewItem.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -22,99 +22,99 @@ namespace Msg { - class MbeRecipientsView; - - /** - * @brief Wraps all basic multibutton entry item operations. - */ - class MbeRecipientItem - : public ViewItem - { - friend class MbeRecipientsView; - - public: - /** - * @brief Constructs instance of MbeRecipientItem with a specified display-name, address etc. - * @param[in] address recipient-address(phone number or email). - * @param[in] dispName displayable mbe-item text. - * @param[in] addressType type of recipient address. - * @param[in] recipType type of recipient. - */ - MbeRecipientItem(const std::string &address, const std::string &dispName, - MsgAddress::AddressType addressType, MsgAddress::RecipientType recipType = MsgAddress::To); - - /** - * @brief Gets recipient's display-name. - * @return display-name. - */ - const std::string &getDispName() const; - - /** - * @brief Gets recipient address. - * @return recipient address. - */ - const std::string &getAddress() const; - - /** - * @brief Gets address-type. - * @return address-type. - */ - MsgAddress::AddressType getAddressType() const; - - /** - * @brief Gets recipient type. - * @return recipient type. - */ - MsgAddress::RecipientType getRecipType() const; - - /** - * @brief Sets new display name. - * @param[in] dispName new display name. - */ - void setDispName(const std::string &dispName); - - private: - std::string m_Address; - std::string m_DispName; - MsgAddress::AddressType m_AddressType; - MsgAddress::RecipientType m_RecipType; - }; - - inline MbeRecipientItem::MbeRecipientItem(const std::string &address, const std::string &dispName, - MsgAddress::AddressType addressType, MsgAddress::RecipientType recipType) - : m_Address(address) - , m_DispName(dispName) - , m_AddressType(addressType) - , m_RecipType(recipType) - { - } - - inline const std::string &MbeRecipientItem::getDispName() const - { - return m_DispName; - } - - inline const std::string &MbeRecipientItem::getAddress() const - { - return m_Address; - } - - inline MsgAddress::AddressType MbeRecipientItem::getAddressType() const - { - return m_AddressType; - } - - inline MsgAddress::RecipientType MbeRecipientItem::getRecipType() const - { - return m_RecipType; - } - - inline void MbeRecipientItem::setDispName(const std::string &dispName) - { - m_DispName = dispName; - if (getElmObjItem()) - setText(dispName); - } + class MbeRecipientsView; + + /** + * @brief Wraps all basic multibutton entry item operations. + */ + class MbeRecipientItem + : public ViewItem + { + friend class MbeRecipientsView; + + public: + /** + * @brief Constructs instance of MbeRecipientItem with a specified display-name, address etc. + * @param[in] address recipient-address(phone number or email). + * @param[in] dispName displayable mbe-item text. + * @param[in] addressType type of recipient address. + * @param[in] recipType type of recipient. + */ + MbeRecipientItem(const std::string &address, const std::string &dispName, + MsgAddress::AddressType addressType, MsgAddress::RecipientType recipType = MsgAddress::To); + + /** + * @brief Gets recipient's display-name. + * @return display-name. + */ + const std::string &getDispName() const; + + /** + * @brief Gets recipient address. + * @return recipient address. + */ + const std::string &getAddress() const; + + /** + * @brief Gets address-type. + * @return address-type. + */ + MsgAddress::AddressType getAddressType() const; + + /** + * @brief Gets recipient type. + * @return recipient type. + */ + MsgAddress::RecipientType getRecipType() const; + + /** + * @brief Sets new display name. + * @param[in] dispName new display name. + */ + void setDispName(const std::string &dispName); + + private: + std::string m_Address; + std::string m_DispName; + MsgAddress::AddressType m_AddressType; + MsgAddress::RecipientType m_RecipType; + }; + + inline MbeRecipientItem::MbeRecipientItem(const std::string &address, const std::string &dispName, + MsgAddress::AddressType addressType, MsgAddress::RecipientType recipType) + : m_Address(address) + , m_DispName(dispName) + , m_AddressType(addressType) + , m_RecipType(recipType) + { + } + + inline const std::string &MbeRecipientItem::getDispName() const + { + return m_DispName; + } + + inline const std::string &MbeRecipientItem::getAddress() const + { + return m_Address; + } + + inline MsgAddress::AddressType MbeRecipientItem::getAddressType() const + { + return m_AddressType; + } + + inline MsgAddress::RecipientType MbeRecipientItem::getRecipType() const + { + return m_RecipType; + } + + inline void MbeRecipientItem::setDispName(const std::string &dispName) + { + m_DispName = dispName; + if (getElmObjItem()) + setText(dispName); + } } #endif /* MbeRecipientItem_h_ */ diff --git a/src/Common/View/inc/MbeRecipientsView.h b/src/Common/View/inc/MbeRecipientsView.h index 4d6ad00..e0271ea 100644 --- a/src/Common/View/inc/MbeRecipientsView.h +++ b/src/Common/View/inc/MbeRecipientsView.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -24,84 +24,84 @@ namespace Msg { - class IMbeRecipientsListener; - - /** - * @brief Wraps all basic multibutton entry(mbe) operations. - */ - class MbeRecipientsView - : public View - { - public: - MbeRecipientsView(Evas_Object *parent); - virtual ~MbeRecipientsView(); - - /** - * @brief Appends new item into mbe. - * @param[in] item new item to be appended. - */ - void appendItem(MbeRecipientItem &item); - - /** - * @brief Gets number of mbe items. - * @return items count. - */ - int getItemsCount() const; - - /** - * @brief Gets mbe items collection. - * @return mbe items. - */ - std::vector getItems() const; - - /** - * @brief Gets mbe's selected item. - * @return selected item or nullptr if no item is selected. - */ - MbeRecipientItem *getSelectedItem() const; - - /** - * @brief Checks whether mbe is empty or not. - * @return true if mbe is empty false otherwise. - */ - bool isEmpty() const; - - /** - * @brief Removes all mbe items. - */ - void clear(); - - void setListener(IMbeRecipientsListener *pListener); - private: - void onMbeItemClicked(Evas_Object *obj, void *eventInfo); - void onMbeChanged(Evas_Object *obj, void *eventInfo); - - - private: - IMbeRecipientsListener *m_pListener; - MbeRecipientItem *m_pSelectedItem; - Ecore_Job *m_pChangedJob; - }; - - /** - * @brief A listener class that should be implemented by all mbe event subscribers. - */ - class IMbeRecipientsListener - { - public: - virtual ~IMbeRecipientsListener() {}; - - /** - * @brief Notification about some mbe item being clicked. - * @param[in] item clicked item. - */ - virtual void onMbeItemClicked(MbeRecipientItem &item) {}; - - /** - * @brief Notification about mbe content being changed(Item was added or deleted). - */ - virtual void onMbeChanged() {}; - }; + class IMbeRecipientsListener; + + /** + * @brief Wraps all basic multibutton entry(mbe) operations. + */ + class MbeRecipientsView + : public View + { + public: + MbeRecipientsView(Evas_Object *parent); + virtual ~MbeRecipientsView(); + + /** + * @brief Appends new item into mbe. + * @param[in] item new item to be appended. + */ + void appendItem(MbeRecipientItem &item); + + /** + * @brief Gets number of mbe items. + * @return items count. + */ + int getItemsCount() const; + + /** + * @brief Gets mbe items collection. + * @return mbe items. + */ + std::vector getItems() const; + + /** + * @brief Gets mbe's selected item. + * @return selected item or nullptr if no item is selected. + */ + MbeRecipientItem *getSelectedItem() const; + + /** + * @brief Checks whether mbe is empty or not. + * @return true if mbe is empty false otherwise. + */ + bool isEmpty() const; + + /** + * @brief Removes all mbe items. + */ + void clear(); + + void setListener(IMbeRecipientsListener *pListener); + private: + void onMbeItemClicked(Evas_Object *obj, void *eventInfo); + void onMbeChanged(Evas_Object *obj, void *eventInfo); + + + private: + IMbeRecipientsListener *m_pListener; + MbeRecipientItem *m_pSelectedItem; + Ecore_Job *m_pChangedJob; + }; + + /** + * @brief A listener class that should be implemented by all mbe event subscribers. + */ + class IMbeRecipientsListener + { + public: + virtual ~IMbeRecipientsListener() {}; + + /** + * @brief Notification about some mbe item being clicked. + * @param[in] item clicked item. + */ + virtual void onMbeItemClicked(MbeRecipientItem &item) {}; + + /** + * @brief Notification about mbe content being changed(Item was added or deleted). + */ + virtual void onMbeChanged() {}; + }; } #endif /* MbeRecipientsView_h_ */ diff --git a/src/Common/View/inc/MoreOption.h b/src/Common/View/inc/MoreOption.h index ee036f9..ace1f94 100644 --- a/src/Common/View/inc/MoreOption.h +++ b/src/Common/View/inc/MoreOption.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -24,67 +24,67 @@ #include namespace Msg { - class MoreOption; - typedef void (*MoreOptionCb)(MoreOption &obj, void *userData); - - class MoreOption - : public View { - - public: - MoreOption(Evas_Object *parent); - virtual ~MoreOption(); - - Eext_Object_Item *appendItem(const TText &mainText, - Evas_Object *icon, - MoreOptionCb cb, - void *userData); - - Eext_Object_Item *appendItem(const TText &mainText, - const std::string &imgGroupName, - MoreOptionCb cb, - void *userData); - - Eext_Object_Item *prependItem(const TText &mainText, - Evas_Object *icon, - MoreOptionCb cb, - void *userData); - - Eext_Object_Item *prependItem(const TText &mainText, - const std::string &imgGroupName, - MoreOptionCb cb, - void *userData); - - void removeItem(Eext_Object_Item *item); - void setDirection(Eext_More_Option_Direction direction); - void setOpened(bool opened); - bool getOpened() const; - void addOpenedCb(Evas_Smart_Cb cb, void *data); - void addClosedCb(Evas_Smart_Cb cb, void *data); - - private: - void onItemClicked(Evas_Object *obj, void *event); - void onItemSelected(Evas_Object *obj, void *event); - - void prepareItem(Eext_Object_Item *item, - const TText &mainText, - Evas_Object *icon, - MoreOptionCb cb, - void *userData); - - void prepareItem(Eext_Object_Item *item, - const TText &mainText, - const std::string &imgGroupName, - MoreOptionCb cb, - void *userData); - - struct ItemData { - MoreOptionCb cb; - void *userData; - }; - - private: - std::map m_ItemMap; - }; + class MoreOption; + typedef void (*MoreOptionCb)(MoreOption &obj, void *userData); + + class MoreOption + : public View { + + public: + MoreOption(Evas_Object *parent); + virtual ~MoreOption(); + + Eext_Object_Item *appendItem(const TText &mainText, + Evas_Object *icon, + MoreOptionCb cb, + void *userData); + + Eext_Object_Item *appendItem(const TText &mainText, + const std::string &imgGroupName, + MoreOptionCb cb, + void *userData); + + Eext_Object_Item *prependItem(const TText &mainText, + Evas_Object *icon, + MoreOptionCb cb, + void *userData); + + Eext_Object_Item *prependItem(const TText &mainText, + const std::string &imgGroupName, + MoreOptionCb cb, + void *userData); + + void removeItem(Eext_Object_Item *item); + void setDirection(Eext_More_Option_Direction direction); + void setOpened(bool opened); + bool getOpened() const; + void addOpenedCb(Evas_Smart_Cb cb, void *data); + void addClosedCb(Evas_Smart_Cb cb, void *data); + + private: + void onItemClicked(Evas_Object *obj, void *event); + void onItemSelected(Evas_Object *obj, void *event); + + void prepareItem(Eext_Object_Item *item, + const TText &mainText, + Evas_Object *icon, + MoreOptionCb cb, + void *userData); + + void prepareItem(Eext_Object_Item *item, + const TText &mainText, + const std::string &imgGroupName, + MoreOptionCb cb, + void *userData); + + struct ItemData { + MoreOptionCb cb; + void *userData; + }; + + private: + std::map m_ItemMap; + }; } #endif /* MoreOption_h_ */ diff --git a/src/Common/View/inc/NaviFrameItem.h b/src/Common/View/inc/NaviFrameItem.h index b4a7170..d128295 100644 --- a/src/Common/View/inc/NaviFrameItem.h +++ b/src/Common/View/inc/NaviFrameItem.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -27,65 +27,65 @@ namespace Msg { - class NaviFrameView; - class NaviFrameItem; - typedef std::vector NaviFrameItemList; + class NaviFrameView; + class NaviFrameItem; + typedef std::vector NaviFrameItemList; - /** - * @brief Wraps all basic Naviframe-item operations. - */ - class NaviFrameItem - : public ViewItem - { - friend class NaviFrameView; + /** + * @brief Wraps all basic Naviframe-item operations. + */ + class NaviFrameItem + : public ViewItem + { + friend class NaviFrameView; - public: - typedef void (*PopCb)(NaviFrameItem &, void *); + public: + typedef void (*PopCb)(NaviFrameItem &, void *); - public: - /** - * A constructor of NaviFrameItem object based on outside parent object. Creates nested navibar. - * @param[in] owner an object responsible for automatic removing of NaviFrameItem instance. - */ - NaviFrameItem(NaviFrameView &parent); - virtual ~NaviFrameItem(); + public: + /** + * A constructor of NaviFrameItem object based on outside parent object. Creates nested navibar. + * @param[in] owner an object responsible for automatic removing of NaviFrameItem instance. + */ + NaviFrameItem(NaviFrameView &parent); + virtual ~NaviFrameItem(); - public: - /** - * @brief Gets NaviframeView that owns this item. - * @return owner of this item. - */ - NaviFrameView &getParent(); - const NaviFrameView &getParent() const; + public: + /** + * @brief Gets NaviframeView that owns this item. + * @return owner of this item. + */ + NaviFrameView &getParent(); + const NaviFrameView &getParent() const; - /** - * @brief Gets popping status - * @return true if current frame is popping and will be destroyed, false otherwise. - */ - bool isPopping() const; + /** + * @brief Gets popping status + * @return true if current frame is popping and will be destroyed, false otherwise. + */ + bool isPopping() const; - /** - * @brief Set pop callback (called before start pop) - * @param cb pop callback - * @param data user data - */ - void setOnPopCb(PopCb cb, void *data); + /** + * @brief Set pop callback (called before start pop) + * @param cb pop callback + * @param data user data + */ + void setOnPopCb(PopCb cb, void *data); - protected: - virtual bool onRequestPop(); + protected: + virtual bool onRequestPop(); - //ViewItem - void onAttached(ViewItem &item) override; - virtual void onTransitionFinished(NaviFrameItem &item) {}; + //ViewItem + void onAttached(ViewItem &item) override; + virtual void onTransitionFinished(NaviFrameItem &item) {}; - void notifyOnPop(); + void notifyOnPop(); - private: - NaviFrameView &m_Parent; - bool m_IsPopping; - PopCb m_pPopCb; - void *m_pPopCbData; - }; + private: + NaviFrameView &m_Parent; + bool m_IsPopping; + PopCb m_pPopCb; + void *m_pPopCbData; + }; } #endif /* NaviFrameItem_h_ */ diff --git a/src/Common/View/inc/NaviFrameView.h b/src/Common/View/inc/NaviFrameView.h index 2b5760d..92baed1 100644 --- a/src/Common/View/inc/NaviFrameView.h +++ b/src/Common/View/inc/NaviFrameView.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -23,94 +23,94 @@ namespace Msg { - /** - * @brief Wraps all basic Naviframe operations. - */ - class NaviFrameView - : public View - { - public: - NaviFrameView(Evas_Object *parent); - NaviFrameView(View &parent); - virtual ~NaviFrameView(); - - /** - * @brief Checks is it last frame. - */ - bool isLastFrame() const; - - /** - * @brief Get count of pushed frames. - */ - unsigned getItemsCount() const; - /** - * @brief Get list of pushed frames. - */ - NaviFrameItemList getItems() const; - - /** - * @brief Checks if any frame was pushed. - */ - bool isEmpty() const; - - /** - * @brief Pushes new frame. Attaches @content to frame. Updates @item with created frame. - */ - void push(NaviFrameItem &item); - - /** - * @brief Pops top item from Naviframe. - */ - void pop(); - - /** - * @brief Pops item from Naviframe. - * @param[in] item NaviFrame item for pop. - */ - void pop(NaviFrameItem &item); - - /** - * @brief Inserts specified item to bottom of item's stack. - * @param[in] item an item to be inserted. - */ - void insertToBottom(NaviFrameItem &item); - - /** - * @brief Promote an item already in the naviframe stack to the top of the stack - * @param[in] item an item to be promoted. - */ - void promote(NaviFrameItem &item); - - /** - * @brief Gets top frame from items-stack. - * @return Top naviframe-item or nullptr if item-stack is empty. - */ - NaviFrameItem *getTopFrame() const; - - /** - * Checks if item transition is in progress. - * @return true if transition is in progress, false otherwise. - */ - bool getTransitionStatus() const; - - - void destroy(); - - protected: - virtual void onPause(NaviFrameItem &item) {}; - virtual void onResume(NaviFrameItem &item) {}; - void onBeforeDelete(View &view) override; - - private: - void create(Evas_Object *parent); - void pause(); - void resume(); - void onTransitionFinished(Evas_Object *obj, void *eventInfo); - - private: - bool m_TransitionStatus; - std::vector m_ItemsToDelete; - }; + /** + * @brief Wraps all basic Naviframe operations. + */ + class NaviFrameView + : public View + { + public: + NaviFrameView(Evas_Object *parent); + NaviFrameView(View &parent); + virtual ~NaviFrameView(); + + /** + * @brief Checks is it last frame. + */ + bool isLastFrame() const; + + /** + * @brief Get count of pushed frames. + */ + unsigned getItemsCount() const; + /** + * @brief Get list of pushed frames. + */ + NaviFrameItemList getItems() const; + + /** + * @brief Checks if any frame was pushed. + */ + bool isEmpty() const; + + /** + * @brief Pushes new frame. Attaches @content to frame. Updates @item with created frame. + */ + void push(NaviFrameItem &item); + + /** + * @brief Pops top item from Naviframe. + */ + void pop(); + + /** + * @brief Pops item from Naviframe. + * @param[in] item NaviFrame item for pop. + */ + void pop(NaviFrameItem &item); + + /** + * @brief Inserts specified item to bottom of item's stack. + * @param[in] item an item to be inserted. + */ + void insertToBottom(NaviFrameItem &item); + + /** + * @brief Promote an item already in the naviframe stack to the top of the stack + * @param[in] item an item to be promoted. + */ + void promote(NaviFrameItem &item); + + /** + * @brief Gets top frame from items-stack. + * @return Top naviframe-item or nullptr if item-stack is empty. + */ + NaviFrameItem *getTopFrame() const; + + /** + * Checks if item transition is in progress. + * @return true if transition is in progress, false otherwise. + */ + bool getTransitionStatus() const; + + + void destroy(); + + protected: + virtual void onPause(NaviFrameItem &item) {}; + virtual void onResume(NaviFrameItem &item) {}; + void onBeforeDelete(View &view) override; + + private: + void create(Evas_Object *parent); + void pause(); + void resume(); + void onTransitionFinished(Evas_Object *obj, void *eventInfo); + + private: + bool m_TransitionStatus; + std::vector m_ItemsToDelete; + }; } #endif /* NaviFrameView_h_ */ diff --git a/src/Common/View/inc/NoContentLayout.h b/src/Common/View/inc/NoContentLayout.h index c0c4072..6e943f0 100644 --- a/src/Common/View/inc/NoContentLayout.h +++ b/src/Common/View/inc/NoContentLayout.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -23,20 +23,20 @@ namespace Msg { - /** - * @brief A Layout that shows a message text when ThreadList is empty - */ - class NoContentLayout - : public View { - public: - NoContentLayout(Evas_Object *parent); - virtual ~NoContentLayout(); + /** + * @brief A Layout that shows a message text when ThreadList is empty + */ + class NoContentLayout + : public View { + public: + NoContentLayout(Evas_Object *parent); + virtual ~NoContentLayout(); - void setTitle(const TText &text); - void setText(const TText &text); - void enableTitle(bool enable); - void setIcon(Evas_Object *icon); - }; + void setTitle(const TText &text); + void setText(const TText &text); + void enableTitle(bool enable); + void setIcon(Evas_Object *icon); + }; } #endif /* NoContentLayout_h_ */ diff --git a/src/Common/View/inc/PaddingListViewItem.h b/src/Common/View/inc/PaddingListViewItem.h index eefdb39..fff7662 100644 --- a/src/Common/View/inc/PaddingListViewItem.h +++ b/src/Common/View/inc/PaddingListViewItem.h @@ -20,26 +20,26 @@ #include "ListItem.h" namespace Msg { - class PaddingListViewItem - : public ListItem { - - public: - PaddingListViewItem(); - - protected: - void onAttached(ViewItem &item) override; - }; - - inline PaddingListViewItem::PaddingListViewItem() - : ListItem(ListItemStyle::create("padding")) - { - } - - inline void PaddingListViewItem::onAttached(ViewItem &item) - { - setSelectable(false); - getAtspi().canHighlight(false); - } + class PaddingListViewItem + : public ListItem { + + public: + PaddingListViewItem(); + + protected: + void onAttached(ViewItem &item) override; + }; + + inline PaddingListViewItem::PaddingListViewItem() + : ListItem(ListItemStyle::create("padding")) + { + } + + inline void PaddingListViewItem::onAttached(ViewItem &item) + { + setSelectable(false); + getAtspi().canHighlight(false); + } } #endif // PaddingListViewItem_h_ diff --git a/src/Common/View/inc/Popup.h b/src/Common/View/inc/Popup.h index 7835513..f8a693d 100644 --- a/src/Common/View/inc/Popup.h +++ b/src/Common/View/inc/Popup.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -21,46 +21,46 @@ namespace Msg { - class Popup; - typedef void (*PopupButtonCb)(Popup &popup, void *userData); + class Popup; + typedef void (*PopupButtonCb)(Popup &popup, void *userData); - class Popup - : public BasePopup { + class Popup + : public BasePopup { - public: - static void defaultButtonCb(Popup &popup, void *userData); - static const double defaultTimeOut; + public: + static void defaultButtonCb(Popup &popup, void *userData); + static const double defaultTimeOut; - public: - Popup(); - virtual ~Popup(); + public: + Popup(); + virtual ~Popup(); - void show(bool deferred = true); - void setTitle(const TText &title); - void setTimeOut(double timeout = defaultTimeOut); - double getTimeOut() const; + void show(bool deferred = true); + void setTitle(const TText &title); + void setTimeOut(double timeout = defaultTimeOut); + double getTimeOut() const; - Evas_Object *addBottomButton(const TText &text, PopupButtonCb cb = defaultButtonCb, void *userData = nullptr); - Evas_Object *addBottomButton(const char *iconName, PopupButtonCb cb = defaultButtonCb, void *userData = nullptr); - Evas_Object *addLeftButton(const char *iconName, PopupButtonCb cb = defaultButtonCb, void *userData = nullptr); - Evas_Object *addRightButton(const char *iconName, PopupButtonCb cb = defaultButtonCb, void *userData = nullptr); + Evas_Object *addBottomButton(const TText &text, PopupButtonCb cb = defaultButtonCb, void *userData = nullptr); + Evas_Object *addBottomButton(const char *iconName, PopupButtonCb cb = defaultButtonCb, void *userData = nullptr); + Evas_Object *addLeftButton(const char *iconName, PopupButtonCb cb = defaultButtonCb, void *userData = nullptr); + Evas_Object *addRightButton(const char *iconName, PopupButtonCb cb = defaultButtonCb, void *userData = nullptr); - protected: - Evas_Object *addButton(const char *part, PopupButtonCb buttonCb, void *userData); - Evas_Object *addButton(const TText &text, const char *iconName, const char *part, PopupButtonCb buttonCb, void *userData); - void dismiss() override; + protected: + Evas_Object *addButton(const char *part, PopupButtonCb buttonCb, void *userData); + Evas_Object *addButton(const TText &text, const char *iconName, const char *part, PopupButtonCb buttonCb, void *userData); + void dismiss() override; - private: - Evas_Object *createIcon(Evas_Object *) const; - static void on_button_clicked(void *data, Evas_Object *obj, void *event_info); - static void on_popup_block_clicked_cb(void *data, Evas_Object *obj, void *event_info); - static void on_timeout_cb(void *data, Evas_Object *obj, void *event_info); - static void on_dismissed_cb(void *data, Evas_Object *obj, void *event_info); + private: + Evas_Object *createIcon(Evas_Object *) const; + static void on_button_clicked(void *data, Evas_Object *obj, void *event_info); + static void on_popup_block_clicked_cb(void *data, Evas_Object *obj, void *event_info); + static void on_timeout_cb(void *data, Evas_Object *obj, void *event_info); + static void on_dismissed_cb(void *data, Evas_Object *obj, void *event_info); - private: - Ecore_Idler *m_pShowIdler; - }; + private: + Ecore_Idler *m_pShowIdler; + }; } #endif /* Popup_h_ */ diff --git a/src/Common/View/inc/PopupAttachmentListItem.h b/src/Common/View/inc/PopupAttachmentListItem.h index 5b3b2fb..8508826 100644 --- a/src/Common/View/inc/PopupAttachmentListItem.h +++ b/src/Common/View/inc/PopupAttachmentListItem.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -22,22 +22,22 @@ namespace Msg { - /** - * @brief A class of popup-for attach files - */ - class PopupAttachmentListItem - : public PopupCheckListItem - { - public: - PopupAttachmentListItem(PopupList &parent, const std::string &text, const std::string &path, - PopupListItemPressedCb cb, void *userData); - virtual ~PopupAttachmentListItem(); + /** + * @brief A class of popup-for attach files + */ + class PopupAttachmentListItem + : public PopupCheckListItem + { + public: + PopupAttachmentListItem(PopupList &parent, const std::string &text, const std::string &path, + PopupListItemPressedCb cb, void *userData); + virtual ~PopupAttachmentListItem(); - public: - const std::string &getFilePath() const; + public: + const std::string &getFilePath() const; - private: - std::string m_FilePath; - }; + private: + std::string m_FilePath; + }; } #endif /* PopupAttachmentListItem_h_ */ diff --git a/src/Common/View/inc/PopupList.h b/src/Common/View/inc/PopupList.h index cc1d9b2..856d6db 100644 --- a/src/Common/View/inc/PopupList.h +++ b/src/Common/View/inc/PopupList.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -23,56 +23,56 @@ namespace Msg { - /** - * @brief A popup with list of available popup items. - */ - class PopupList - : public Popup - , private IListViewListener - { - public: - PopupList(); - virtual ~PopupList(); + /** + * @brief A popup with list of available popup items. + */ + class PopupList + : public Popup + , private IListViewListener + { + public: + PopupList(); + virtual ~PopupList(); - /** - * @brief Appends specified existing item to popup list. - * @param[in] item an item created outside to be appended. - */ - void appendItem(PopupListItem &item); + /** + * @brief Appends specified existing item to popup list. + * @param[in] item an item created outside to be appended. + */ + void appendItem(PopupListItem &item); - /** - * @brief Creates an item with a single string based on specified parameters and appends it to popup list. - * @param[in] text a text displayed on popup list item. - * @param[in] cb a callback raised by tap on this item. - * @param[in] userData user data passed to item's on-press callback. - */ - void appendItem(const std::string &text, PopupListItemPressedCb cb, void *userData); + /** + * @brief Creates an item with a single string based on specified parameters and appends it to popup list. + * @param[in] text a text displayed on popup list item. + * @param[in] cb a callback raised by tap on this item. + * @param[in] userData user data passed to item's on-press callback. + */ + void appendItem(const std::string &text, PopupListItemPressedCb cb, void *userData); - /** - * Creates an item with a single string and a stored filepath based on specified parameters and appends it to popup list. - * @param[in] text a text displayed on popup list item. - * @param[in] path filepath. - * @param[in] cb a callback raised by tap on this item. - * @param[in] userData user data passed to item's on-press callback. - */ - void appendItem(const std::string &text, const std::string &path, PopupListItemPressedCb cb, void *userData); + /** + * Creates an item with a single string and a stored filepath based on specified parameters and appends it to popup list. + * @param[in] text a text displayed on popup list item. + * @param[in] path filepath. + * @param[in] cb a callback raised by tap on this item. + * @param[in] userData user data passed to item's on-press callback. + */ + void appendItem(const std::string &text, const std::string &path, PopupListItemPressedCb cb, void *userData); - /** - * @brief Gets nested list-view. - * @return list-view. - */ - ListView &getListView(); - const ListView &getListView() const; + /** + * @brief Gets nested list-view. + * @return list-view. + */ + ListView &getListView(); + const ListView &getListView() const; - private: - void onListItemSelected(ListItem &listItem) override; + private: + void onListItemSelected(ListItem &listItem) override; - void create(); - Evas_Object *createList(Evas_Object *parent); + void create(); + Evas_Object *createList(Evas_Object *parent); - private: - ListView *m_pList; - }; + private: + ListView *m_pList; + }; } #endif /* PopupList_h_ */ diff --git a/src/Common/View/inc/PopupListItem.h b/src/Common/View/inc/PopupListItem.h index 938a798..a220c49 100644 --- a/src/Common/View/inc/PopupListItem.h +++ b/src/Common/View/inc/PopupListItem.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -21,60 +21,60 @@ namespace Msg { - class PopupList; - class PopupListItem; + class PopupList; + class PopupListItem; - /** @brief Callback raised when popup-list item was clicked.*/ - typedef void (*PopupListItemPressedCb)(PopupListItem &item, void *userData); - #define POPUPLIST_ITEM_PRESSED_CB(ClassName, method) [](PopupListItem &item, void *userData) \ - { \ - static_cast(userData)->method(item); \ - } + /** @brief Callback raised when popup-list item was clicked.*/ + typedef void (*PopupListItemPressedCb)(PopupListItem &item, void *userData); + #define POPUPLIST_ITEM_PRESSED_CB(ClassName, method) [](PopupListItem &item, void *userData) \ + { \ + static_cast(userData)->method(item); \ + } - /** - * @brief Generic Popup-list item class - */ - class PopupListItem: public ListItem - { - public: - PopupListItem(PopupList &parent, PopupListItemPressedCb cb, void *userData); - PopupList &getParent(); - void fireCallback(); - private: - PopupList &m_Parent; - PopupListItemPressedCb m_Cb; - void *m_pUserData; - }; + /** + * @brief Generic Popup-list item class + */ + class PopupListItem: public ListItem + { + public: + PopupListItem(PopupList &parent, PopupListItemPressedCb cb, void *userData); + PopupList &getParent(); + void fireCallback(); + private: + PopupList &m_Parent; + PopupListItemPressedCb m_Cb; + void *m_pUserData; + }; - /** - * @brief A class of popup-item with single text displayed. - */ - class PopupTextListItem: public PopupListItem - { - public: - PopupTextListItem(PopupList &parent, const std::string &text, PopupListItemPressedCb cb, void *userData); - virtual ~PopupTextListItem(); - private: - std::string getText(ListItem &item, const char *part) override; - private: - std::string m_Text; - }; + /** + * @brief A class of popup-item with single text displayed. + */ + class PopupTextListItem: public PopupListItem + { + public: + PopupTextListItem(PopupList &parent, const std::string &text, PopupListItemPressedCb cb, void *userData); + virtual ~PopupTextListItem(); + private: + std::string getText(ListItem &item, const char *part) override; + private: + std::string m_Text; + }; - /** - * @brief A class of popup-item with text and check field. - */ - class PopupCheckListItem: public PopupListItem - { - public: - PopupCheckListItem(PopupList &parent, const std::string &text, PopupListItemPressedCb cb, void *userData); - virtual ~PopupCheckListItem(); + /** + * @brief A class of popup-item with text and check field. + */ + class PopupCheckListItem: public PopupListItem + { + public: + PopupCheckListItem(PopupList &parent, const std::string &text, PopupListItemPressedCb cb, void *userData); + virtual ~PopupCheckListItem(); - private: - const char *getCheckPart(ListItem &item) override; - std::string getText(ListItem &item, const char *part) override; - private: - std::string m_Text; - }; + private: + const char *getCheckPart(ListItem &item) override; + std::string getText(ListItem &item, const char *part) override; + private: + std::string m_Text; + }; } #endif /* PopupListItem_h_ */ diff --git a/src/Common/View/inc/PopupManager.h b/src/Common/View/inc/PopupManager.h index 770476a..91d4814 100644 --- a/src/Common/View/inc/PopupManager.h +++ b/src/Common/View/inc/PopupManager.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -24,61 +24,61 @@ #include namespace Msg { - class Window; - class IPopupManagerListener; + class Window; + class IPopupManagerListener; - /** - * @brief A global instance that manages context popups and regular popups lifecycle in context of one window. - */ - class PopupManager { - public: - /** - * @brief Creating PopupManager instance in context of specified window. - * @param[in] window a window context. - */ - PopupManager(Window &window); - ~PopupManager(); + /** + * @brief A global instance that manages context popups and regular popups lifecycle in context of one window. + */ + class PopupManager { + public: + /** + * @brief Creating PopupManager instance in context of specified window. + * @param[in] window a window context. + */ + PopupManager(Window &window); + ~PopupManager(); - PopupManager(PopupManager&) = delete; - PopupManager &operator=(PopupManager&) = delete; + PopupManager(PopupManager&) = delete; + PopupManager &operator=(PopupManager&) = delete; - void addListener(IPopupManagerListener &listener); - void removeListener(IPopupManagerListener &listener); + void addListener(IPopupManagerListener &listener); + void removeListener(IPopupManagerListener &listener); - /** - * @brief Gets window-context. - * @return window-context. - */ - Window &getWindow() const; + /** + * @brief Gets window-context. + * @return window-context. + */ + Window &getWindow() const; - void pop(void *id = nullptr, bool anim = true); - void pop(BasePopup *popup, bool anim = true); - void push(BasePopup &popup, void *id = nullptr); - BasePopup *getTop() const; - bool isEmpty() const; + void pop(void *id = nullptr, bool anim = true); + void pop(BasePopup *popup, bool anim = true); + void push(BasePopup &popup, void *id = nullptr); + BasePopup *getTop() const; + bool isEmpty() const; - /** - * @brief Process pause event - */ - void onPause(); + /** + * @brief Process pause event + */ + void onPause(); - private: - void onHwBackButtonClicked(Evas_Object *obj, void *eventInfo); - void destroyPopup(bool anim); + private: + void onHwBackButtonClicked(Evas_Object *obj, void *eventInfo); + void destroyPopup(bool anim); - private: - BasePopup *m_pPopup; - Window &m_Window; - void *m_pPopupId; - std::list m_Listeners; - }; + private: + BasePopup *m_pPopup; + Window &m_Window; + void *m_pPopupId; + std::list m_Listeners; + }; - class IPopupManagerListener { - public: - virtual ~IPopupManagerListener() {} - virtual void onPop(BasePopup &popup) {}; - virtual void onPush(BasePopup &popup) {}; - }; + class IPopupManagerListener { + public: + virtual ~IPopupManagerListener() {} + virtual void onPop(BasePopup &popup) {}; + virtual void onPush(BasePopup &popup) {}; + }; } #endif /* PopupManager_h_ */ diff --git a/src/Common/View/inc/SearchBar.h b/src/Common/View/inc/SearchBar.h index c14cd1f..119c0e5 100644 --- a/src/Common/View/inc/SearchBar.h +++ b/src/Common/View/inc/SearchBar.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -21,32 +21,32 @@ namespace Msg { - class ISearchBarListener; + class ISearchBarListener; - class SearchBar - : public View { + class SearchBar + : public View { - public: - SearchBar(Evas_Object *parent); + public: + SearchBar(Evas_Object *parent); - void setListener(ISearchBarListener *l); - void setText(const std::string &text); + void setListener(ISearchBarListener *l); + void setText(const std::string &text); - private: - void onButtonClicked(Evas_Object *obj, void *event); - void onTextClicked(Evas_Object *obj, const char *emission, const char *source); + private: + void onButtonClicked(Evas_Object *obj, void *event); + void onTextClicked(Evas_Object *obj, const char *emission, const char *source); - private: - ISearchBarListener *m_pListener; - Atspi m_AoSearchText; - }; + private: + ISearchBarListener *m_pListener; + Atspi m_AoSearchText; + }; - class ISearchBarListener { - public: - virtual ~ISearchBarListener() {}; - virtual void onButtonClicked(SearchBar &obj) {}; - virtual void onTextClicked(SearchBar &obj) {}; - }; + class ISearchBarListener { + public: + virtual ~ISearchBarListener() {}; + virtual void onButtonClicked(SearchBar &obj) {}; + virtual void onTextClicked(SearchBar &obj) {}; + }; } #endif /* SearchBar_h_ */ diff --git a/src/Common/View/inc/SelectAllListItem.h b/src/Common/View/inc/SelectAllListItem.h index 4948b91..2a54c75 100644 --- a/src/Common/View/inc/SelectAllListItem.h +++ b/src/Common/View/inc/SelectAllListItem.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -23,20 +23,20 @@ namespace Msg { - class SelectAllListItem - : public ListItem - { - public: - SelectAllListItem(); - virtual ~SelectAllListItem(); + class SelectAllListItem + : public ListItem + { + public: + SelectAllListItem(); + virtual ~SelectAllListItem(); - private: - const char *getCheckPart(ListItem &item) override; - std::string getText(ListItem &item, const char *part) override; + private: + const char *getCheckPart(ListItem &item) override; + std::string getText(ListItem &item, const char *part) override; - private: - std::string m_Text; - }; + private: + std::string m_Text; + }; } #endif // SelectAllListItem_h_ diff --git a/src/Common/View/inc/SelectButton.h b/src/Common/View/inc/SelectButton.h index 3ea1562..ba6d39d 100644 --- a/src/Common/View/inc/SelectButton.h +++ b/src/Common/View/inc/SelectButton.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -20,18 +20,18 @@ #include "View.h" namespace Msg { - class SelectButton - : public View { + class SelectButton + : public View { - public: - SelectButton(Evas_Object *parent); - Evas_Object *getInnerButton() const; - void showButton(bool show); - void setText(const std::string &text); + public: + SelectButton(Evas_Object *parent); + Evas_Object *getInnerButton() const; + void showButton(bool show); + void setText(const std::string &text); - private: - Evas_Object *m_pButton; - }; + private: + Evas_Object *m_pButton; + }; } #endif /* SelectButton_h_ */ diff --git a/src/Common/View/inc/SelectCtxPopup.h b/src/Common/View/inc/SelectCtxPopup.h index 675c18b..67a7c83 100644 --- a/src/Common/View/inc/SelectCtxPopup.h +++ b/src/Common/View/inc/SelectCtxPopup.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -20,48 +20,48 @@ #include "CtxPopup.h" namespace Msg { - class SelectCtxPopup - : public CtxPopup { + class SelectCtxPopup + : public CtxPopup { - public: - SelectCtxPopup(); - CtxPopupItem *appendTopItem(const TText &text, CtxPopupItemPressedCb cb = nullptr, void *userData = nullptr); - CtxPopupItem *appendBottomItem(const TText &text, CtxPopupItemPressedCb cb = nullptr, void *userData = nullptr); - void go(); + public: + SelectCtxPopup(); + CtxPopupItem *appendTopItem(const TText &text, CtxPopupItemPressedCb cb = nullptr, void *userData = nullptr); + CtxPopupItem *appendBottomItem(const TText &text, CtxPopupItemPressedCb cb = nullptr, void *userData = nullptr); + void go(); - private: - CtxPopupItem *m_pTopItem; - CtxPopupItem *m_pBottomItem; - }; + private: + CtxPopupItem *m_pTopItem; + CtxPopupItem *m_pBottomItem; + }; - inline SelectCtxPopup::SelectCtxPopup() - : CtxPopup() - , m_pTopItem(nullptr) - , m_pBottomItem(nullptr) - { - setStyle("select_mode"); - } + inline SelectCtxPopup::SelectCtxPopup() + : CtxPopup() + , m_pTopItem(nullptr) + , m_pBottomItem(nullptr) + { + setStyle("select_mode"); + } - inline CtxPopupItem *SelectCtxPopup::appendTopItem(const TText &text, CtxPopupItemPressedCb cb, void *userData) - { - m_pTopItem = appendItem(text, nullptr, cb, userData); - return m_pTopItem; - } + inline CtxPopupItem *SelectCtxPopup::appendTopItem(const TText &text, CtxPopupItemPressedCb cb, void *userData) + { + m_pTopItem = appendItem(text, nullptr, cb, userData); + return m_pTopItem; + } - inline CtxPopupItem *SelectCtxPopup::appendBottomItem(const TText &text, CtxPopupItemPressedCb cb, void *userData) - { - m_pBottomItem = appendItem(text, nullptr, cb, userData); - return m_pBottomItem; - } + inline CtxPopupItem *SelectCtxPopup::appendBottomItem(const TText &text, CtxPopupItemPressedCb cb, void *userData) + { + m_pBottomItem = appendItem(text, nullptr, cb, userData); + return m_pBottomItem; + } - inline void SelectCtxPopup::go() - { - show(); - if (m_pTopItem && m_pBottomItem) { - m_pTopItem->setStyle("select_mode/top"); - m_pBottomItem->setStyle("select_mode/bottom"); - } - } + inline void SelectCtxPopup::go() + { + show(); + if (m_pTopItem && m_pBottomItem) { + m_pTopItem->setStyle("select_mode/top"); + m_pBottomItem->setStyle("select_mode/bottom"); + } + } } #endif // SelectCtxPopup_h_ diff --git a/src/Common/View/inc/StandardPopup.h b/src/Common/View/inc/StandardPopup.h index c2b6475..6411757 100644 --- a/src/Common/View/inc/StandardPopup.h +++ b/src/Common/View/inc/StandardPopup.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -20,28 +20,28 @@ #include "Popup.h" namespace Msg { - class StandardPopup - : public Popup { - - public: - static const char *defaultStyle; - static const char *buttons1Style; - static const char *buttons2Style; - - public: - StandardPopup(const char *style = defaultStyle); - virtual ~StandardPopup(); - - Evas_Object *getLayout() const; - void setText(const std::string &text); - void setText(const TText &text); - void setTitle(const std::string &title); - void setTitle(const TText &title); - void setContent(Evas_Object *content); - - private: - Evas_Object *m_pLayout; - }; + class StandardPopup + : public Popup { + + public: + static const char *defaultStyle; + static const char *buttons1Style; + static const char *buttons2Style; + + public: + StandardPopup(const char *style = defaultStyle); + virtual ~StandardPopup(); + + Evas_Object *getLayout() const; + void setText(const std::string &text); + void setText(const TText &text); + void setTitle(const std::string &title); + void setTitle(const TText &title); + void setContent(Evas_Object *content); + + private: + Evas_Object *m_pLayout; + }; } #endif /* StandardPopup_h_ */ diff --git a/src/Common/View/inc/StandardWindow.h b/src/Common/View/inc/StandardWindow.h index 9487834..bb91e84 100644 --- a/src/Common/View/inc/StandardWindow.h +++ b/src/Common/View/inc/StandardWindow.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -21,28 +21,28 @@ namespace Msg { - class StandardWindow - : public Window - { - public: - StandardWindow(); - virtual ~StandardWindow(); + class StandardWindow + : public Window + { + public: + StandardWindow(); + virtual ~StandardWindow(); - Evas_Object *getWinEvasObject() const override; - Evas_Object *getConformEvasObject() const override; - Evas_Object *getHostEvasObject() const override; - Eext_Circle_Surface *getCircleSurface() const override; - void setContent(Evas_Object *content) override; - void getScreenSize(int *x, int *y, int *w, int *h) const override; - int getRotation() const override; - void lower() override; - void raise() override; + Evas_Object *getWinEvasObject() const override; + Evas_Object *getConformEvasObject() const override; + Evas_Object *getHostEvasObject() const override; + Eext_Circle_Surface *getCircleSurface() const override; + void setContent(Evas_Object *content) override; + void getScreenSize(int *x, int *y, int *w, int *h) const override; + int getRotation() const override; + void lower() override; + void raise() override; - private: - Evas_Object *m_pConform; - Evas_Object *m_pBg; - Eext_Circle_Surface *m_pCircleSurface; - }; + private: + Evas_Object *m_pConform; + Evas_Object *m_pBg; + Eext_Circle_Surface *m_pCircleSurface; + }; } #endif /* StandardWindow_h_ */ diff --git a/src/Common/View/inc/TitleListItem.h b/src/Common/View/inc/TitleListItem.h index 107ae34..86d6bb5 100644 --- a/src/Common/View/inc/TitleListItem.h +++ b/src/Common/View/inc/TitleListItem.h @@ -21,23 +21,23 @@ #include "TextDecorator.h" namespace Msg { - class TitleListItem - : public ListItem { - public: - TitleListItem(); + class TitleListItem + : public ListItem { + public: + TitleListItem(); - void setTitle(TText title); + void setTitle(TText title); - private: - Evas_Object *getContent(ListItem &item, const char *part) override; - Evas_Object *createLabel(); + private: + Evas_Object *getContent(ListItem &item, const char *part) override; + Evas_Object *createLabel(); - protected: - void onAttached(ViewItem &item) override; + protected: + void onAttached(ViewItem &item) override; - private: - TText m_Title; - }; + private: + TText m_Title; + }; } #endif /* TitleListItem_h_ */ diff --git a/src/Common/View/inc/ToastPopup.h b/src/Common/View/inc/ToastPopup.h index 28a8a5b..e5ae2f6 100644 --- a/src/Common/View/inc/ToastPopup.h +++ b/src/Common/View/inc/ToastPopup.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -20,19 +20,19 @@ #include "Popup.h" namespace Msg { - class ToastPopup - : public Popup { + class ToastPopup + : public Popup { - public: - ToastPopup(double timeout = defaultTimeOut); - virtual ~ToastPopup(); + public: + ToastPopup(double timeout = defaultTimeOut); + virtual ~ToastPopup(); - void setIcon(const char *iconName); - void setText(const TText &text); - void setText(const std::string &text); + void setIcon(const char *iconName); + void setText(const TText &text); + void setText(const std::string &text); - static ToastPopup *toast(const TText &text, const char *iconName = nullptr); - }; + static ToastPopup *toast(const TText &text, const char *iconName = nullptr); + }; } #endif /* ToastPopup_h_ */ diff --git a/src/Common/View/inc/View.h b/src/Common/View/inc/View.h index e0723f8..0a37097 100644 --- a/src/Common/View/inc/View.h +++ b/src/Common/View/inc/View.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -27,592 +27,592 @@ namespace Msg { - /** - * @brief Wraps all basic Evas_Object operations and manages automatic self-removal by EVAS_CALLBACK_FREE and EVAS_CALLBACK_DEL events. - */ - class View - : public BaseView - { - public: - View(); - - /** - * @brief Destroys nested Evas_Object. - */ - void destroy(); - operator Evas_Object *() const; - Evas_Object *getEo() const; - - /** - * @brief Checks whether view is visible or not. - * @return true if view is visible, otherwise false. - */ - bool isVisible() const; - - /** - * @brief Shows view. - * @param[in] value - true show, false - otherwise - */ - void show(bool value = true); - - /** - * @brief Moves view to specified Evas-coordinates. - * @param[in] x x-coordinate - * @param[in] y y-coordinate - */ - void move(Evas_Coord x, Evas_Coord y); - - /** - * @brief Sets size-weight hints. - * @param[in] x x-coordinate - * @param[in] y y-coordinate - */ - void setSizeHintWeight(double x, double y); - - /** - * @brief Sets size-align hints. - * @param[in] x x-coordinate - * @param[in] y y-coordinate - */ - void setSizeHintAlign(double x, double y); - - /** - * @brief Sets size-weight and size-align hints in order to make view expanded. - */ - void expand(); - - /** - * @brief Sets specified Evas_object's size-weight and size-align hints in order to make it expanded. - * @param[in] obj an Evas_Object to be expanded. - */ - static void expand(Evas_Object *obj); - - /** - * @brief Sets min size hints. - * @param[in] w width hint. - * @param[in] h height hint. - */ - void setSizeHintMin(Evas_Coord w, Evas_Coord h); - - /** - * @brief Sets max size hints. - * @param[in] w width hint. - * @param[in] h height hint. - */ - void setSizeHintMax(Evas_Coord w, Evas_Coord h); - - /** - * @brief Gets min size hints. - * @param[out] w width hint. - * @param[out] h height hint. - */ - void getSizeHintMin(Evas_Coord *w, Evas_Coord *h) const; - - /** - * @brief Gets max size hints. - * @param[out] w width hint. - * @param[out] h height hint. - */ - void getSizeHintMax(Evas_Coord *w, Evas_Coord *h) const; - - /** - * @brief Sets specified content into specified part. - * @param[in] content a content to set into view. - * @param[in] part a part content should be placed to. If part is nullptr the default part is used. - * @param[in] saveOldContent a flag that checks whether old view's content should be returned or not. - * @return if saveOldContent is true returns old content set into view before, otherwise returns nullptr. - */ - Evas_Object *setContent(Evas_Object *content, const char *part = nullptr, bool saveOldContent = false); - static Evas_Object *setContent(Evas_Object *obj, Evas_Object *content, const char *part = nullptr, bool saveOldContent = false); - - /** - * @brief Unsets view's content. - * @param[in] part a part content should be removed from. If part is nullptr the default part is used. - * @return old view's content in case of success, nullptr in case of errors. - */ - Evas_Object *unsetContent(const char *part = nullptr); - - /** - * @brief Gets view's content. - * @param[in] part a content-part. If part is nullptr the default part is used. - * @return view's content in case of success, nullptr in case of errors. - */ - Evas_Object* getContent(const char *part = nullptr) const; - - /** - * @brief Set the ability for an view object to be focused. - * @param[in] enable if true view is enabled to be focused, otherwise it can not be focused. - */ - void setFocusAllow(bool enable); - - /** - * @brief Checks whether view can be focused or not. - * @return true if view is able to be focused, otherwise false. - */ - bool getFocusAllow() const; - - /** - * @brief Sets(unsets) focus to view. - * @param[in] focus if true sets focus to view, otherwise unfocuses it. - */ - void setFocus(bool focus); - - /** - * @brief Checks whether view is focused or not. - * @return true if view is focused, otherwise false. - */ - bool getFocus() const; - - /** - * @brief Mark the part text to be translatable or not. - * @param[in] translatable @c true, the part text will be translated internally. @c false, otherwise. - * @param[in] domain The translation domain to use. - * @param[in] part The part name of the translatable text, if part is nullptr the default part is used. - */ - void setTranslatable(bool translatable, const char *domain, const char *part = nullptr); - - /** - * @brief Sends a signal to edje-object. - * @param[in] emission The signal's name. - * @param[in] source The signal's source. - * @param[in] async true - process an object's message queue in job/timer, false - process immediately. - */ - void emitSignal(const char *emission, const char *source = "", bool async = false); - - /** - * @brief Sends a signal to edje-object. - * @param[in] obj Target object - * @param[in] emission The signal's name. - * @param[in] source The signal's source. - * @param[in] async true - process the signal postponed, false - process immediately. - */ - static void emitSignal(Evas_Object *obj, const char *emission, const char *source = "", bool async = false); - - /** - * @brief Process all edje signals for object - * @param[in] obj Target object - */ - static void processSignal(Evas_Object *obj); - - /** - * @brief Process edje signals for object - */ - void processSignal(); - - /** - * @brief Process all edje signals - */ - static void processSignals(); - - /** - * @brief Sets user-data associated with specified key-string. - * @param[in] key a string-key. - * @param[in] data to be stored. - */ - void setData(const char *key, const void *data); - - /** - * @brief Sets the view mirrored mode. - * @param[in] obj evas object - * @param[in] true to set mirrored mode, false othewise - */ - static void setMirrored(Evas_Object *obj, bool mirrored); - void setMirrored(bool mirrored); - - /** - * @brief Gets data associated with specified key-string. - * @param[in] key a string-key. - * @return user-data. - */ - void *getData(const char *key) const; - void addEventCb(Evas_Callback_Type type, Evas_Object_Event_Cb func, const void *data); - void addSmartCb(const char *event, Evas_Smart_Cb func, const void *data); - void addSignalCb(const char *emission, const char *source, Edje_Signal_Cb func, void *data); - void addHwButtonEvent(Eext_Callback_Type cbType, Eext_Event_Cb cb, void *data); - void HwButtonEvent(Eext_Callback_Type cbType, Eext_Event_Cb cb, void *data); - - static void addHwButtonEvent(Evas_Object *obj, Eext_Callback_Type cbType, Eext_Event_Cb cb, void *data); - static void addEventCb(Evas_Object *obj, Evas_Callback_Type type, Evas_Object_Event_Cb func, const void *data); - static void addSmartCb(Evas_Object *obj, const char *event, Evas_Smart_Cb func, const void *data); - static void addSignalCb(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func, void *data); - - template - static T staticCast(void *evasObj); - template - static T reinterpretCast(void *evasObj); - template - static T dynamicCast(void *evasObj); - - /** - * @brief Gets text placed in specified part. - * @param[in] part a part to get text from. If part is nullptr the default part is used. - * @return a text part contains. If part contains no text returns empty string. - */ - std::string getText(const char *part = nullptr) const; - - /** - * @brief A C-style implementation of getText(). - */ - const char *getTextCStr(const char *part = nullptr) const; - - /** - * @brief Sets IDS of translatable string into specified part. - * @param[in] text a translatable text to be set in specified part. - * @param[in] part a part to get text from. If part is nullptr the default part is used. - */ - void setText(const TText &text, const char *part = nullptr); - - /** - * @brief Set the style to used by a given widget - * @param[in] style The name of the style to use on it - */ - void setStyle(const char *style); - static void setStyle(Evas_Object *obj, const char *style); - - /** - * @brief Gets the edje object - * @return edje object - */ - Evas_Object *getEdje() const; - - /** - * @brief Gets evas - * @return pointer to evas - */ - Evas *getEvas() const; - - Atspi registerAccessObj(const char *part); - static Atspi registerAccessObj(Evas_Object *obj, const char *part); - Atspi registerAccessObj(Evas_Object *parent); - void unregisterAccessObj(); - static Atspi registerAccessObj(Evas_Object *obj, Evas_Object *parent); - static void unregisterAccessObj(Evas_Object *obj); - static Atspi getAccessObj(Evas_Object *obj); - Atspi getAccessObj() const; - - static void setText(Evas_Object *obj, const TText &text, const char *part = nullptr); - - static Evas_Object *addLayout(Evas_Object *parent, const std::string &edjePath, const std::string &group); - static Evas_Object *addIconButton(Evas_Object *parent, const std::string &iconName, Evas_Smart_Cb clickedCb = nullptr, void *cbData = nullptr); - - protected: - virtual ~View(); - - /** - * @brief Allows children-classes to perform some cleanup activities before their destroying. - * @param[in] view to be destroyed after exiting onBeforeDelete(). - */ - virtual void onBeforeDelete(View &view) {}; - - void setEventCb(Evas_Callback_Type type); - void unsetEventCb(Evas_Callback_Type type); - void setEo(Evas_Object *eo); - - private: - View(View&) = delete; - View& operator=(View&) = delete; - Evas_Object_Event_Cb getCb(Evas_Callback_Type); - void *getData() const; - static void *getData(Evas_Object *obj); - void setData(const void *data); - static void setData(Evas_Object *obj, const void *data); - - private: - static void on_free_cb(void *data, Evas *e, Evas_Object *obj, void *event_info); - static void on_del_cb(void *data, Evas *e, Evas_Object *obj, void *event_info); - }; - - std::string markupToUtf8(const char *str); - std::string utf8ToMarkup(const char *str); - std::string markupToUtf8(const std::string &str); - std::string utf8ToMarkup(const std::string &str); - - inline View::operator Evas_Object *() const - { - return m_pEo; - } - - inline Evas_Object *View::getEo() const - { - return (Evas_Object*)BaseView::getEo(); - } - - inline void View::destroy() - { - evas_object_del(m_pEo); - } - - inline bool View::isVisible() const - { - return evas_object_visible_get(m_pEo); - } - - inline void View::show(bool value) - { - value ? evas_object_show(m_pEo) : evas_object_hide(m_pEo); - } - - inline void View::setSizeHintWeight(double x, double y) - { - evas_object_size_hint_weight_set(m_pEo, x, y); - } - - inline void View::setSizeHintAlign(double x, double y) - { - evas_object_size_hint_align_set(m_pEo, x, y); - } - - inline void View::setSizeHintMin(Evas_Coord w, Evas_Coord h) - { - evas_object_size_hint_min_set(m_pEo, w, h); - } - - inline void View::setSizeHintMax(Evas_Coord w, Evas_Coord h) - { - evas_object_size_hint_max_set(m_pEo, w, h); - } - - inline void View::getSizeHintMin(Evas_Coord *w, Evas_Coord *h) const - { - evas_object_size_hint_min_get(m_pEo, w, h); - }; - - inline void View::getSizeHintMax(Evas_Coord *w, Evas_Coord *h) const - { - evas_object_size_hint_max_get(m_pEo, w, h); - } - - inline void View::move(Evas_Coord x, Evas_Coord y) - { - evas_object_move(m_pEo, x, y); - } - - inline Evas_Object* View::getContent(const char *part) const - { - return elm_object_part_content_get(m_pEo, part); - } - - inline void View::setFocusAllow(bool enable) - { - elm_object_focus_allow_set(m_pEo, enable); - } - - inline bool View::getFocusAllow() const - { - return elm_object_focus_allow_get(m_pEo); - } - - inline void View::setFocus(bool focus) - { - return elm_object_focus_set(m_pEo, focus); - } - - inline bool View::getFocus() const - { - return elm_object_focus_get(m_pEo); - } - - inline void View::setTranslatable(bool translatable, const char *domain, const char *part) - { - elm_object_domain_part_text_translatable_set(m_pEo, part, domain, translatable); - } - - inline void View::emitSignal(const char *emission, const char *source, bool async) - { - emitSignal(m_pEo, emission, source, async); - } - - inline void View::processSignal() - { - processSignal(m_pEo); - } - - inline void View::processSignals() - { - edje_message_signal_process(); - } - - inline void View::setText(const TText &text, const char *part) - { - setText(m_pEo, text, part); - } - - inline void View::setStyle(const char *style) - { - setStyle(getEo(), style); - } - - inline void View::setStyle(Evas_Object *obj, const char *style) - { - elm_object_style_set(obj, style); - } - - inline void View::setText(Evas_Object *obj, const TText &text, const char *part) - { - if (text.isTranslatable()) - elm_object_domain_translatable_part_text_set(obj, part, text.getDomain(), text.getMsg()); - else { - elm_object_part_text_translatable_set(obj, part, false); - elm_object_part_text_set(obj, part, text.translate().c_str()); - } - } - - inline std::string View::getText(const char *part) const - { - const char *text = getTextCStr(part); - return text ? text : ""; - } - - inline const char *View::getTextCStr(const char *part) const - { - return elm_object_part_text_get(m_pEo, part); - } - - inline void View::setData(const char *key, const void *data) - { - evas_object_data_set(m_pEo, key, data); - } - - inline void *View::getData(const char *key) const - { - return evas_object_data_get(m_pEo, key); - } - - inline void View::setData(const void *data) - { - setData(m_pEo, data); - } - - inline void *View::getData() const - { - return getData(m_pEo); - } - - template - inline T View::staticCast(void *evasObj) - { - return static_cast(getData((Evas_Object*)evasObj)); - } - - template - inline T View::reinterpretCast(void *evasObj) - { - return reinterpret_cast(getData((Evas_Object*)evasObj)); - } - - template - inline T View::dynamicCast(void *evasObj) - { - return dynamic_cast(staticCast(evasObj)); - } - - inline void View::addEventCb(Evas_Callback_Type type, Evas_Object_Event_Cb func, const void *data) - { - evas_object_event_callback_add(m_pEo, type, func, data); - } - - inline void View::addSmartCb(const char *event, Evas_Smart_Cb func, const void *data) - { - evas_object_smart_callback_add(m_pEo, event, func, data); - } - - inline void View::addSignalCb(const char *emission, const char *source, Edje_Signal_Cb func, void *data) - { - elm_object_signal_callback_add(m_pEo, emission, source, func, data); - } - - inline void View::addHwButtonEvent(Evas_Object *obj, Eext_Callback_Type cbType, Eext_Event_Cb cb, void *data) - { - eext_object_event_callback_add(obj, cbType, cb, data); - } - - inline void View::addEventCb(Evas_Object *obj, Evas_Callback_Type type, Evas_Object_Event_Cb func, const void *data) - { - evas_object_event_callback_add(obj, type, func, data); - } - - inline void View::addSmartCb(Evas_Object *obj, const char *event, Evas_Smart_Cb func, const void *data) - { - evas_object_smart_callback_add(obj, event, func, data); - } - - inline void View::addSignalCb(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func, void *data) - { - elm_object_signal_callback_add(obj, emission, source, func, data); - } - - inline void View::addHwButtonEvent(Eext_Callback_Type cbType, Eext_Event_Cb cb, void *data) - { - addHwButtonEvent(m_pEo, cbType, cb, data); - } - - inline Evas_Object *View::unsetContent(const char *part) - { - return elm_object_part_content_unset(m_pEo, part); - } - - inline Evas_Object *View::getEdje() const - { - return elm_layout_edje_get(m_pEo); - } - - inline Evas *View::getEvas() const - { - return evas_object_evas_get(m_pEo); - } - - inline void View::setMirrored(Evas_Object *obj, bool mirrored) - { - elm_object_mirrored_automatic_set(obj, mirrored); - elm_object_mirrored_set(obj, mirrored); - } - - inline void View::setMirrored(bool mirrored) - { - setMirrored(getEo(), mirrored); - } - - inline Atspi View::registerAccessObj(const char *part) - { - return registerAccessObj(m_pEo, part); - } - - inline Atspi View::registerAccessObj(Evas_Object *obj, const char *part) - { - Evas_Object *edje = elm_layout_edje_get(obj); - Evas_Object *partObj = (Evas_Object *)edje_object_part_object_get(edje, part); - return registerAccessObj(partObj, obj); - } - - inline Atspi View::registerAccessObj(Evas_Object *parent) - { - return registerAccessObj(m_pEo, parent); - } - - inline void View::unregisterAccessObj() - { - unregisterAccessObj(m_pEo); - } - - inline Atspi View::registerAccessObj(Evas_Object *obj, Evas_Object *parent) - { - return elm_access_object_register(obj, parent); - } - - inline void View::unregisterAccessObj(Evas_Object *obj) - { - elm_access_object_unregister(obj); - } - - inline Atspi View::getAccessObj(Evas_Object *obj) - { - return elm_access_object_get(obj); - } - - inline Atspi View::getAccessObj() const - { - return getAccessObj(m_pEo); - } + /** + * @brief Wraps all basic Evas_Object operations and manages automatic self-removal by EVAS_CALLBACK_FREE and EVAS_CALLBACK_DEL events. + */ + class View + : public BaseView + { + public: + View(); + + /** + * @brief Destroys nested Evas_Object. + */ + void destroy(); + operator Evas_Object *() const; + Evas_Object *getEo() const; + + /** + * @brief Checks whether view is visible or not. + * @return true if view is visible, otherwise false. + */ + bool isVisible() const; + + /** + * @brief Shows view. + * @param[in] value - true show, false - otherwise + */ + void show(bool value = true); + + /** + * @brief Moves view to specified Evas-coordinates. + * @param[in] x x-coordinate + * @param[in] y y-coordinate + */ + void move(Evas_Coord x, Evas_Coord y); + + /** + * @brief Sets size-weight hints. + * @param[in] x x-coordinate + * @param[in] y y-coordinate + */ + void setSizeHintWeight(double x, double y); + + /** + * @brief Sets size-align hints. + * @param[in] x x-coordinate + * @param[in] y y-coordinate + */ + void setSizeHintAlign(double x, double y); + + /** + * @brief Sets size-weight and size-align hints in order to make view expanded. + */ + void expand(); + + /** + * @brief Sets specified Evas_object's size-weight and size-align hints in order to make it expanded. + * @param[in] obj an Evas_Object to be expanded. + */ + static void expand(Evas_Object *obj); + + /** + * @brief Sets min size hints. + * @param[in] w width hint. + * @param[in] h height hint. + */ + void setSizeHintMin(Evas_Coord w, Evas_Coord h); + + /** + * @brief Sets max size hints. + * @param[in] w width hint. + * @param[in] h height hint. + */ + void setSizeHintMax(Evas_Coord w, Evas_Coord h); + + /** + * @brief Gets min size hints. + * @param[out] w width hint. + * @param[out] h height hint. + */ + void getSizeHintMin(Evas_Coord *w, Evas_Coord *h) const; + + /** + * @brief Gets max size hints. + * @param[out] w width hint. + * @param[out] h height hint. + */ + void getSizeHintMax(Evas_Coord *w, Evas_Coord *h) const; + + /** + * @brief Sets specified content into specified part. + * @param[in] content a content to set into view. + * @param[in] part a part content should be placed to. If part is nullptr the default part is used. + * @param[in] saveOldContent a flag that checks whether old view's content should be returned or not. + * @return if saveOldContent is true returns old content set into view before, otherwise returns nullptr. + */ + Evas_Object *setContent(Evas_Object *content, const char *part = nullptr, bool saveOldContent = false); + static Evas_Object *setContent(Evas_Object *obj, Evas_Object *content, const char *part = nullptr, bool saveOldContent = false); + + /** + * @brief Unsets view's content. + * @param[in] part a part content should be removed from. If part is nullptr the default part is used. + * @return old view's content in case of success, nullptr in case of errors. + */ + Evas_Object *unsetContent(const char *part = nullptr); + + /** + * @brief Gets view's content. + * @param[in] part a content-part. If part is nullptr the default part is used. + * @return view's content in case of success, nullptr in case of errors. + */ + Evas_Object* getContent(const char *part = nullptr) const; + + /** + * @brief Set the ability for an view object to be focused. + * @param[in] enable if true view is enabled to be focused, otherwise it can not be focused. + */ + void setFocusAllow(bool enable); + + /** + * @brief Checks whether view can be focused or not. + * @return true if view is able to be focused, otherwise false. + */ + bool getFocusAllow() const; + + /** + * @brief Sets(unsets) focus to view. + * @param[in] focus if true sets focus to view, otherwise unfocuses it. + */ + void setFocus(bool focus); + + /** + * @brief Checks whether view is focused or not. + * @return true if view is focused, otherwise false. + */ + bool getFocus() const; + + /** + * @brief Mark the part text to be translatable or not. + * @param[in] translatable @c true, the part text will be translated internally. @c false, otherwise. + * @param[in] domain The translation domain to use. + * @param[in] part The part name of the translatable text, if part is nullptr the default part is used. + */ + void setTranslatable(bool translatable, const char *domain, const char *part = nullptr); + + /** + * @brief Sends a signal to edje-object. + * @param[in] emission The signal's name. + * @param[in] source The signal's source. + * @param[in] async true - process an object's message queue in job/timer, false - process immediately. + */ + void emitSignal(const char *emission, const char *source = "", bool async = false); + + /** + * @brief Sends a signal to edje-object. + * @param[in] obj Target object + * @param[in] emission The signal's name. + * @param[in] source The signal's source. + * @param[in] async true - process the signal postponed, false - process immediately. + */ + static void emitSignal(Evas_Object *obj, const char *emission, const char *source = "", bool async = false); + + /** + * @brief Process all edje signals for object + * @param[in] obj Target object + */ + static void processSignal(Evas_Object *obj); + + /** + * @brief Process edje signals for object + */ + void processSignal(); + + /** + * @brief Process all edje signals + */ + static void processSignals(); + + /** + * @brief Sets user-data associated with specified key-string. + * @param[in] key a string-key. + * @param[in] data to be stored. + */ + void setData(const char *key, const void *data); + + /** + * @brief Sets the view mirrored mode. + * @param[in] obj evas object + * @param[in] true to set mirrored mode, false othewise + */ + static void setMirrored(Evas_Object *obj, bool mirrored); + void setMirrored(bool mirrored); + + /** + * @brief Gets data associated with specified key-string. + * @param[in] key a string-key. + * @return user-data. + */ + void *getData(const char *key) const; + void addEventCb(Evas_Callback_Type type, Evas_Object_Event_Cb func, const void *data); + void addSmartCb(const char *event, Evas_Smart_Cb func, const void *data); + void addSignalCb(const char *emission, const char *source, Edje_Signal_Cb func, void *data); + void addHwButtonEvent(Eext_Callback_Type cbType, Eext_Event_Cb cb, void *data); + void HwButtonEvent(Eext_Callback_Type cbType, Eext_Event_Cb cb, void *data); + + static void addHwButtonEvent(Evas_Object *obj, Eext_Callback_Type cbType, Eext_Event_Cb cb, void *data); + static void addEventCb(Evas_Object *obj, Evas_Callback_Type type, Evas_Object_Event_Cb func, const void *data); + static void addSmartCb(Evas_Object *obj, const char *event, Evas_Smart_Cb func, const void *data); + static void addSignalCb(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func, void *data); + + template + static T staticCast(void *evasObj); + template + static T reinterpretCast(void *evasObj); + template + static T dynamicCast(void *evasObj); + + /** + * @brief Gets text placed in specified part. + * @param[in] part a part to get text from. If part is nullptr the default part is used. + * @return a text part contains. If part contains no text returns empty string. + */ + std::string getText(const char *part = nullptr) const; + + /** + * @brief A C-style implementation of getText(). + */ + const char *getTextCStr(const char *part = nullptr) const; + + /** + * @brief Sets IDS of translatable string into specified part. + * @param[in] text a translatable text to be set in specified part. + * @param[in] part a part to get text from. If part is nullptr the default part is used. + */ + void setText(const TText &text, const char *part = nullptr); + + /** + * @brief Set the style to used by a given widget + * @param[in] style The name of the style to use on it + */ + void setStyle(const char *style); + static void setStyle(Evas_Object *obj, const char *style); + + /** + * @brief Gets the edje object + * @return edje object + */ + Evas_Object *getEdje() const; + + /** + * @brief Gets evas + * @return pointer to evas + */ + Evas *getEvas() const; + + Atspi registerAccessObj(const char *part); + static Atspi registerAccessObj(Evas_Object *obj, const char *part); + Atspi registerAccessObj(Evas_Object *parent); + void unregisterAccessObj(); + static Atspi registerAccessObj(Evas_Object *obj, Evas_Object *parent); + static void unregisterAccessObj(Evas_Object *obj); + static Atspi getAccessObj(Evas_Object *obj); + Atspi getAccessObj() const; + + static void setText(Evas_Object *obj, const TText &text, const char *part = nullptr); + + static Evas_Object *addLayout(Evas_Object *parent, const std::string &edjePath, const std::string &group); + static Evas_Object *addIconButton(Evas_Object *parent, const std::string &iconName, Evas_Smart_Cb clickedCb = nullptr, void *cbData = nullptr); + + protected: + virtual ~View(); + + /** + * @brief Allows children-classes to perform some cleanup activities before their destroying. + * @param[in] view to be destroyed after exiting onBeforeDelete(). + */ + virtual void onBeforeDelete(View &view) {}; + + void setEventCb(Evas_Callback_Type type); + void unsetEventCb(Evas_Callback_Type type); + void setEo(Evas_Object *eo); + + private: + View(View&) = delete; + View& operator=(View&) = delete; + Evas_Object_Event_Cb getCb(Evas_Callback_Type); + void *getData() const; + static void *getData(Evas_Object *obj); + void setData(const void *data); + static void setData(Evas_Object *obj, const void *data); + + private: + static void on_free_cb(void *data, Evas *e, Evas_Object *obj, void *event_info); + static void on_del_cb(void *data, Evas *e, Evas_Object *obj, void *event_info); + }; + + std::string markupToUtf8(const char *str); + std::string utf8ToMarkup(const char *str); + std::string markupToUtf8(const std::string &str); + std::string utf8ToMarkup(const std::string &str); + + inline View::operator Evas_Object *() const + { + return m_pEo; + } + + inline Evas_Object *View::getEo() const + { + return (Evas_Object*)BaseView::getEo(); + } + + inline void View::destroy() + { + evas_object_del(m_pEo); + } + + inline bool View::isVisible() const + { + return evas_object_visible_get(m_pEo); + } + + inline void View::show(bool value) + { + value ? evas_object_show(m_pEo) : evas_object_hide(m_pEo); + } + + inline void View::setSizeHintWeight(double x, double y) + { + evas_object_size_hint_weight_set(m_pEo, x, y); + } + + inline void View::setSizeHintAlign(double x, double y) + { + evas_object_size_hint_align_set(m_pEo, x, y); + } + + inline void View::setSizeHintMin(Evas_Coord w, Evas_Coord h) + { + evas_object_size_hint_min_set(m_pEo, w, h); + } + + inline void View::setSizeHintMax(Evas_Coord w, Evas_Coord h) + { + evas_object_size_hint_max_set(m_pEo, w, h); + } + + inline void View::getSizeHintMin(Evas_Coord *w, Evas_Coord *h) const + { + evas_object_size_hint_min_get(m_pEo, w, h); + }; + + inline void View::getSizeHintMax(Evas_Coord *w, Evas_Coord *h) const + { + evas_object_size_hint_max_get(m_pEo, w, h); + } + + inline void View::move(Evas_Coord x, Evas_Coord y) + { + evas_object_move(m_pEo, x, y); + } + + inline Evas_Object* View::getContent(const char *part) const + { + return elm_object_part_content_get(m_pEo, part); + } + + inline void View::setFocusAllow(bool enable) + { + elm_object_focus_allow_set(m_pEo, enable); + } + + inline bool View::getFocusAllow() const + { + return elm_object_focus_allow_get(m_pEo); + } + + inline void View::setFocus(bool focus) + { + return elm_object_focus_set(m_pEo, focus); + } + + inline bool View::getFocus() const + { + return elm_object_focus_get(m_pEo); + } + + inline void View::setTranslatable(bool translatable, const char *domain, const char *part) + { + elm_object_domain_part_text_translatable_set(m_pEo, part, domain, translatable); + } + + inline void View::emitSignal(const char *emission, const char *source, bool async) + { + emitSignal(m_pEo, emission, source, async); + } + + inline void View::processSignal() + { + processSignal(m_pEo); + } + + inline void View::processSignals() + { + edje_message_signal_process(); + } + + inline void View::setText(const TText &text, const char *part) + { + setText(m_pEo, text, part); + } + + inline void View::setStyle(const char *style) + { + setStyle(getEo(), style); + } + + inline void View::setStyle(Evas_Object *obj, const char *style) + { + elm_object_style_set(obj, style); + } + + inline void View::setText(Evas_Object *obj, const TText &text, const char *part) + { + if (text.isTranslatable()) + elm_object_domain_translatable_part_text_set(obj, part, text.getDomain(), text.getMsg()); + else { + elm_object_part_text_translatable_set(obj, part, false); + elm_object_part_text_set(obj, part, text.translate().c_str()); + } + } + + inline std::string View::getText(const char *part) const + { + const char *text = getTextCStr(part); + return text ? text : ""; + } + + inline const char *View::getTextCStr(const char *part) const + { + return elm_object_part_text_get(m_pEo, part); + } + + inline void View::setData(const char *key, const void *data) + { + evas_object_data_set(m_pEo, key, data); + } + + inline void *View::getData(const char *key) const + { + return evas_object_data_get(m_pEo, key); + } + + inline void View::setData(const void *data) + { + setData(m_pEo, data); + } + + inline void *View::getData() const + { + return getData(m_pEo); + } + + template + inline T View::staticCast(void *evasObj) + { + return static_cast(getData((Evas_Object*)evasObj)); + } + + template + inline T View::reinterpretCast(void *evasObj) + { + return reinterpret_cast(getData((Evas_Object*)evasObj)); + } + + template + inline T View::dynamicCast(void *evasObj) + { + return dynamic_cast(staticCast(evasObj)); + } + + inline void View::addEventCb(Evas_Callback_Type type, Evas_Object_Event_Cb func, const void *data) + { + evas_object_event_callback_add(m_pEo, type, func, data); + } + + inline void View::addSmartCb(const char *event, Evas_Smart_Cb func, const void *data) + { + evas_object_smart_callback_add(m_pEo, event, func, data); + } + + inline void View::addSignalCb(const char *emission, const char *source, Edje_Signal_Cb func, void *data) + { + elm_object_signal_callback_add(m_pEo, emission, source, func, data); + } + + inline void View::addHwButtonEvent(Evas_Object *obj, Eext_Callback_Type cbType, Eext_Event_Cb cb, void *data) + { + eext_object_event_callback_add(obj, cbType, cb, data); + } + + inline void View::addEventCb(Evas_Object *obj, Evas_Callback_Type type, Evas_Object_Event_Cb func, const void *data) + { + evas_object_event_callback_add(obj, type, func, data); + } + + inline void View::addSmartCb(Evas_Object *obj, const char *event, Evas_Smart_Cb func, const void *data) + { + evas_object_smart_callback_add(obj, event, func, data); + } + + inline void View::addSignalCb(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func, void *data) + { + elm_object_signal_callback_add(obj, emission, source, func, data); + } + + inline void View::addHwButtonEvent(Eext_Callback_Type cbType, Eext_Event_Cb cb, void *data) + { + addHwButtonEvent(m_pEo, cbType, cb, data); + } + + inline Evas_Object *View::unsetContent(const char *part) + { + return elm_object_part_content_unset(m_pEo, part); + } + + inline Evas_Object *View::getEdje() const + { + return elm_layout_edje_get(m_pEo); + } + + inline Evas *View::getEvas() const + { + return evas_object_evas_get(m_pEo); + } + + inline void View::setMirrored(Evas_Object *obj, bool mirrored) + { + elm_object_mirrored_automatic_set(obj, mirrored); + elm_object_mirrored_set(obj, mirrored); + } + + inline void View::setMirrored(bool mirrored) + { + setMirrored(getEo(), mirrored); + } + + inline Atspi View::registerAccessObj(const char *part) + { + return registerAccessObj(m_pEo, part); + } + + inline Atspi View::registerAccessObj(Evas_Object *obj, const char *part) + { + Evas_Object *edje = elm_layout_edje_get(obj); + Evas_Object *partObj = (Evas_Object *)edje_object_part_object_get(edje, part); + return registerAccessObj(partObj, obj); + } + + inline Atspi View::registerAccessObj(Evas_Object *parent) + { + return registerAccessObj(m_pEo, parent); + } + + inline void View::unregisterAccessObj() + { + unregisterAccessObj(m_pEo); + } + + inline Atspi View::registerAccessObj(Evas_Object *obj, Evas_Object *parent) + { + return elm_access_object_register(obj, parent); + } + + inline void View::unregisterAccessObj(Evas_Object *obj) + { + elm_access_object_unregister(obj); + } + + inline Atspi View::getAccessObj(Evas_Object *obj) + { + return elm_access_object_get(obj); + } + + inline Atspi View::getAccessObj() const + { + return getAccessObj(m_pEo); + } } #endif /* View_h_ */ diff --git a/src/Common/View/inc/ViewItem.h b/src/Common/View/inc/ViewItem.h index 8210ed3..22bfd25 100644 --- a/src/Common/View/inc/ViewItem.h +++ b/src/Common/View/inc/ViewItem.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -25,226 +25,226 @@ namespace Msg { - /** - * @brief Wraps all basic Elm_Object_Item operations and manages automatic self-removal by delete-callback. - */ - class ViewItem - : public BaseView - { - public: - ViewItem(); - ViewItem(ViewItem&) = delete; - ViewItem& operator=(const ViewItem&) = delete; - - operator Elm_Object_Item *() const; - - /** - * @brief Destroys view-item. - */ - void destroy(); - - /** - * @brief Sets specified content into specified part. - * @param[in] content a content to set into view-item. - * @param[in] part a part content should be placed to. If part is nullptr the default part is used. - * @param[in] saveOldContent a flag that checks whether old view's content should be returned or not. - * @return if saveOldContent is true returns old content set into view before, otherwise returns nullptr. - */ - Evas_Object *setContent(Evas_Object *content, const char *part = nullptr, bool saveOldContent = false); - - /** - * @brief Gets view-items's content. - * @param[in] part a content-part. If part is nullptr the default part is used. - * @return view's content in case of success, nullptr in case of errors. - */ - Evas_Object *getContent(const char *part = nullptr) const; - - /** - * @brief Sends a signal to edje-object. - * @param[in] emission The signal's name. - * @param[in] source The signal's source. - */ - void emitSignal(const char *signal, const char *source = "elm"); - - /** - * @brief Gets item-data. - * @return item-data. - */ - void *getData() const; - - /** - * @brief Sets item-data. - * @param[in] data item-data. - */ - void setData(void *data); - - /** - * @brief Gets Elm_Object_Item current view-item is wrapping. - * @return wrapped object-item. - */ - Elm_Object_Item *getElmObjItem() const; - - /** - * @brief Get the widget object's handle which contains a given view-item. - */ - Evas_Object *getWidget() const; - - /** - * @brief Disables(enables) view-item. - * @param[in] val if true disables view-item, otherwise enables it. - */ - void disabled(bool val); - - /** - * @brief Checks whether view-item is disabled or not. - * @return true if view-item is disabled, otherwise false. - */ - bool isDisabled() const; - - /** - * @brief Mark the part text to be translatable or not. - * @param[in] translatable @c true, the part text will be translated internally. @c false, otherwise. - * @param[in] domain The translation domain to use. - * @param[in] part The part name of the translatable text, if part is nullptr the default part is used. - */ - void setTranslatable(bool translatable, const char *domain, const char *part = nullptr); - - /** - * @brief Gets text placed in specified part. - * @param[in] part a part to get text from. If part is nullptr the default part is used. - * @return a text part contains. If part contains no text returns empty string. - */ - std::string getText(const char *part = nullptr) const; - - /** - * @brief A C-style implementation of getText(). - */ - const char *getTextCStr(const char *part = nullptr) const; - - /** - * @brief Sets IDS of translatable string into specified part. - * @param[in] text a translatable text to be set in specified part. - * @param[in] part a part to get text from. If part is nullptr the default part is used. - */ - void setText(const TText &text, const char *part = nullptr); - static void setText(Elm_Object_Item *it, const TText &text, const char *part = nullptr); - - /** - * @brief Set the style to used by a given widget - * @param[in] style The name of the style to use on it - */ - void setStyle(const char *style); - static void setStyle(Elm_Object_Item *it, const char *style); - - template - static T staticCast(void *elmObjectItem); - template - static T reinterpretCast(void *elmObjectItem); - template - static T dynamicCast(void *elmObjectItem); - - protected: - virtual ~ViewItem(); - virtual void onAttached(ViewItem &item) {}; - void setElmObjItem(Elm_Object_Item *item); - - private: - static void on_delete_cb(void *data, Evas_Object *obj, void *event_info); - }; - - inline ViewItem::operator Elm_Object_Item *() const - { - return getElmObjItem(); - } - - inline Elm_Object_Item *ViewItem::getElmObjItem() const - { - return (Elm_Object_Item*)getEo(); - } - - inline Evas_Object *ViewItem::getWidget() const - { - return elm_object_item_widget_get(getElmObjItem()); - } - - inline void *ViewItem::getData() const - { - return elm_object_item_data_get(getElmObjItem()); - } - - inline void ViewItem::setData(void *data) - { - elm_object_item_data_set(getElmObjItem(), data); - } - - inline void ViewItem::disabled(bool val) - { - elm_object_item_disabled_set(getElmObjItem(), val); - } - - inline bool ViewItem::isDisabled() const - { - return elm_object_item_disabled_get(getElmObjItem()); - } - - inline void ViewItem::setTranslatable(bool translatable, const char *domain, const char *part) - { - elm_object_item_domain_part_text_translatable_set(getElmObjItem(), part, domain, translatable); - } - - inline void ViewItem::setText(const TText &text, const char *part) - { - setText(getElmObjItem(), text, part); - } - - inline void ViewItem::setText(Elm_Object_Item *it, const TText &text, const char *part) - { - if (text.isTranslatable()) { - elm_object_item_domain_translatable_part_text_set(it, part, text.getDomain(), text.getMsg()); - } else { - elm_object_item_part_text_translatable_set(it, part, false); - elm_object_item_part_text_set(it, part, text.translate().c_str()); - } - } - - inline std::string ViewItem::getText(const char *part) const - { - const char *text = getTextCStr(part); - return text ? text : ""; - } - - inline const char *ViewItem::getTextCStr(const char *part) const - { - return elm_object_item_part_text_get(getElmObjItem(), part); - } - - inline void ViewItem::setStyle(const char *style) - { - setStyle(getElmObjItem(), style); - } - - inline void ViewItem::setStyle(Elm_Object_Item *it, const char *style) - { - elm_object_item_style_set(it, style); - } - - template - inline T ViewItem::staticCast(void *elmObjectItem) - { - return static_cast(elm_object_item_data_get((Elm_Object_Item*)elmObjectItem)); - } - - template - inline T ViewItem::reinterpretCast(void *elmObjectItem) - { - return reinterpret_cast(elm_object_item_data_get((Elm_Object_Item*)elmObjectItem)); - } - - template - inline T ViewItem::dynamicCast(void *elmObjectItem) - { - return dynamic_cast(staticCast(elmObjectItem)); - } + /** + * @brief Wraps all basic Elm_Object_Item operations and manages automatic self-removal by delete-callback. + */ + class ViewItem + : public BaseView + { + public: + ViewItem(); + ViewItem(ViewItem&) = delete; + ViewItem& operator=(const ViewItem&) = delete; + + operator Elm_Object_Item *() const; + + /** + * @brief Destroys view-item. + */ + void destroy(); + + /** + * @brief Sets specified content into specified part. + * @param[in] content a content to set into view-item. + * @param[in] part a part content should be placed to. If part is nullptr the default part is used. + * @param[in] saveOldContent a flag that checks whether old view's content should be returned or not. + * @return if saveOldContent is true returns old content set into view before, otherwise returns nullptr. + */ + Evas_Object *setContent(Evas_Object *content, const char *part = nullptr, bool saveOldContent = false); + + /** + * @brief Gets view-items's content. + * @param[in] part a content-part. If part is nullptr the default part is used. + * @return view's content in case of success, nullptr in case of errors. + */ + Evas_Object *getContent(const char *part = nullptr) const; + + /** + * @brief Sends a signal to edje-object. + * @param[in] emission The signal's name. + * @param[in] source The signal's source. + */ + void emitSignal(const char *signal, const char *source = "elm"); + + /** + * @brief Gets item-data. + * @return item-data. + */ + void *getData() const; + + /** + * @brief Sets item-data. + * @param[in] data item-data. + */ + void setData(void *data); + + /** + * @brief Gets Elm_Object_Item current view-item is wrapping. + * @return wrapped object-item. + */ + Elm_Object_Item *getElmObjItem() const; + + /** + * @brief Get the widget object's handle which contains a given view-item. + */ + Evas_Object *getWidget() const; + + /** + * @brief Disables(enables) view-item. + * @param[in] val if true disables view-item, otherwise enables it. + */ + void disabled(bool val); + + /** + * @brief Checks whether view-item is disabled or not. + * @return true if view-item is disabled, otherwise false. + */ + bool isDisabled() const; + + /** + * @brief Mark the part text to be translatable or not. + * @param[in] translatable @c true, the part text will be translated internally. @c false, otherwise. + * @param[in] domain The translation domain to use. + * @param[in] part The part name of the translatable text, if part is nullptr the default part is used. + */ + void setTranslatable(bool translatable, const char *domain, const char *part = nullptr); + + /** + * @brief Gets text placed in specified part. + * @param[in] part a part to get text from. If part is nullptr the default part is used. + * @return a text part contains. If part contains no text returns empty string. + */ + std::string getText(const char *part = nullptr) const; + + /** + * @brief A C-style implementation of getText(). + */ + const char *getTextCStr(const char *part = nullptr) const; + + /** + * @brief Sets IDS of translatable string into specified part. + * @param[in] text a translatable text to be set in specified part. + * @param[in] part a part to get text from. If part is nullptr the default part is used. + */ + void setText(const TText &text, const char *part = nullptr); + static void setText(Elm_Object_Item *it, const TText &text, const char *part = nullptr); + + /** + * @brief Set the style to used by a given widget + * @param[in] style The name of the style to use on it + */ + void setStyle(const char *style); + static void setStyle(Elm_Object_Item *it, const char *style); + + template + static T staticCast(void *elmObjectItem); + template + static T reinterpretCast(void *elmObjectItem); + template + static T dynamicCast(void *elmObjectItem); + + protected: + virtual ~ViewItem(); + virtual void onAttached(ViewItem &item) {}; + void setElmObjItem(Elm_Object_Item *item); + + private: + static void on_delete_cb(void *data, Evas_Object *obj, void *event_info); + }; + + inline ViewItem::operator Elm_Object_Item *() const + { + return getElmObjItem(); + } + + inline Elm_Object_Item *ViewItem::getElmObjItem() const + { + return (Elm_Object_Item*)getEo(); + } + + inline Evas_Object *ViewItem::getWidget() const + { + return elm_object_item_widget_get(getElmObjItem()); + } + + inline void *ViewItem::getData() const + { + return elm_object_item_data_get(getElmObjItem()); + } + + inline void ViewItem::setData(void *data) + { + elm_object_item_data_set(getElmObjItem(), data); + } + + inline void ViewItem::disabled(bool val) + { + elm_object_item_disabled_set(getElmObjItem(), val); + } + + inline bool ViewItem::isDisabled() const + { + return elm_object_item_disabled_get(getElmObjItem()); + } + + inline void ViewItem::setTranslatable(bool translatable, const char *domain, const char *part) + { + elm_object_item_domain_part_text_translatable_set(getElmObjItem(), part, domain, translatable); + } + + inline void ViewItem::setText(const TText &text, const char *part) + { + setText(getElmObjItem(), text, part); + } + + inline void ViewItem::setText(Elm_Object_Item *it, const TText &text, const char *part) + { + if (text.isTranslatable()) { + elm_object_item_domain_translatable_part_text_set(it, part, text.getDomain(), text.getMsg()); + } else { + elm_object_item_part_text_translatable_set(it, part, false); + elm_object_item_part_text_set(it, part, text.translate().c_str()); + } + } + + inline std::string ViewItem::getText(const char *part) const + { + const char *text = getTextCStr(part); + return text ? text : ""; + } + + inline const char *ViewItem::getTextCStr(const char *part) const + { + return elm_object_item_part_text_get(getElmObjItem(), part); + } + + inline void ViewItem::setStyle(const char *style) + { + setStyle(getElmObjItem(), style); + } + + inline void ViewItem::setStyle(Elm_Object_Item *it, const char *style) + { + elm_object_item_style_set(it, style); + } + + template + inline T ViewItem::staticCast(void *elmObjectItem) + { + return static_cast(elm_object_item_data_get((Elm_Object_Item*)elmObjectItem)); + } + + template + inline T ViewItem::reinterpretCast(void *elmObjectItem) + { + return reinterpret_cast(elm_object_item_data_get((Elm_Object_Item*)elmObjectItem)); + } + + template + inline T ViewItem::dynamicCast(void *elmObjectItem) + { + return dynamic_cast(staticCast(elmObjectItem)); + } } #endif /* ViewItem_h_ */ diff --git a/src/Common/View/inc/Window.h b/src/Common/View/inc/Window.h index caa6675..df9ef7d 100644 --- a/src/Common/View/inc/Window.h +++ b/src/Common/View/inc/Window.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -22,25 +22,25 @@ namespace Msg { - /** - * @brief An interface that should be implemented by all window-classes across whole application. - */ - class Window - : public View - { - public: - virtual ~Window() {}; + /** + * @brief An interface that should be implemented by all window-classes across whole application. + */ + class Window + : public View + { + public: + virtual ~Window() {}; - virtual Evas_Object *getWinEvasObject() const = 0; - virtual Evas_Object *getConformEvasObject() const = 0; - virtual Evas_Object *getHostEvasObject() const = 0; - virtual Eext_Circle_Surface *getCircleSurface() const = 0; - virtual void setContent(Evas_Object *content) = 0; - virtual void getScreenSize(int *x, int *y, int *w, int *h) const = 0; - virtual int getRotation() const = 0; - virtual void lower() = 0; - virtual void raise() = 0; - }; + virtual Evas_Object *getWinEvasObject() const = 0; + virtual Evas_Object *getConformEvasObject() const = 0; + virtual Evas_Object *getHostEvasObject() const = 0; + virtual Eext_Circle_Surface *getCircleSurface() const = 0; + virtual void setContent(Evas_Object *content) = 0; + virtual void getScreenSize(int *x, int *y, int *w, int *h) const = 0; + virtual int getRotation() const = 0; + virtual void lower() = 0; + virtual void raise() = 0; + }; } #endif /* Window_h_ */ diff --git a/src/Common/View/src/BasePopup.cpp b/src/Common/View/src/BasePopup.cpp index 33ce49e..9a8333a 100644 --- a/src/Common/View/src/BasePopup.cpp +++ b/src/Common/View/src/BasePopup.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -22,12 +22,12 @@ using namespace Msg; BasePopup::BasePopup(Evas_Object *popup) - : m_OutsideTapDismiss(false) - , m_PauseAppDismiss(false) - , m_BackButtonDismiss(true) + : m_OutsideTapDismiss(false) + , m_PauseAppDismiss(false) + , m_BackButtonDismiss(true) { - setEo(popup); - App::getInst().getPopupManager().push(*this); + setEo(popup); + App::getInst().getPopupManager().push(*this); } BasePopup::~BasePopup() @@ -36,45 +36,45 @@ BasePopup::~BasePopup() void BasePopup::destroy(bool anim) { - App::getInst().getPopupManager().pop(this, anim); + App::getInst().getPopupManager().pop(this, anim); } void BasePopup::dismiss() { - View::destroy(); + View::destroy(); } Evas_Object *BasePopup::getWindow() { - return App::getInst().getWindow(); + return App::getInst().getWindow(); } void BasePopup::setDismissByOutsideTapFlag(bool value) { - m_OutsideTapDismiss = value; + m_OutsideTapDismiss = value; } bool BasePopup::getDismissByOutsideTapFlag() const { - return m_OutsideTapDismiss; + return m_OutsideTapDismiss; } void BasePopup::setDismissByPauseAppFlag(bool value) { - m_PauseAppDismiss = value; + m_PauseAppDismiss = value; } bool BasePopup::getDismissByPauseAppFlag() const { - return m_PauseAppDismiss; + return m_PauseAppDismiss; } void BasePopup::setDismissByBackButtonFlag(bool value) { - m_BackButtonDismiss = value; + m_BackButtonDismiss = value; } bool BasePopup::getDismissByBackButtonFlag() const { - return m_BackButtonDismiss; + return m_BackButtonDismiss; } diff --git a/src/Common/View/src/BottomButton.cpp b/src/Common/View/src/BottomButton.cpp index eb3db5e..9194a0d 100644 --- a/src/Common/View/src/BottomButton.cpp +++ b/src/Common/View/src/BottomButton.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -19,26 +19,26 @@ using namespace Msg; BottomButton::BottomButton(Evas_Object *parent) - : m_pButton(nullptr) + : m_pButton(nullptr) { - setEo(elm_layout_add(parent)); - elm_layout_theme_set(getEo(), "layout", "bottom_button", "default"); - m_pButton = elm_button_add(getEo()); - setStyle(m_pButton, "bottom"); - setContent(m_pButton, "elm.swallow.button"); + setEo(elm_layout_add(parent)); + elm_layout_theme_set(getEo(), "layout", "bottom_button", "default"); + m_pButton = elm_button_add(getEo()); + setStyle(m_pButton, "bottom"); + setContent(m_pButton, "elm.swallow.button"); } Evas_Object *BottomButton::getInnerButton() const { - return m_pButton; + return m_pButton; } void BottomButton::setText(const TText &text) { - View::setText(m_pButton, text); + View::setText(m_pButton, text); } void BottomButton::disabled(bool value) { - elm_object_disabled_set(m_pButton, value); + elm_object_disabled_set(m_pButton, value); } diff --git a/src/Common/View/src/CtxPopup.cpp b/src/Common/View/src/CtxPopup.cpp index 8d5a890..da3d630 100644 --- a/src/Common/View/src/CtxPopup.cpp +++ b/src/Common/View/src/CtxPopup.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -21,53 +21,53 @@ using namespace Msg; CtxPopupItem::CtxPopupItem(CtxPopup &parent, CtxPopupItemPressedCb userCb, void *userData) - : m_Parent(parent) - , m_pUserCb(userCb) - , m_pUserData(userData) + : m_Parent(parent) + , m_pUserCb(userCb) + , m_pUserData(userData) { } CtxPopupItem::~CtxPopupItem() { - MSG_LOG("Destructor"); + MSG_LOG("Destructor"); } CtxPopup &CtxPopupItem::getParent() { - return m_Parent; + return m_Parent; } // CtxPopup: CtxPopup::CtxPopup() - : BasePopup(elm_ctxpopup_add(getWindow())) + : BasePopup(elm_ctxpopup_add(getWindow())) { - elm_ctxpopup_auto_hide_disabled_set(getEo(), EINA_FALSE); - evas_object_smart_callback_add(getEo(), "dismissed", on_dismissed_cb, this); - setDirectionPriority(ELM_CTXPOPUP_DIRECTION_DOWN, - ELM_CTXPOPUP_DIRECTION_DOWN, - ELM_CTXPOPUP_DIRECTION_DOWN, - ELM_CTXPOPUP_DIRECTION_DOWN); + elm_ctxpopup_auto_hide_disabled_set(getEo(), EINA_FALSE); + evas_object_smart_callback_add(getEo(), "dismissed", on_dismissed_cb, this); + setDirectionPriority(ELM_CTXPOPUP_DIRECTION_DOWN, + ELM_CTXPOPUP_DIRECTION_DOWN, + ELM_CTXPOPUP_DIRECTION_DOWN, + ELM_CTXPOPUP_DIRECTION_DOWN); } CtxPopup::~CtxPopup() { - MSG_LOG("Destructor"); + MSG_LOG("Destructor"); } CtxPopupItem *CtxPopup::appendItem(const TText &text, Evas_Object *icon, CtxPopupItemPressedCb cb, void *userData) { - auto *newItem = new CtxPopupItem(*this, cb, userData); - Elm_Object_Item *elmItem = elm_ctxpopup_item_append(getEo(), "", icon, on_item_pressed_cb, newItem); - ViewItem::setText(elmItem, text); - - if (elmItem) { - newItem->setElmObjItem(elmItem); - } else { - delete newItem; - newItem = nullptr; - } - - return newItem; + auto *newItem = new CtxPopupItem(*this, cb, userData); + Elm_Object_Item *elmItem = elm_ctxpopup_item_append(getEo(), "", icon, on_item_pressed_cb, newItem); + ViewItem::setText(elmItem, text); + + if (elmItem) { + newItem->setElmObjItem(elmItem); + } else { + delete newItem; + newItem = nullptr; + } + + return newItem; } void CtxPopup::createCtxPopup(Evas_Object *parent) @@ -75,61 +75,61 @@ void CtxPopup::createCtxPopup(Evas_Object *parent) } void CtxPopup::setDirectionPriority(Elm_Ctxpopup_Direction first, Elm_Ctxpopup_Direction second, - Elm_Ctxpopup_Direction third, Elm_Ctxpopup_Direction fourth) + Elm_Ctxpopup_Direction third, Elm_Ctxpopup_Direction fourth) { - elm_ctxpopup_direction_priority_set(getEo(), first, second, third, fourth); + elm_ctxpopup_direction_priority_set(getEo(), first, second, third, fourth); } Elm_Ctxpopup_Direction CtxPopup::getDirection() const { - return elm_ctxpopup_direction_get(getEo()); + return elm_ctxpopup_direction_get(getEo()); } void CtxPopup::on_dismissed_cb(void *data, Evas_Object *obj, void *event_info) { - auto *self = static_cast(data); - self->destroy(); + auto *self = static_cast(data); + self->destroy(); } void CtxPopup::on_item_pressed_cb(void *data, Evas_Object *obj, void *event_info) { - auto *item = static_cast(data); - if (item) { - if (item->m_pUserCb) - item->m_pUserCb(*item, item->m_pUserData); - item->getParent().destroy(); - } + auto *item = static_cast(data); + if (item) { + if (item->m_pUserCb) + item->m_pUserCb(*item, item->m_pUserData); + item->getParent().destroy(); + } } void CtxPopup::align(Window &win) { - int w; - int h; - - int pos = win.getRotation(); - win.getScreenSize(nullptr, nullptr, &w, &h); - - switch (pos) { - case 0: - case 180: - move(w/2, h); - break; - case 90: - move(h/2, w); - break; - case 270: - move(h/2, w); - break; - } + int w; + int h; + + int pos = win.getRotation(); + win.getScreenSize(nullptr, nullptr, &w, &h); + + switch (pos) { + case 0: + case 180: + move(w/2, h); + break; + case 90: + move(h/2, w); + break; + case 270: + move(h/2, w); + break; + } } void CtxPopup::align(Evas_Object *obj) { - Evas_Coord x = 0; - Evas_Coord y = 0; - Evas_Coord w = 0; - Evas_Coord h = 0; - evas_object_geometry_get(obj, &x, &y, &w, &h); - evas_object_move(getEo(), x + (w / 2), y + (h / 2)); + Evas_Coord x = 0; + Evas_Coord y = 0; + Evas_Coord w = 0; + Evas_Coord h = 0; + evas_object_geometry_get(obj, &x, &y, &w, &h); + evas_object_move(getEo(), x + (w / 2), y + (h / 2)); } diff --git a/src/Common/View/src/DefaultLayout.cpp b/src/Common/View/src/DefaultLayout.cpp index 0c84f6e..323d19c 100644 --- a/src/Common/View/src/DefaultLayout.cpp +++ b/src/Common/View/src/DefaultLayout.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -21,7 +21,7 @@ using namespace Msg; DefaultLayout::DefaultLayout(Evas_Object *parent) { - setEo(addLayout(parent, DEFAULT_LAYOUT_EDJ_PATH, "main")); + setEo(addLayout(parent, DEFAULT_LAYOUT_EDJ_PATH, "main")); } DefaultLayout::~DefaultLayout() @@ -30,55 +30,55 @@ DefaultLayout::~DefaultLayout() void DefaultLayout::setContent(Evas_Object *obj) { - View::setContent(obj, "swl.content"); + View::setContent(obj, "swl.content"); } void DefaultLayout::setNoContent(Evas_Object *obj) { - View::setContent(obj, "swl.nocontent"); + View::setContent(obj, "swl.nocontent"); } void DefaultLayout::setMoreOption(Evas_Object *obj) { - View::setContent(obj, "swl.more_option"); + View::setContent(obj, "swl.more_option"); } void DefaultLayout::setSelectButton(Evas_Object *obj) { - View::setContent(obj, "swl.select_button"); + View::setContent(obj, "swl.select_button"); } void DefaultLayout::setBottomButton(Evas_Object *obj) { - View::setContent(obj, "swl.bottom_button"); + View::setContent(obj, "swl.bottom_button"); } void DefaultLayout::showContent(bool show) { - const char *sig = show ? "show_content" : "hide_content"; - emitSignal(sig); + const char *sig = show ? "show_content" : "hide_content"; + emitSignal(sig); } void DefaultLayout::showNoContent(bool show) { - const char *sig = show ? "show_nocontent" : "hide_nocontent"; - emitSignal(sig); + const char *sig = show ? "show_nocontent" : "hide_nocontent"; + emitSignal(sig); } void DefaultLayout::showMoreOption(bool show) { - const char *sig = show ? "show_more_option" : "hide_more_option"; - emitSignal(sig); + const char *sig = show ? "show_more_option" : "hide_more_option"; + emitSignal(sig); } void DefaultLayout::showSelectButton(bool show) { - const char *sig = show ? "show_select_button" : "hide_select_button"; - emitSignal(sig); + const char *sig = show ? "show_select_button" : "hide_select_button"; + emitSignal(sig); } void DefaultLayout::showBottomButton(bool show) { - const char *sig = show ? "show_bottom_button" : "hide_bottom_button"; - emitSignal(sig); + const char *sig = show ? "show_bottom_button" : "hide_bottom_button"; + emitSignal(sig); } diff --git a/src/Common/View/src/Entry.cpp b/src/Common/View/src/Entry.cpp index b64ac72..8957e27 100644 --- a/src/Common/View/src/Entry.cpp +++ b/src/Common/View/src/Entry.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -20,14 +20,14 @@ using namespace Msg; Entry::Entry(Evas_Object *parent) { - setEo(elm_entry_add(parent)); - // Default settings: - setEditable(true); - setAutocapitalType(ELM_AUTOCAPITAL_TYPE_NONE); - elm_entry_cnp_mode_set(getEo(), ELM_CNP_MODE_PLAINTEXT); - elm_entry_context_menu_disabled_set(getEo(), true); - elm_entry_end_visible_set(getEo(), false); - eext_entry_selection_back_event_allow_set(getEo(), true); + setEo(elm_entry_add(parent)); + // Default settings: + setEditable(true); + setAutocapitalType(ELM_AUTOCAPITAL_TYPE_NONE); + elm_entry_cnp_mode_set(getEo(), ELM_CNP_MODE_PLAINTEXT); + elm_entry_context_menu_disabled_set(getEo(), true); + elm_entry_end_visible_set(getEo(), false); + eext_entry_selection_back_event_allow_set(getEo(), true); } Entry::~Entry() @@ -36,163 +36,163 @@ Entry::~Entry() void Entry::setEditable(bool value) { - elm_entry_editable_set(getEo(), value); + elm_entry_editable_set(getEo(), value); } void Entry::enabledInputPanel(bool value) { - elm_entry_input_panel_enabled_set(getEo(), value); + elm_entry_input_panel_enabled_set(getEo(), value); } void Entry::showInputPanel(bool value) { - if (value) - elm_entry_input_panel_show(getEo()); - else - elm_entry_input_panel_hide(getEo()); + if (value) + elm_entry_input_panel_show(getEo()); + else + elm_entry_input_panel_hide(getEo()); } void Entry::setInputPanelReturnType(Elm_Input_Panel_Return_Key_Type retType) { - elm_entry_input_panel_return_key_type_set(getEo(), retType); + elm_entry_input_panel_return_key_type_set(getEo(), retType); } void Entry::setGuideText(const TText &text) { - View::setText(getEo(), text, "elm.guide"); + View::setText(getEo(), text, "elm.guide"); } std::string Entry::getText() const { - return markupToUtf8(getEntry()); + return markupToUtf8(getEntry()); } void Entry::setText(const std::string &text) { - elm_entry_entry_set(getEo(), text.c_str()); + elm_entry_entry_set(getEo(), text.c_str()); } const char *Entry::getEntry() const { - return elm_entry_entry_get(getEo()); + return elm_entry_entry_get(getEo()); } void Entry::setScrollerPolicy(Elm_Scroller_Policy policyH, Elm_Scroller_Policy policyV) { - elm_scroller_policy_set(getEo(), policyH, policyV); + elm_scroller_policy_set(getEo(), policyH, policyV); } void Entry::setAutocapitalType(Elm_Autocapital_Type type) { - elm_entry_autocapital_type_set(getEo(), type); + elm_entry_autocapital_type_set(getEo(), type); } void Entry::setScrollable(bool value) { - elm_entry_scrollable_set(getEo(), value); + elm_entry_scrollable_set(getEo(), value); } void Entry::setSingleLine(bool value) { - elm_entry_single_line_set(getEo(), value); + elm_entry_single_line_set(getEo(), value); } void Entry::setCursorPos(int pos) { - elm_entry_cursor_pos_set(getEo(), pos); + elm_entry_cursor_pos_set(getEo(), pos); } void Entry::setCursorPosToEnd() { - elm_entry_cursor_end_set(getEo()); + elm_entry_cursor_end_set(getEo()); } int Entry::getCursorPos() const { - return elm_entry_cursor_pos_get(getEo()); + return elm_entry_cursor_pos_get(getEo()); } void Entry::setEditInfo(Entry &entry) { - View::setText(entry.getEntry()); - setCursorPos(getCursorPos()); + View::setText(entry.getEntry()); + setCursorPos(getCursorPos()); } bool Entry::isEmpty() const { - const char *text = getEntry(); - return text ? text[0] == '\0' : true; + const char *text = getEntry(); + return text ? text[0] == '\0' : true; } void Entry::clear() { - View::setText(getEo(), ""); + View::setText(getEo(), ""); } void Entry::setLimit(int charCount, int byteCount) { - Elm_Entry_Filter_Limit_Size limitFilter = {charCount, byteCount}; - elm_entry_markup_filter_append(getEo(), elm_entry_filter_limit_size, &limitFilter); + Elm_Entry_Filter_Limit_Size limitFilter = {charCount, byteCount}; + elm_entry_markup_filter_append(getEo(), elm_entry_filter_limit_size, &limitFilter); } void Entry::disabledReturnKey(bool disabled) { - elm_entry_input_panel_return_key_disabled_set(getEo(), disabled); + elm_entry_input_panel_return_key_disabled_set(getEo(), disabled); } void Entry::addKeyDownCb(Evas_Object_Event_Cb cb, void *data) { - addEventCb(EVAS_CALLBACK_KEY_DOWN, cb, data); + addEventCb(EVAS_CALLBACK_KEY_DOWN, cb, data); } void Entry::addChangedCb(Evas_Smart_Cb cb, void *data) { - addSmartCb("changed", cb, data); + addSmartCb("changed", cb, data); } void Entry::addFocusedCb(Evas_Smart_Cb cb, void *data) { - addSmartCb("focused", cb, data); + addSmartCb("focused", cb, data); } void Entry::addUnfocusedCb(Evas_Smart_Cb cb, void *data) { - addSmartCb("unfocused", cb, data); + addSmartCb("unfocused", cb, data); } void Entry::addMaxlengthReachedCb(Evas_Smart_Cb cb, void *data) { - addSmartCb("maxlength,reached", cb, data); + addSmartCb("maxlength,reached", cb, data); } void Entry::addActivatedCb(Evas_Smart_Cb cb, void *data) { - addSmartCb("activated", cb, data); + addSmartCb("activated", cb, data); } void Entry::addMarkupFilterCb(Elm_Entry_Filter_Cb cb, void *data) { - elm_entry_markup_filter_append(getEo(), cb, data); + elm_entry_markup_filter_append(getEo(), cb, data); } void Entry::addInputPanelEventCb(Ecore_IMF_Input_Panel_Event type, InputPanelEventCb cb, const void *data) { - auto *imf = (Ecore_IMF_Context*)elm_entry_imf_context_get(getEo()); - if (imf) - ecore_imf_context_input_panel_event_callback_add(imf, type, cb, data); + auto *imf = (Ecore_IMF_Context*)elm_entry_imf_context_get(getEo()); + if (imf) + ecore_imf_context_input_panel_event_callback_add(imf, type, cb, data); } void Entry::delInputPanelEventCb(Ecore_IMF_Input_Panel_Event type, InputPanelEventCb cb) { - auto *imf = (Ecore_IMF_Context*)elm_entry_imf_context_get(getEo()); - if (imf) - ecore_imf_context_input_panel_event_callback_del(imf, type, cb); + auto *imf = (Ecore_IMF_Context*)elm_entry_imf_context_get(getEo()); + if (imf) + ecore_imf_context_input_panel_event_callback_del(imf, type, cb); } namespace Msg { - bool isPreedit(const char *str) - { - return strstr(str, "") == str && - strstr(str, "") != nullptr; - } + bool isPreedit(const char *str) + { + return strstr(str, "") == str && + strstr(str, "") != nullptr; + } } diff --git a/src/Common/View/src/IconTextPopup.cpp b/src/Common/View/src/IconTextPopup.cpp index 57303f1..a6409bb 100644 --- a/src/Common/View/src/IconTextPopup.cpp +++ b/src/Common/View/src/IconTextPopup.cpp @@ -23,12 +23,12 @@ using namespace Msg; static const double iconSize = 82.0; IconTextPopup::IconTextPopup() - : StandardPopup() - , m_pLayout(nullptr) - , m_IconType(NoneIcon) + : StandardPopup() + , m_pLayout(nullptr) + , m_IconType(NoneIcon) { - m_pLayout = View::addLayout(StandardPopup::getLayout(), POPUP_EDJ_PATH, "progress/custom/sending_popup"); - setContent(m_pLayout); + m_pLayout = View::addLayout(StandardPopup::getLayout(), POPUP_EDJ_PATH, "progress/custom/sending_popup"); + setContent(m_pLayout); } IconTextPopup::~IconTextPopup() @@ -37,54 +37,54 @@ IconTextPopup::~IconTextPopup() void IconTextPopup::setText(const TText &text) { - View::setText(m_pLayout, text, "text"); + View::setText(m_pLayout, text, "text"); } void IconTextPopup::setIcon(IconType type) { - if (m_IconType == type) - return; + if (m_IconType == type) + return; - m_IconType = type; - switch (m_IconType) { - case ProgressIcon: - showProgressBar(); - break; - case CheckIcon: - showCheckItem(); - break; - case FailedIcon: - showFailItem(); - break; - case NoneIcon: - break; - } + m_IconType = type; + switch (m_IconType) { + case ProgressIcon: + showProgressBar(); + break; + case CheckIcon: + showCheckItem(); + break; + case FailedIcon: + showFailItem(); + break; + case NoneIcon: + break; + } } void IconTextPopup::showProgressBar() { - Evas_Object *progressbar = elm_progressbar_add(m_pLayout); - elm_object_style_set(progressbar, "process_small"); - evas_object_smart_calculate(progressbar); - int w = 0; - int h = 0; - evas_object_size_hint_min_get(progressbar, &w, &h); - int max = std::max(w, h); - if (max != 0) - elm_object_scale_set(progressbar, iconSize / max); - evas_object_show(progressbar); - elm_progressbar_pulse(progressbar, EINA_TRUE); - elm_object_part_content_set(m_pLayout, "swallow.progress", progressbar); + Evas_Object *progressbar = elm_progressbar_add(m_pLayout); + elm_object_style_set(progressbar, "process_small"); + evas_object_smart_calculate(progressbar); + int w = 0; + int h = 0; + evas_object_size_hint_min_get(progressbar, &w, &h); + int max = std::max(w, h); + if (max != 0) + elm_object_scale_set(progressbar, iconSize / max); + evas_object_show(progressbar); + elm_progressbar_pulse(progressbar, EINA_TRUE); + elm_object_part_content_set(m_pLayout, "swallow.progress", progressbar); } void IconTextPopup::showCheckItem() { - Evas_Object *layout = View::addLayout(m_pLayout, ICONS_EDJ_PATH, "popup/check_icon"); - View::setContent(m_pLayout, layout, "swallow.progress"); + Evas_Object *layout = View::addLayout(m_pLayout, ICONS_EDJ_PATH, "popup/check_icon"); + View::setContent(m_pLayout, layout, "swallow.progress"); } void IconTextPopup::showFailItem() { - Evas_Object *layout = View::addLayout(m_pLayout, ICONS_EDJ_PATH, "popup/failed_icon"); - View::setContent(m_pLayout, layout, "swallow.progress"); + Evas_Object *layout = View::addLayout(m_pLayout, ICONS_EDJ_PATH, "popup/failed_icon"); + View::setContent(m_pLayout, layout, "swallow.progress"); } diff --git a/src/Common/View/src/InputLayout.cpp b/src/Common/View/src/InputLayout.cpp index 5d6f1a9..5efd271 100644 --- a/src/Common/View/src/InputLayout.cpp +++ b/src/Common/View/src/InputLayout.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +20,7 @@ using namespace Msg; InputLayout::InputLayout(Evas_Object *parent) { - setEo(addLayout(parent, INPUT_LAYOUT_EDJ_PATH, "main")); + setEo(addLayout(parent, INPUT_LAYOUT_EDJ_PATH, "main")); } InputLayout::~InputLayout() @@ -29,16 +29,16 @@ InputLayout::~InputLayout() void InputLayout::setPredictBar(Evas_Object *obj) { - setContent(obj, "predic_bar.swl"); + setContent(obj, "predic_bar.swl"); } void InputLayout::setEntry(Evas_Object *obj) { - setContent(obj, "entry.swl"); + setContent(obj, "entry.swl"); } void InputLayout::showPredictBar(bool value) { - const char *sig = value ? "show_predic_bar" : "hide_predic_bar"; - emitSignal(sig); + const char *sig = value ? "show_predic_bar" : "hide_predic_bar"; + emitSignal(sig); } diff --git a/src/Common/View/src/LineListViewItem.cpp b/src/Common/View/src/LineListViewItem.cpp index 5839221..e88a55f 100644 --- a/src/Common/View/src/LineListViewItem.cpp +++ b/src/Common/View/src/LineListViewItem.cpp @@ -19,8 +19,8 @@ using namespace Msg; LineListViewItem::LineListViewItem(std::string titleText) - : ListItem(ListItemStyle::create("1lineitem")) - , m_TitleText(std::move(titleText)) + : ListItem(ListItemStyle::create("1lineitem")) + , m_TitleText(std::move(titleText)) { } @@ -30,18 +30,18 @@ LineListViewItem::~LineListViewItem() void LineListViewItem::onAttached(ViewItem &item) { - setSelectable(false); + setSelectable(false); } void LineListViewItem::setText(std::string text) { - m_TitleText = std::move(text); + m_TitleText = std::move(text); } std::string LineListViewItem::getText(ListItem &item, const char *part) { - if (!strcmp(part, "elm.text")) - return msg(m_TitleText); + if (!strcmp(part, "elm.text")) + return msg(m_TitleText); - return ""; + return ""; } diff --git a/src/Common/View/src/ListItem.cpp b/src/Common/View/src/ListItem.cpp index 9228470..049c9c7 100644 --- a/src/Common/View/src/ListItem.cpp +++ b/src/Common/View/src/ListItem.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -26,75 +26,75 @@ using namespace Msg; // ListItemClass : ListItemStyle::ListItemStyle(const char *itemStyle, const char *decorateItemStyle, const char *decorateAllItemStyle) - : m_pGenlistItemClass(nullptr) + : m_pGenlistItemClass(nullptr) { - m_pGenlistItemClass = elm_genlist_item_class_new(); + m_pGenlistItemClass = elm_genlist_item_class_new(); - setStyle(itemStyle, decorateItemStyle, decorateAllItemStyle); - registerCallback(); + setStyle(itemStyle, decorateItemStyle, decorateAllItemStyle); + registerCallback(); } ListItemStyle::~ListItemStyle() { - unregisterCallback(); - if (m_pGenlistItemClass) - elm_genlist_item_class_free(m_pGenlistItemClass); + unregisterCallback(); + if (m_pGenlistItemClass) + elm_genlist_item_class_free(m_pGenlistItemClass); } ListItemStyleRef ListItemStyle::create(const char *itemStyle, - const char *decorateItemStyle, - const char *decorateAllItemStyle) + const char *decorateItemStyle, + const char *decorateAllItemStyle) { - return std::shared_ptr(new ListItemStyle(itemStyle, decorateItemStyle, decorateAllItemStyle)); + return std::shared_ptr(new ListItemStyle(itemStyle, decorateItemStyle, decorateAllItemStyle)); } void ListItemStyle::setStyle(const char * itemStyle, const char * decorateItemStyle, const char * decorateAllItemStyle) { - if (!m_pGenlistItemClass) - return; + if (!m_pGenlistItemClass) + return; - m_pGenlistItemClass->decorate_all_item_style = decorateAllItemStyle; - m_pGenlistItemClass->decorate_item_style = decorateItemStyle; - m_pGenlistItemClass->item_style = itemStyle; + m_pGenlistItemClass->decorate_all_item_style = decorateAllItemStyle; + m_pGenlistItemClass->decorate_item_style = decorateItemStyle; + m_pGenlistItemClass->item_style = itemStyle; } void ListItemStyle::registerCallback() { - if (!m_pGenlistItemClass) - return; + if (!m_pGenlistItemClass) + return; - m_pGenlistItemClass->func.text_get = &ListItem::elm_gen_item_text_get_cb; - m_pGenlistItemClass->func.state_get = &ListItem::elm_gen_item_state_get_cb; - m_pGenlistItemClass->func.del = &ListItem::elm_gen_item_del_cb; - m_pGenlistItemClass->func.content_get = &ListItem::elm_gen_item_content_get_cb; - m_pGenlistItemClass->func.filter_get = &ListItem::elm_gen_item_filter_cb; + m_pGenlistItemClass->func.text_get = &ListItem::elm_gen_item_text_get_cb; + m_pGenlistItemClass->func.state_get = &ListItem::elm_gen_item_state_get_cb; + m_pGenlistItemClass->func.del = &ListItem::elm_gen_item_del_cb; + m_pGenlistItemClass->func.content_get = &ListItem::elm_gen_item_content_get_cb; + m_pGenlistItemClass->func.filter_get = &ListItem::elm_gen_item_filter_cb; } void ListItemStyle::unregisterCallback() { - if (!m_pGenlistItemClass) - return; + if (!m_pGenlistItemClass) + return; - m_pGenlistItemClass->func.text_get = nullptr; - m_pGenlistItemClass->func.state_get = nullptr; - m_pGenlistItemClass->func.del = nullptr; - m_pGenlistItemClass->func.content_get = nullptr; - m_pGenlistItemClass->func.filter_get = nullptr; + m_pGenlistItemClass->func.text_get = nullptr; + m_pGenlistItemClass->func.state_get = nullptr; + m_pGenlistItemClass->func.del = nullptr; + m_pGenlistItemClass->func.content_get = nullptr; + m_pGenlistItemClass->func.filter_get = nullptr; } // ListItemClass: ListItem::ListItem(const ListItemStyleRef &itemStyle, Elm_Genlist_Item_Type type) - : ViewItem() - , m_pOwner(nullptr) - , m_ItemStyle(itemStyle) - , m_Type(type) - , m_Checked(false) - , m_OnSelectedCb() + : ViewItem() + , m_pOwner(nullptr) + , m_ItemStyle(itemStyle) + , m_Type(type) + , m_Checked(false) + , m_OnSelectedCb() { } ListItem::ListItem(Elm_Genlist_Item_Type type) - : ListItem(ListItemStyleRef(), type) + : ListItem(ListItemStyleRef(), type) { } @@ -104,190 +104,190 @@ ListItem::~ListItem() ListView *ListItem::getOwner() const { - return m_pOwner; + return m_pOwner; } Elm_Genlist_Item_Type ListItem::getType() const { - return m_Type; + return m_Type; } void ListItem::setStyle(ListItemStyleRef &style) { - m_ItemStyle = style; + m_ItemStyle = style; } const ListItemStyleRef &ListItem::getStyle() const { - return m_ItemStyle; + return m_ItemStyle; } char *ListItem::elm_gen_item_text_get_cb(void *data, Evas_Object *obj, const char *part) { - ListItem *self = static_cast(data); + ListItem *self = static_cast(data); - if (self) - { - std::string text = self->getText(*self, part); - return text.empty() ? nullptr : strdup(text.c_str()); - } + if (self) + { + std::string text = self->getText(*self, part); + return text.empty() ? nullptr : strdup(text.c_str()); + } - return nullptr; + return nullptr; } Evas_Object *ListItem::elm_gen_item_content_get_cb(void * data, Evas_Object * obj, const char * part) { - ListItem *self = static_cast(data); + ListItem *self = static_cast(data); - if (!self) - return nullptr; + if (!self) + return nullptr; - if (self->getOwner()->getCheckMode()) - { - const char *checkPart = self->getCheckPart(*self); - if (checkPart && strcmp(checkPart, part) == 0) - { - return self->addCheck(); - } - } + if (self->getOwner()->getCheckMode()) + { + const char *checkPart = self->getCheckPart(*self); + if (checkPart && strcmp(checkPart, part) == 0) + { + return self->addCheck(); + } + } - return self->getContent(*self, part); + return self->getContent(*self, part); } Eina_Bool ListItem::elm_gen_item_filter_cb(void *data, Evas_Object *obj, void *key) { - ListItem *self = static_cast(data); - return self ? self->getFilter(*self, key) : false; + ListItem *self = static_cast(data); + return self ? self->getFilter(*self, key) : false; } Evas_Object *ListItem::addCheck() { - Evas_Object *check = elm_check_add(*getOwner()); - elm_object_style_set(check, "genlist/select_mode"); - elm_check_state_set(check, m_Checked); - evas_object_propagate_events_set(check, EINA_FALSE); - evas_object_smart_callback_add(check, "changed", makeCbFirst(&ListItem::onCheckChanged), this); - elm_object_focus_allow_set(check, false); - evas_object_show(check); - return check; + Evas_Object *check = elm_check_add(*getOwner()); + elm_object_style_set(check, "genlist/select_mode"); + elm_check_state_set(check, m_Checked); + evas_object_propagate_events_set(check, EINA_FALSE); + evas_object_smart_callback_add(check, "changed", makeCbFirst(&ListItem::onCheckChanged), this); + elm_object_focus_allow_set(check, false); + evas_object_show(check); + return check; } void ListItem::changeCheckedState(bool updateUi) { - setCheckedState(!getCheckedState(), updateUi); + setCheckedState(!getCheckedState(), updateUi); } void ListItem::setCheckedState(bool state, bool updateUi) { - m_Checked = state; - if (updateUi) - updateFields(getCheckPart(*this), ELM_GENLIST_ITEM_FIELD_ALL); + m_Checked = state; + if (updateUi) + updateFields(getCheckPart(*this), ELM_GENLIST_ITEM_FIELD_ALL); } bool ListItem::getCheckedState() const { - return m_Checked; + return m_Checked; } bool ListItem::isCheckable() const { - return false; + return false; } bool ListItem::isSame(const ListItem &item) const { - return item.getElmObjItem() == getElmObjItem(); + return item.getElmObjItem() == getElmObjItem(); } void ListItem::setOnSelectedCb(OnSelectedCb cb) { - m_OnSelectedCb = cb; + m_OnSelectedCb = cb; } ListItem::OnSelectedCb &ListItem::getOnSelectedCb() { - return m_OnSelectedCb; + return m_OnSelectedCb; } void ListItem::onCheckChanged(Evas_Object *obj, void *eventInfo) { - m_Checked = elm_check_state_get(obj); - getOwner()->notifyListener(nullptr, obj, getElmObjItem(), &IListViewListener::onListItemChecked); + m_Checked = elm_check_state_get(obj); + getOwner()->notifyListener(nullptr, obj, getElmObjItem(), &IListViewListener::onListItemChecked); } Eina_Bool ListItem::elm_gen_item_state_get_cb(void *data, Evas_Object *obj, const char *part) { - ListItem *self = static_cast(data); - return self ? self->getState(*self, part) : false; + ListItem *self = static_cast(data); + return self ? self->getState(*self, part) : false; } void ListItem::setSelected(bool selected) { - elm_genlist_item_selected_set(getElmObjItem(), selected); + elm_genlist_item_selected_set(getElmObjItem(), selected); } bool ListItem::getSelected() const { - return elm_genlist_item_selected_get(getElmObjItem()); + return elm_genlist_item_selected_get(getElmObjItem()); } void ListItem::setSelectable(bool selectable) { - Elm_Object_Select_Mode mode = selectable ? ELM_OBJECT_SELECT_MODE_DEFAULT : ELM_OBJECT_SELECT_MODE_NONE; - elm_genlist_item_select_mode_set(getElmObjItem(), mode); + Elm_Object_Select_Mode mode = selectable ? ELM_OBJECT_SELECT_MODE_DEFAULT : ELM_OBJECT_SELECT_MODE_NONE; + elm_genlist_item_select_mode_set(getElmObjItem(), mode); } bool ListItem::getSelectable() const { - Elm_Object_Select_Mode mode = elm_genlist_item_select_mode_get(getElmObjItem()); - return mode == ELM_OBJECT_SELECT_MODE_DEFAULT || mode == ELM_OBJECT_SELECT_MODE_ALWAYS; + Elm_Object_Select_Mode mode = elm_genlist_item_select_mode_get(getElmObjItem()); + return mode == ELM_OBJECT_SELECT_MODE_DEFAULT || mode == ELM_OBJECT_SELECT_MODE_ALWAYS; } void ListItem::setExpanded(bool expand) { - elm_genlist_item_expanded_set(getElmObjItem(), expand); + elm_genlist_item_expanded_set(getElmObjItem(), expand); } void ListItem::update() { - 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()); + 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()); } void ListItem::updateFields(const char *parts, Elm_Genlist_Item_Field_Type type) { - elm_genlist_item_fields_update(getElmObjItem(), parts, type); + elm_genlist_item_fields_update(getElmObjItem(), parts, type); } std::string ListItem::getText(ListItem &item, const char* part) { - return std::string(); + return std::string(); } bool ListItem::getFilter(ListItem &item, void *key) { - return true; + return true; } Evas_Object* ListItem::getContent(ListItem &item, const char* part) { - return nullptr; + return nullptr; } bool ListItem::getState(ListItem &item, const char* part) { - return false; + return false; } void ListItem::onDelete(ListItem &item) { - delete this; + delete this; } const char *ListItem::getCheckPart(ListItem &item) { - return nullptr; + return nullptr; } void ListItem::onViewDestroyed() @@ -296,9 +296,9 @@ void ListItem::onViewDestroyed() void ListItem::elm_gen_item_del_cb(void *data, Evas_Object *obj) { - ListItem *self = static_cast(data); + ListItem *self = static_cast(data); - if (self) - self->onDelete(*self); + if (self) + self->onDelete(*self); } diff --git a/src/Common/View/src/ListView.cpp b/src/Common/View/src/ListView.cpp index fea6e6f..6394b62 100644 --- a/src/Common/View/src/ListView.cpp +++ b/src/Common/View/src/ListView.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -27,30 +27,30 @@ using namespace Msg; namespace { - inline ListItem *getItem(Elm_Object_Item *obj) - { - return obj ? static_cast(elm_object_item_data_get(obj)) : nullptr; - } + inline ListItem *getItem(Elm_Object_Item *obj) + { + return obj ? static_cast(elm_object_item_data_get(obj)) : nullptr; + } - inline int normalizeCmpValue(int value) - { - if (value > 0) - return 1; - if (value < 0) - return -1; - return 0; - } + inline int normalizeCmpValue(int value) + { + if (value > 0) + return 1; + if (value < 0) + return -1; + return 0; + } } // ListView: ListView::ListView(Evas_Object *parent, Eext_Circle_Surface *parentCircleSurface) - : View() - , m_pListener(nullptr) - , m_CheckMode(false) - , m_CmpFunc() - , m_pCircleGenlist(nullptr) + : View() + , m_pListener(nullptr) + , m_CheckMode(false) + , m_CmpFunc() + , m_pCircleGenlist(nullptr) { - createListView(parent, parentCircleSurface); + createListView(parent, parentCircleSurface); } ListView::~ListView() @@ -59,322 +59,322 @@ ListView::~ListView() void ListView::setListener(IListViewListener *listener) { - m_pListener = listener; + m_pListener = listener; } void ListView::createListView(Evas_Object *parent, Eext_Circle_Surface *parentCircleSurface) { - setEo(elm_genlist_add(parent)); - setMode(ELM_LIST_COMPRESS); - setMultiSelection(false); - addSmartCb("realized", ListView::on_realized_cb, this); - addSmartCb("unrealized", ListView::on_unrealized_cb, this); - addSmartCb("longpressed", ListView::on_longpressed_cb, this); + setEo(elm_genlist_add(parent)); + setMode(ELM_LIST_COMPRESS); + setMultiSelection(false); + addSmartCb("realized", ListView::on_realized_cb, this); + addSmartCb("unrealized", ListView::on_unrealized_cb, this); + addSmartCb("longpressed", ListView::on_longpressed_cb, this); - if (parentCircleSurface) { - // Default settings: - m_pCircleGenlist = eext_circle_object_genlist_add(getEo(), parentCircleSurface); - if (m_pCircleGenlist) { - eext_circle_object_genlist_scroller_policy_set(m_pCircleGenlist, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO); - eext_rotary_object_event_activated_set(m_pCircleGenlist, true); - } - } + if (parentCircleSurface) { + // Default settings: + m_pCircleGenlist = eext_circle_object_genlist_add(getEo(), parentCircleSurface); + if (m_pCircleGenlist) { + eext_circle_object_genlist_scroller_policy_set(m_pCircleGenlist, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO); + eext_rotary_object_event_activated_set(m_pCircleGenlist, true); + } + } } bool ListView::appendItem(ListItem &listItem, ListItem *parent) { - Elm_Object_Item *parentItem = parent ? parent->getElmObjItem() : nullptr; + Elm_Object_Item *parentItem = parent ? parent->getElmObjItem() : nullptr; - listItem.m_pOwner = this; - Elm_Object_Item *elmItem = elm_genlist_item_append(getEo(), listItem.m_ItemStyle->m_pGenlistItemClass, - &listItem, parentItem, listItem.getType(), on_item_selected_cb, this); - listItem.setElmObjItem(elmItem); - return elmItem != nullptr; + listItem.m_pOwner = this; + Elm_Object_Item *elmItem = elm_genlist_item_append(getEo(), listItem.m_ItemStyle->m_pGenlistItemClass, + &listItem, parentItem, listItem.getType(), on_item_selected_cb, this); + listItem.setElmObjItem(elmItem); + return elmItem != nullptr; } bool ListView::insertBeforeItem(ListItem &listItem, ListItem &before, ListItem *parent) { - Elm_Object_Item *parentItem = parent ? parent->getElmObjItem() : nullptr; + Elm_Object_Item *parentItem = parent ? parent->getElmObjItem() : nullptr; - listItem.m_pOwner = this; - Elm_Object_Item *elmItem = elm_genlist_item_insert_before(getEo(), listItem.m_ItemStyle->m_pGenlistItemClass, - &listItem, parentItem, before, listItem.getType(), on_item_selected_cb, this); - listItem.setElmObjItem(elmItem); - return elmItem != nullptr; + listItem.m_pOwner = this; + Elm_Object_Item *elmItem = elm_genlist_item_insert_before(getEo(), listItem.m_ItemStyle->m_pGenlistItemClass, + &listItem, parentItem, before, listItem.getType(), on_item_selected_cb, this); + listItem.setElmObjItem(elmItem); + return elmItem != nullptr; } bool ListView::prependItem(ListItem &listItem, ListItem *parent) { - Elm_Object_Item *parentItem = parent ? parent->getElmObjItem() : nullptr; + Elm_Object_Item *parentItem = parent ? parent->getElmObjItem() : nullptr; - listItem.m_pOwner = this; - Elm_Object_Item *elmItem = elm_genlist_item_prepend(getEo(), listItem.m_ItemStyle->m_pGenlistItemClass, - &listItem, parentItem, listItem.getType(), on_item_selected_cb, this); + listItem.m_pOwner = this; + Elm_Object_Item *elmItem = elm_genlist_item_prepend(getEo(), listItem.m_ItemStyle->m_pGenlistItemClass, + &listItem, parentItem, listItem.getType(), on_item_selected_cb, this); - listItem.setElmObjItem(elmItem); - return elmItem != nullptr; + listItem.setElmObjItem(elmItem); + return elmItem != nullptr; } bool ListView::sortedInsertItem(ListItem &listItem, ListItem *parent) { - Elm_Object_Item *parentItem = parent ? parent->getElmObjItem() : nullptr; - - listItem.m_pOwner = this; - Elm_Object_Item *elmItem = elm_genlist_item_sorted_insert - ( - getEo(), - listItem.m_ItemStyle->m_pGenlistItemClass, - &listItem, - parentItem, - listItem.getType(), - [](const void *data1, const void *data2)->int - { - 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) - res = normalizeCmpValue(item1->m_pOwner->m_CmpFunc(*item1, *item2)); - return res; - }, - on_item_selected_cb, - this); - - listItem.setElmObjItem(elmItem); - return elmItem != nullptr; + Elm_Object_Item *parentItem = parent ? parent->getElmObjItem() : nullptr; + + listItem.m_pOwner = this; + Elm_Object_Item *elmItem = elm_genlist_item_sorted_insert + ( + getEo(), + listItem.m_ItemStyle->m_pGenlistItemClass, + &listItem, + parentItem, + listItem.getType(), + [](const void *data1, const void *data2)->int + { + 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) + res = normalizeCmpValue(item1->m_pOwner->m_CmpFunc(*item1, *item2)); + return res; + }, + on_item_selected_cb, + this); + + listItem.setElmObjItem(elmItem); + return elmItem != nullptr; } void ListView::setCmpFunc(CmpFunc fn) { - m_CmpFunc = fn; + m_CmpFunc = fn; } void ListView::deleteItem(ListItem &listItem) { - elm_object_item_del(listItem.getElmObjItem()); + elm_object_item_del(listItem.getElmObjItem()); } ListItemCollection ListView::getItems() const { - ListItemCollection list; - Elm_Object_Item *elmItem = elm_genlist_first_item_get(getEo()); - while (elmItem) - { - void *data = elm_object_item_data_get(elmItem); - MSG_ASSERT(data, "Genlist item data is NULL"); - if (data) - { - ListItem *listItem = static_cast(data); - list.push_back(listItem); - } - elmItem = elm_genlist_item_next_get(elmItem); - } + ListItemCollection list; + Elm_Object_Item *elmItem = elm_genlist_first_item_get(getEo()); + while (elmItem) + { + void *data = elm_object_item_data_get(elmItem); + MSG_ASSERT(data, "Genlist item data is NULL"); + if (data) + { + ListItem *listItem = static_cast(data); + list.push_back(listItem); + } + elmItem = elm_genlist_item_next_get(elmItem); + } - return list; + return list; } ListItemCollection ListView::getRealizedItems() const { - ListItemCollection collection; - Eina_List *list = elm_genlist_realized_items_get(getEo()); - if (list) - { - void *obj = nullptr; - Eina_List *l = nullptr; + ListItemCollection collection; + Eina_List *list = elm_genlist_realized_items_get(getEo()); + if (list) + { + void *obj = nullptr; + Eina_List *l = nullptr; - EINA_LIST_FOREACH(list, l, obj) - { - collection.push_back(getItem((Elm_Object_Item *)obj)); - } + EINA_LIST_FOREACH(list, l, obj) + { + collection.push_back(getItem((Elm_Object_Item *)obj)); + } - eina_list_free(list); - } + eina_list_free(list); + } - return collection; + return collection; } ListItem *ListView::getFirstItem() const { - return getItem(elm_genlist_first_item_get(getEo())); + return getItem(elm_genlist_first_item_get(getEo())); } ListItem *ListView::getLastItem() const { - return getItem(elm_genlist_last_item_get(getEo())); + return getItem(elm_genlist_last_item_get(getEo())); } void ListView::showItem(ListItem &listItem, Elm_Genlist_Item_Scrollto_Type type) { - elm_genlist_item_show(listItem.getElmObjItem(), type); + elm_genlist_item_show(listItem.getElmObjItem(), type); } void ListView::clear() { - elm_genlist_clear(getEo()); + elm_genlist_clear(getEo()); } bool ListView::isEmpty() const { - return elm_genlist_first_item_get(getEo()) == nullptr; + return elm_genlist_first_item_get(getEo()) == nullptr; } void ListView::setMode(Elm_List_Mode mode) { - elm_genlist_mode_set(getEo(), mode); + elm_genlist_mode_set(getEo(), mode); } void ListView::setHomogeneous(bool isHomogeneous) { - elm_genlist_homogeneous_set(getEo(), isHomogeneous); + elm_genlist_homogeneous_set(getEo(), isHomogeneous); } ListItem *ListView::getSelectedItem() const { - Elm_Object_Item *elmItem = elm_genlist_selected_item_get(getEo()); - return ListItem::staticCast(elmItem); + Elm_Object_Item *elmItem = elm_genlist_selected_item_get(getEo()); + return ListItem::staticCast(elmItem); } unsigned ListView::getItemsCount() const { - return elm_genlist_items_count(getEo()); + return elm_genlist_items_count(getEo()); } ListItem *ListView::getNextItem(ListItem &item) const { - return ListItem::staticCast(elm_genlist_item_next_get(item)); + return ListItem::staticCast(elm_genlist_item_next_get(item)); } ListItem *ListView::getPrevItem(ListItem &item) const { - return ListItem::staticCast(elm_genlist_item_prev_get(item)); + return ListItem::staticCast(elm_genlist_item_prev_get(item)); } void ListView::demoteItem(ListItem &item) { - elm_genlist_item_demote(item); + elm_genlist_item_demote(item); } void ListView::promoteItem(ListItem &item) { - elm_genlist_item_promote(item); + elm_genlist_item_promote(item); } void ListView::setFilter(void *key) { - elm_genlist_filter_set(getEo(), key); + elm_genlist_filter_set(getEo(), key); } void ListView::notifyListener(void *data, Evas_Object *obj, void *event_info, ListenerMethod method) { - ListItem *item = ListItem::staticCast(event_info); - MSG_ASSERT(item, "Item is null"); + ListItem *item = ListItem::staticCast(event_info); + MSG_ASSERT(item, "Item is null"); - if (item) - { - ListView *owner = item->getOwner(); - MSG_ASSERT(owner, "ListItem::owner is null"); + if (item) + { + ListView *owner = item->getOwner(); + MSG_ASSERT(owner, "ListItem::owner is null"); - if (owner && owner->m_pListener) - (owner->m_pListener->*method)(*item); - } + if (owner && owner->m_pListener) + (owner->m_pListener->*method)(*item); + } } void ListView::setCheckMode(bool check) { - m_CheckMode = check; + m_CheckMode = check; } bool ListView::getCheckMode() const { - return m_CheckMode; + return m_CheckMode; } void ListView::checkAllItems(bool check, bool updateUi) { - for (ListItem *item: getItems()) - { - if (item->isCheckable()) - item->setCheckedState(check, updateUi); - } + for (ListItem *item: getItems()) + { + if (item->isCheckable()) + item->setCheckedState(check, updateUi); + } } void ListView::updateRealizedItems() { - elm_genlist_realized_items_update(getEo()); + elm_genlist_realized_items_update(getEo()); } void ListView::enabledAlign(bool enabled) { - elm_object_scroll_item_align_enabled_set(getEo(), enabled); + elm_object_scroll_item_align_enabled_set(getEo(), enabled); } void ListView::setRealizationMode(bool mode) { - elm_genlist_realization_mode_set(getEo(), mode); + elm_genlist_realization_mode_set(getEo(), mode); } void ListView::setMultiSelection(bool value) { - elm_genlist_multi_select_set(getEo(), value); + elm_genlist_multi_select_set(getEo(), value); } bool ListView::getMultiSelection() const { - return elm_genlist_multi_select_get(getEo()); + return elm_genlist_multi_select_get(getEo()); } unsigned ListView::getCheckedItemsCount() const { - unsigned count = 0; - auto items = getItems(); - for(auto *item : items) { - if (item->getCheckedState()) - ++count; - } - return count; + unsigned count = 0; + auto items = getItems(); + for(auto *item : items) { + if (item->getCheckedState()) + ++count; + } + return count; } unsigned ListView::getCheckableItemsCount() const { - unsigned count = 0; - auto items = getItems(); - for(auto *item : items) { - if (item->isCheckable()) - ++count; - } - return count; + unsigned count = 0; + auto items = getItems(); + for(auto *item : items) { + if (item->isCheckable()) + ++count; + } + return count; } void ListView::on_item_selected_cb(void *data, Evas_Object *obj, void *event_info) { - ListItem *item = ListItem::staticCast(event_info); - item->setSelected(false); + ListItem *item = ListItem::staticCast(event_info); + item->setSelected(false); - if (item->getOwner()->getCheckMode() && item->isCheckable()) { - item->changeCheckedState(true); - notifyListener(data, obj, event_info, &IListViewListener::onListItemChecked); - } else { - if (item->m_OnSelectedCb) - item->m_OnSelectedCb(*item); - notifyListener(data, obj, event_info, &IListViewListener::onListItemSelected); - } + if (item->getOwner()->getCheckMode() && item->isCheckable()) { + item->changeCheckedState(true); + notifyListener(data, obj, event_info, &IListViewListener::onListItemChecked); + } else { + if (item->m_OnSelectedCb) + item->m_OnSelectedCb(*item); + notifyListener(data, obj, event_info, &IListViewListener::onListItemSelected); + } } void ListView::on_realized_cb(void *data, Evas_Object *obj, void *event_info) { - ListItem *item = ListItem::staticCast(event_info); - item->onRealized(*item); + ListItem *item = ListItem::staticCast(event_info); + item->onRealized(*item); } void ListView::on_unrealized_cb(void *data, Evas_Object *obj, void *event_info) { - ListItem *item = ListItem::staticCast(event_info); - item->onUnrealized(*item); + ListItem *item = ListItem::staticCast(event_info); + item->onUnrealized(*item); } void ListView::on_longpressed_cb(void *data, Evas_Object *obj, void *event_info) { - ListItem *item = ListItem::staticCast(event_info); - item->setSelected(false); - if (!item->getOwner()->getCheckMode()) - notifyListener(data, obj, event_info, &IListViewListener::onListItemLongPressed); + ListItem *item = ListItem::staticCast(event_info); + item->setSelected(false); + if (!item->getOwner()->getCheckMode()) + notifyListener(data, obj, event_info, &IListViewListener::onListItemLongPressed); } diff --git a/src/Common/View/src/MbeRecipientsView.cpp b/src/Common/View/src/MbeRecipientsView.cpp index 76d9be7..70cf9f9 100644 --- a/src/Common/View/src/MbeRecipientsView.cpp +++ b/src/Common/View/src/MbeRecipientsView.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -20,98 +20,98 @@ using namespace Msg; MbeRecipientsView::MbeRecipientsView(Evas_Object *parent) - : m_pListener(nullptr) - , m_pSelectedItem(nullptr) - , m_pChangedJob(nullptr) + : m_pListener(nullptr) + , m_pSelectedItem(nullptr) + , m_pChangedJob(nullptr) { - setEo(elm_multibuttonentry_add(parent)); - elm_multibuttonentry_editable_set(getEo(), false); - elm_multibuttonentry_expanded_set(getEo(), true); - elm_object_tree_focus_allow_set(getEo(), false); - - addSmartCb("item,clicked", makeCbFirst(&MbeRecipientsView::onMbeItemClicked), this); - addSmartCb("item,added", makeCbFirst(&MbeRecipientsView::onMbeChanged), this); - addSmartCb("item,deleted", makeCbFirst(&MbeRecipientsView::onMbeChanged), this); + setEo(elm_multibuttonentry_add(parent)); + elm_multibuttonentry_editable_set(getEo(), false); + elm_multibuttonentry_expanded_set(getEo(), true); + elm_object_tree_focus_allow_set(getEo(), false); + + addSmartCb("item,clicked", makeCbFirst(&MbeRecipientsView::onMbeItemClicked), this); + addSmartCb("item,added", makeCbFirst(&MbeRecipientsView::onMbeChanged), this); + addSmartCb("item,deleted", makeCbFirst(&MbeRecipientsView::onMbeChanged), this); } MbeRecipientsView::~MbeRecipientsView() { - if (m_pChangedJob) - { - ecore_job_del(m_pChangedJob); - m_pChangedJob = nullptr; - } + if (m_pChangedJob) + { + ecore_job_del(m_pChangedJob); + m_pChangedJob = nullptr; + } } void MbeRecipientsView::appendItem(MbeRecipientItem &item) { - Elm_Object_Item *elmItem = elm_multibuttonentry_item_append(getEo(), item.getDispName().c_str(), nullptr, &item); - item.setElmObjItem(elmItem); + Elm_Object_Item *elmItem = elm_multibuttonentry_item_append(getEo(), item.getDispName().c_str(), nullptr, &item); + item.setElmObjItem(elmItem); } int MbeRecipientsView::getItemsCount() const { - unsigned int res = 0; - const Eina_List* items = elm_multibuttonentry_items_get(getEo()); - if (items) - res = eina_list_count(items); - return res; + unsigned int res = 0; + const Eina_List* items = elm_multibuttonentry_items_get(getEo()); + if (items) + res = eina_list_count(items); + return res; } std::vector MbeRecipientsView::getItems() const { - std::vector res; + std::vector res; - Elm_Object_Item *elmItem = elm_multibuttonentry_first_item_get(getEo()); - while (elmItem) - { - MbeRecipientItem *item = static_cast(elm_object_item_data_get(elmItem)); - res.push_back(item); - elmItem = elm_multibuttonentry_item_next_get(elmItem); - } + Elm_Object_Item *elmItem = elm_multibuttonentry_first_item_get(getEo()); + while (elmItem) + { + MbeRecipientItem *item = static_cast(elm_object_item_data_get(elmItem)); + res.push_back(item); + elmItem = elm_multibuttonentry_item_next_get(elmItem); + } - return res; + return res; } MbeRecipientItem *MbeRecipientsView::getSelectedItem() const { - MbeRecipientItem *pSelected = ViewItem::staticCast(elm_multibuttonentry_selected_item_get(getEo())); - return pSelected ? pSelected : m_pSelectedItem; + MbeRecipientItem *pSelected = ViewItem::staticCast(elm_multibuttonentry_selected_item_get(getEo())); + return pSelected ? pSelected : m_pSelectedItem; } bool MbeRecipientsView::isEmpty() const { - return elm_multibuttonentry_first_item_get(getEo()) == nullptr; + return elm_multibuttonentry_first_item_get(getEo()) == nullptr; } void MbeRecipientsView::clear() { - elm_multibuttonentry_clear(getEo()); + elm_multibuttonentry_clear(getEo()); } void MbeRecipientsView::setListener(IMbeRecipientsListener *pListener) { - m_pListener = pListener; + m_pListener = pListener; } void MbeRecipientsView::onMbeItemClicked(Evas_Object *obj, void *eventInfo) { - m_pSelectedItem = ViewItem::staticCast(eventInfo); - if (m_pListener) - m_pListener->onMbeItemClicked(*m_pSelectedItem); + m_pSelectedItem = ViewItem::staticCast(eventInfo); + if (m_pListener) + m_pListener->onMbeItemClicked(*m_pSelectedItem); } void MbeRecipientsView::onMbeChanged(Evas_Object *obj, void *eventInfo) { - if (!m_pChangedJob) - m_pChangedJob = ecore_job_add - ( - [](void *data) - { - MbeRecipientsView *self = static_cast(data); - self->m_pChangedJob = nullptr; - if (self->m_pListener) - self->m_pListener->onMbeChanged(); - }, - this); + if (!m_pChangedJob) + m_pChangedJob = ecore_job_add + ( + [](void *data) + { + MbeRecipientsView *self = static_cast(data); + self->m_pChangedJob = nullptr; + if (self->m_pListener) + self->m_pListener->onMbeChanged(); + }, + this); } diff --git a/src/Common/View/src/MoreOption.cpp b/src/Common/View/src/MoreOption.cpp index f290165..cb4dc95 100644 --- a/src/Common/View/src/MoreOption.cpp +++ b/src/Common/View/src/MoreOption.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -23,9 +23,9 @@ using namespace Msg; MoreOption::MoreOption(Evas_Object *parent) { - setEo(eext_more_option_add(parent)); - addSmartCb("item,selected", makeCbFirst(&MoreOption::onItemSelected), this); - addSmartCb("item,clicked", makeCbFirst(&MoreOption::onItemClicked), this); + setEo(eext_more_option_add(parent)); + addSmartCb("item,selected", makeCbFirst(&MoreOption::onItemSelected), this); + addSmartCb("item,clicked", makeCbFirst(&MoreOption::onItemClicked), this); } MoreOption::~MoreOption() @@ -33,118 +33,118 @@ MoreOption::~MoreOption() } void MoreOption::prepareItem(Eext_Object_Item *item, - const TText &mainText, - Evas_Object *icon, - MoreOptionCb cb, - void *userData) + const TText &mainText, + Evas_Object *icon, + MoreOptionCb cb, + void *userData) { - m_ItemMap[item] = {cb, userData}; - eext_more_option_item_part_content_set(item, "item,icon", icon); + m_ItemMap[item] = {cb, userData}; + eext_more_option_item_part_content_set(item, "item,icon", icon); - if (mainText.isTranslatable()) - eext_more_option_item_domain_translatable_part_text_set(item, "selector,main_text", mainText.getDomain(), mainText.getMsg()); - else - eext_more_option_item_part_text_set(item, "selector,main_text", mainText.getMsg()); + if (mainText.isTranslatable()) + eext_more_option_item_domain_translatable_part_text_set(item, "selector,main_text", mainText.getDomain(), mainText.getMsg()); + else + eext_more_option_item_part_text_set(item, "selector,main_text", mainText.getMsg()); } void MoreOption::prepareItem(Eext_Object_Item *item, - const TText &mainText, - const std::string &imgGroupName, - MoreOptionCb cb, - void *userData) + const TText &mainText, + const std::string &imgGroupName, + MoreOptionCb cb, + void *userData) { - Evas_Object *icon = elm_image_add(getEo()); - static const std::string imagesPath = PathUtils::getResourcePath(IMAGES_EDJ_PATH); - elm_image_file_set(icon, imagesPath.c_str(), imgGroupName.c_str()); - prepareItem(item, mainText, icon, cb, userData); + Evas_Object *icon = elm_image_add(getEo()); + static const std::string imagesPath = PathUtils::getResourcePath(IMAGES_EDJ_PATH); + elm_image_file_set(icon, imagesPath.c_str(), imgGroupName.c_str()); + prepareItem(item, mainText, icon, cb, userData); } Eext_Object_Item *MoreOption::appendItem(const TText &mainText, - const std::string &imgGroupName, - MoreOptionCb cb, - void *userData) + const std::string &imgGroupName, + MoreOptionCb cb, + void *userData) { - auto *item = eext_more_option_item_append(getEo()); - prepareItem(item, mainText, imgGroupName, cb, userData); - return item; + auto *item = eext_more_option_item_append(getEo()); + prepareItem(item, mainText, imgGroupName, cb, userData); + return item; } Eext_Object_Item *MoreOption::appendItem(const TText &mainText, - Evas_Object *icon, - MoreOptionCb cb, - void *userData) + Evas_Object *icon, + MoreOptionCb cb, + void *userData) { - auto *item = eext_more_option_item_append(getEo()); - prepareItem(item, mainText, icon, cb, userData); - return item; + auto *item = eext_more_option_item_append(getEo()); + prepareItem(item, mainText, icon, cb, userData); + return item; } Eext_Object_Item *MoreOption::prependItem(const TText &mainText, - Evas_Object *icon, - MoreOptionCb cb, - void *userData) + Evas_Object *icon, + MoreOptionCb cb, + void *userData) { - auto *item = eext_more_option_item_prepend(getEo()); - prepareItem(item, mainText, icon, cb, userData); - return item; + auto *item = eext_more_option_item_prepend(getEo()); + prepareItem(item, mainText, icon, cb, userData); + return item; } Eext_Object_Item *MoreOption::prependItem(const TText &mainText, - const std::string &imgGroupName, - MoreOptionCb cb, - void *userData) + const std::string &imgGroupName, + MoreOptionCb cb, + void *userData) { - auto *item = eext_more_option_item_prepend(getEo()); - prepareItem(item, mainText, imgGroupName, cb, userData); - return item; + auto *item = eext_more_option_item_prepend(getEo()); + prepareItem(item, mainText, imgGroupName, cb, userData); + return item; } void MoreOption::removeItem(Eext_Object_Item *item) { - if (item) { - m_ItemMap.erase(item); - eext_more_option_item_del(item); - } + if (item) { + m_ItemMap.erase(item); + eext_more_option_item_del(item); + } } void MoreOption::setDirection(Eext_More_Option_Direction direction) { - eext_more_option_direction_set(getEo(), direction); + eext_more_option_direction_set(getEo(), direction); } void MoreOption::setOpened(bool opened) { - eext_more_option_opened_set(getEo(), opened); + eext_more_option_opened_set(getEo(), opened); } bool MoreOption::getOpened() const { - return eext_more_option_opened_get(getEo()); + return eext_more_option_opened_get(getEo()); } void MoreOption::addOpenedCb(Evas_Smart_Cb cb, void *data) { - addSmartCb("more,option,opened", cb, data); + addSmartCb("more,option,opened", cb, data); } void MoreOption::addClosedCb(Evas_Smart_Cb cb, void *data) { - addSmartCb("more,option,closed", cb, data); + addSmartCb("more,option,closed", cb, data); } void MoreOption::onItemClicked(Evas_Object *obj, void *event) { - MSG_LOG(""); - Eext_Object_Item *item = (Eext_Object_Item *)event; - eext_more_option_opened_set(obj, false); - auto it = m_ItemMap.find(item); - if (it != m_ItemMap.end() && it->second.cb) - it->second.cb(*this, it->second.userData); + MSG_LOG(""); + Eext_Object_Item *item = (Eext_Object_Item *)event; + eext_more_option_opened_set(obj, false); + auto it = m_ItemMap.find(item); + if (it != m_ItemMap.end() && it->second.cb) + it->second.cb(*this, it->second.userData); } void MoreOption::onItemSelected(Evas_Object *obj, void *event) { - MSG_LOG(""); + MSG_LOG(""); } diff --git a/src/Common/View/src/NaviFrameItem.cpp b/src/Common/View/src/NaviFrameItem.cpp index 0e5bc91..22eb9bf 100644 --- a/src/Common/View/src/NaviFrameItem.cpp +++ b/src/Common/View/src/NaviFrameItem.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -22,11 +22,11 @@ using namespace Msg; NaviFrameItem::NaviFrameItem(NaviFrameView &parent) - : ViewItem() - , m_Parent(parent) - , m_IsPopping(false) - , m_pPopCb(nullptr) - , m_pPopCbData(nullptr) + : ViewItem() + , m_Parent(parent) + , m_IsPopping(false) + , m_pPopCb(nullptr) + , m_pPopCbData(nullptr) { } @@ -36,38 +36,38 @@ NaviFrameItem::~NaviFrameItem() NaviFrameView &NaviFrameItem::getParent() { - return m_Parent; + return m_Parent; } const NaviFrameView &NaviFrameItem::getParent() const { - return m_Parent; + return m_Parent; } bool NaviFrameItem::isPopping() const { - return m_IsPopping; + return m_IsPopping; } void NaviFrameItem::setOnPopCb(PopCb cb, void *data) { - m_pPopCb = cb; - m_pPopCbData = data; + m_pPopCb = cb; + m_pPopCbData = data; } void NaviFrameItem::notifyOnPop() { - if (m_pPopCb) - m_pPopCb(*this, m_pPopCbData); + if (m_pPopCb) + m_pPopCb(*this, m_pPopCbData); } bool NaviFrameItem::onRequestPop() { - return true; + return true; } void NaviFrameItem::onAttached(ViewItem &item) { - ViewItem::onAttached(item); + ViewItem::onAttached(item); } diff --git a/src/Common/View/src/NaviFrameView.cpp b/src/Common/View/src/NaviFrameView.cpp index 8541a25..562f4b0 100644 --- a/src/Common/View/src/NaviFrameView.cpp +++ b/src/Common/View/src/NaviFrameView.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -21,19 +21,19 @@ using namespace Msg; namespace { - const char *naviTitleStyleEmpty = "empty"; - const char *transFinishedEvent = "transition,finished"; + const char *naviTitleStyleEmpty = "empty"; + const char *transFinishedEvent = "transition,finished"; } NaviFrameView::NaviFrameView(Evas_Object *parent) - : View() - , m_TransitionStatus(false) + : View() + , m_TransitionStatus(false) { - create(parent); + create(parent); } NaviFrameView::NaviFrameView(View &parent) - : NaviFrameView(parent.getEo()) + : NaviFrameView(parent.getEo()) { } @@ -43,169 +43,169 @@ NaviFrameView::~NaviFrameView() void NaviFrameView::create(Evas_Object *parent) { - setEo(elm_naviframe_add(parent)); - addSmartCb(transFinishedEvent, makeCbFirst(&NaviFrameView::onTransitionFinished), this); - show(); + setEo(elm_naviframe_add(parent)); + addSmartCb(transFinishedEvent, makeCbFirst(&NaviFrameView::onTransitionFinished), this); + show(); } void NaviFrameView::pause() { - NaviFrameItem *top = getTopFrame(); - if (top) - onPause(*top); + NaviFrameItem *top = getTopFrame(); + if (top) + onPause(*top); } void NaviFrameView::resume() { - NaviFrameItem *top = getTopFrame(); - if (top) - onResume(*top); + NaviFrameItem *top = getTopFrame(); + if (top) + onResume(*top); } bool NaviFrameView::isLastFrame() const { - return elm_naviframe_bottom_item_get(getEo()) == elm_naviframe_top_item_get(getEo()); + return elm_naviframe_bottom_item_get(getEo()) == elm_naviframe_top_item_get(getEo()); } NaviFrameItem *NaviFrameView::getTopFrame() const { - return ViewItem::staticCast(elm_naviframe_top_item_get(getEo())); + return ViewItem::staticCast(elm_naviframe_top_item_get(getEo())); } unsigned NaviFrameView::getItemsCount() const { - unsigned res = 0; - Eina_List *list = elm_naviframe_items_get(getEo()); - if (list) { - res = eina_list_count(list); - eina_list_free(list); - } - return res; + unsigned res = 0; + Eina_List *list = elm_naviframe_items_get(getEo()); + if (list) { + res = eina_list_count(list); + eina_list_free(list); + } + return res; } NaviFrameItemList NaviFrameView::getItems() const { - NaviFrameItemList result; - Eina_List *list = elm_naviframe_items_get(getEo()); + NaviFrameItemList result; + Eina_List *list = elm_naviframe_items_get(getEo()); - if (list) { - Eina_List *l = nullptr; - void *obj = nullptr; + if (list) { + Eina_List *l = nullptr; + void *obj = nullptr; - EINA_LIST_FOREACH(list, l, obj) { - NaviFrameItem *item = static_cast(elm_object_item_data_get((Elm_Object_Item*)obj)); - result.push_back(item); - } + EINA_LIST_FOREACH(list, l, obj) { + NaviFrameItem *item = static_cast(elm_object_item_data_get((Elm_Object_Item*)obj)); + result.push_back(item); + } - eina_list_free(list); - } - return result; + eina_list_free(list); + } + return result; } bool NaviFrameView::isEmpty() const { - return getItemsCount() <= 0; + return getItemsCount() <= 0; } void NaviFrameView::push(NaviFrameItem &item) { - m_TransitionStatus = !isEmpty(); - pause(); - Elm_Object_Item *it = elm_naviframe_item_push(getEo(), nullptr, nullptr, nullptr, nullptr, naviTitleStyleEmpty); - item.setElmObjItem(it); - processSignal(); - resume(); + m_TransitionStatus = !isEmpty(); + pause(); + Elm_Object_Item *it = elm_naviframe_item_push(getEo(), nullptr, nullptr, nullptr, nullptr, naviTitleStyleEmpty); + item.setElmObjItem(it); + processSignal(); + resume(); } void NaviFrameView::pop() { - auto *topFrame = getTopFrame(); - if (topFrame) - pop(*topFrame); + auto *topFrame = getTopFrame(); + if (topFrame) + pop(*topFrame); } void NaviFrameView::pop(NaviFrameItem &item) { - if (item.m_IsPopping || !item.onRequestPop()) - return; - - item.m_IsPopping = true; - item.notifyOnPop(); - - // Workaround solution to avoid rejected JIRA issue: http://suprem.sec.samsung.net/jira/browse/TSAM-6776 - if (getTransitionStatus()) { - m_ItemsToDelete.push_back(&item); - } else { - if (getTopFrame() == &item) { - m_TransitionStatus = getItemsCount() > 1; - pause(); - elm_naviframe_item_pop(getEo()); - resume(); - } else { - pause(); - item.destroy(); - resume(); - } - } + if (item.m_IsPopping || !item.onRequestPop()) + return; + + item.m_IsPopping = true; + item.notifyOnPop(); + + // Workaround solution to avoid rejected JIRA issue: http://suprem.sec.samsung.net/jira/browse/TSAM-6776 + if (getTransitionStatus()) { + m_ItemsToDelete.push_back(&item); + } else { + if (getTopFrame() == &item) { + m_TransitionStatus = getItemsCount() > 1; + pause(); + elm_naviframe_item_pop(getEo()); + resume(); + } else { + pause(); + item.destroy(); + resume(); + } + } } void NaviFrameView::insertToBottom(NaviFrameItem &item) { - Elm_Object_Item *before = elm_naviframe_bottom_item_get(getEo()); - Elm_Object_Item *insert = nullptr; + Elm_Object_Item *before = elm_naviframe_bottom_item_get(getEo()); + Elm_Object_Item *insert = nullptr; - if (before) { - insert = elm_naviframe_item_insert_before(getEo(), before, nullptr, nullptr, nullptr, nullptr, naviTitleStyleEmpty); - item.setElmObjItem(insert); - } else { - m_TransitionStatus = !isEmpty(); - pause(); - insert = elm_naviframe_item_push(getEo(), nullptr, nullptr, nullptr, nullptr, naviTitleStyleEmpty); - item.setElmObjItem(insert); - resume(); - } + if (before) { + insert = elm_naviframe_item_insert_before(getEo(), before, nullptr, nullptr, nullptr, nullptr, naviTitleStyleEmpty); + item.setElmObjItem(insert); + } else { + m_TransitionStatus = !isEmpty(); + pause(); + insert = elm_naviframe_item_push(getEo(), nullptr, nullptr, nullptr, nullptr, naviTitleStyleEmpty); + item.setElmObjItem(insert); + resume(); + } } void NaviFrameView::promote(NaviFrameItem &item) { - bool isTop = &item == getTopFrame(); - if (!isTop) { - m_TransitionStatus = true; - pause(); - elm_naviframe_item_promote(item); - resume(); - } + bool isTop = &item == getTopFrame(); + if (!isTop) { + m_TransitionStatus = true; + pause(); + elm_naviframe_item_promote(item); + resume(); + } } void NaviFrameView::onTransitionFinished(Evas_Object *obj, void *eventInfo) { - MSG_LOG(""); - m_TransitionStatus = false; + MSG_LOG(""); + m_TransitionStatus = false; - for (NaviFrameItem *item: m_ItemsToDelete) { - item->destroy(); - } - m_ItemsToDelete.clear(); + for (NaviFrameItem *item: m_ItemsToDelete) { + item->destroy(); + } + m_ItemsToDelete.clear(); - auto *frame = getTopFrame(); - if (frame) - frame->onTransitionFinished(*frame); + auto *frame = getTopFrame(); + if (frame) + frame->onTransitionFinished(*frame); } void NaviFrameView::onBeforeDelete(View &view) { - pause(); + pause(); } void NaviFrameView::destroy() { - evas_object_smart_callback_del(getEo(), transFinishedEvent, makeCbFirst(&NaviFrameView::onTransitionFinished)); - View::destroy(); + evas_object_smart_callback_del(getEo(), transFinishedEvent, makeCbFirst(&NaviFrameView::onTransitionFinished)); + View::destroy(); } bool NaviFrameView::getTransitionStatus() const { - // TODO: Move functionality for gets TransitionStatus to EFL (elm_naviframe) side. - return m_TransitionStatus; + // TODO: Move functionality for gets TransitionStatus to EFL (elm_naviframe) side. + return m_TransitionStatus; } diff --git a/src/Common/View/src/NoContentLayout.cpp b/src/Common/View/src/NoContentLayout.cpp index 67ceefa..2c1b2c9 100644 --- a/src/Common/View/src/NoContentLayout.cpp +++ b/src/Common/View/src/NoContentLayout.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -20,8 +20,8 @@ using namespace Msg; NoContentLayout::NoContentLayout(Evas_Object *parent) { - setEo(elm_layout_add(parent)); - elm_layout_theme_set(getEo(), "layout", "nocontents", "text"); + setEo(elm_layout_add(parent)); + elm_layout_theme_set(getEo(), "layout", "nocontents", "text"); } NoContentLayout::~NoContentLayout() @@ -30,20 +30,20 @@ NoContentLayout::~NoContentLayout() void NoContentLayout::setTitle(const TText &text) { - View::setText(text, "elm.text.title"); + View::setText(text, "elm.text.title"); } void NoContentLayout::setText(const TText &text) { - View::setText(text, "elm.text"); + View::setText(text, "elm.text"); } void NoContentLayout::setIcon(Evas_Object *icon) { - setContent(icon, "elm.swallow.icon"); + setContent(icon, "elm.swallow.icon"); } void NoContentLayout::enableTitle(bool enable) { - emitSignal("elm,state,title,enable", "elm"); + emitSignal("elm,state,title,enable", "elm"); } diff --git a/src/Common/View/src/Popup.cpp b/src/Common/View/src/Popup.cpp index 8978c35..7a8fd5b 100644 --- a/src/Common/View/src/Popup.cpp +++ b/src/Common/View/src/Popup.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -22,167 +22,167 @@ using namespace Msg; namespace { - const char *buttonCbKey = "cb"; - const char *buttonCbDataKey = "cb-data"; - const char *titlePart = "title,text"; - const char *buttonPart1 = "button1"; - const char *buttonPart2 = "button2"; - const char *buttonBottomStyle = "bottom"; - const char *buttonLeftStyle = "popup/circle/left"; - const char *buttonRightStyle = "popup/circle/right"; + const char *buttonCbKey = "cb"; + const char *buttonCbDataKey = "cb-data"; + const char *titlePart = "title,text"; + const char *buttonPart1 = "button1"; + const char *buttonPart2 = "button2"; + const char *buttonBottomStyle = "bottom"; + const char *buttonLeftStyle = "popup/circle/left"; + const char *buttonRightStyle = "popup/circle/right"; } const double Popup::defaultTimeOut = 2.0; Popup::Popup() - : BasePopup(elm_popup_add(getWindow())) - , m_pShowIdler(nullptr) + : BasePopup(elm_popup_add(getWindow())) + , m_pShowIdler(nullptr) { - addSmartCb("block,clicked", on_popup_block_clicked_cb, this); - addSmartCb("timeout", on_timeout_cb, this); - addSmartCb("dismissed", on_dismissed_cb, this); - expand(); + addSmartCb("block,clicked", on_popup_block_clicked_cb, this); + addSmartCb("timeout", on_timeout_cb, this); + addSmartCb("dismissed", on_dismissed_cb, this); + expand(); } Popup::~Popup() { - MSG_LOG("Destructor"); - if (m_pShowIdler) - { - ecore_idler_del(m_pShowIdler); - m_pShowIdler = nullptr; - } + MSG_LOG("Destructor"); + if (m_pShowIdler) + { + ecore_idler_del(m_pShowIdler); + m_pShowIdler = nullptr; + } } void Popup::setTimeOut(double timeout) { - elm_popup_timeout_set(getEo(), timeout); + elm_popup_timeout_set(getEo(), timeout); } double Popup::getTimeOut() const { - return elm_popup_timeout_get(getEo()); + return elm_popup_timeout_get(getEo()); } Evas_Object *Popup::addButton(const char *part, PopupButtonCb buttonCb, void *userData) { - Evas_Object *btn = elm_button_add(getEo()); - evas_object_data_set(btn, buttonCbKey, (void*)buttonCb); - evas_object_data_set(btn, buttonCbDataKey, userData); - addSmartCb(btn, "clicked", on_button_clicked, this); - View::setContent(btn, part); - return btn; + Evas_Object *btn = elm_button_add(getEo()); + evas_object_data_set(btn, buttonCbKey, (void*)buttonCb); + evas_object_data_set(btn, buttonCbDataKey, userData); + addSmartCb(btn, "clicked", on_button_clicked, this); + View::setContent(btn, part); + return btn; } Evas_Object *Popup::addButton(const TText &text, const char *iconName, const char *part, PopupButtonCb buttonCb, void *userData) { - Evas_Object *button = addButton(part, buttonCb, userData); + Evas_Object *button = addButton(part, buttonCb, userData); - // Text: - if (text.getMsg()) - setText(button, text); + // Text: + if (text.getMsg()) + setText(button, text); - // Icon: - if (iconName) { - static const std::string imagesPath = PathUtils::getResourcePath(IMAGES_EDJ_PATH); - Evas_Object *icon = elm_image_add(button); - elm_image_file_set(icon, imagesPath.c_str(), iconName); - setContent(button, icon); - } + // Icon: + if (iconName) { + static const std::string imagesPath = PathUtils::getResourcePath(IMAGES_EDJ_PATH); + Evas_Object *icon = elm_image_add(button); + elm_image_file_set(icon, imagesPath.c_str(), iconName); + setContent(button, icon); + } - return button; + return button; } Evas_Object *Popup::addBottomButton(const TText &text, PopupButtonCb cb, void *userData) { - Evas_Object *button = addButton(text, nullptr, buttonPart1, cb, userData); - setStyle(button, buttonBottomStyle); - return button; + Evas_Object *button = addButton(text, nullptr, buttonPart1, cb, userData); + setStyle(button, buttonBottomStyle); + return button; } Evas_Object *Popup::addBottomButton(const char *iconName, PopupButtonCb cb, void *userData) { - Evas_Object *button = addButton(nullptr, iconName, buttonPart1, cb, userData); - setStyle(button, buttonBottomStyle); - return button; + Evas_Object *button = addButton(nullptr, iconName, buttonPart1, cb, userData); + setStyle(button, buttonBottomStyle); + return button; } Evas_Object *Popup::addLeftButton(const char *iconName, PopupButtonCb cb, void *userData) { - Evas_Object *button = addButton(nullptr, iconName, buttonPart1, cb, userData); - setStyle(button, buttonLeftStyle); - return button; + Evas_Object *button = addButton(nullptr, iconName, buttonPart1, cb, userData); + setStyle(button, buttonLeftStyle); + return button; } Evas_Object *Popup::addRightButton(const char *iconName, PopupButtonCb cb, void *userData) { - Evas_Object *button = addButton(nullptr, iconName, buttonPart2, cb, userData); - setStyle(button, buttonRightStyle); - return button; + Evas_Object *button = addButton(nullptr, iconName, buttonPart2, cb, userData); + setStyle(button, buttonRightStyle); + return button; } void Popup::setTitle(const TText &title) { - setText(title, titlePart); + setText(title, titlePart); } void Popup::dismiss() { - elm_popup_dismiss(getEo()); + elm_popup_dismiss(getEo()); } void Popup::show(bool deferred) { - if (!deferred) { - View::show(); - } else { - if (!m_pShowIdler) { - m_pShowIdler = ecore_idler_add - ( - [](void *data)->Eina_Bool - { - auto *self =(Popup*)data; - self->m_pShowIdler = nullptr; - self->View::show(); - return false; // Delete idler - }, - this); - } - } + if (!deferred) { + View::show(); + } else { + if (!m_pShowIdler) { + m_pShowIdler = ecore_idler_add + ( + [](void *data)->Eina_Bool + { + auto *self =(Popup*)data; + self->m_pShowIdler = nullptr; + self->View::show(); + return false; // Delete idler + }, + this); + } + } } void Popup::on_button_clicked(void *data, Evas_Object *obj, void *event_info) { - auto cb = (PopupButtonCb)evas_object_data_get(obj, buttonCbKey); - if (cb) { - void *userData = evas_object_data_get(obj, buttonCbDataKey); - auto *popup = static_cast(data); - cb(*popup, userData); - } + auto cb = (PopupButtonCb)evas_object_data_get(obj, buttonCbKey); + if (cb) { + void *userData = evas_object_data_get(obj, buttonCbDataKey); + auto *popup = static_cast(data); + cb(*popup, userData); + } } void Popup::on_popup_block_clicked_cb(void *data, Evas_Object *obj, void *event_info) { - auto *popup = static_cast(data); - if (popup->getDismissByOutsideTapFlag()) - popup->destroy(); + auto *popup = static_cast(data); + if (popup->getDismissByOutsideTapFlag()) + popup->destroy(); } void Popup::on_timeout_cb(void *data, Evas_Object *obj, void *event_info) { - MSG_LOG(""); - auto *popup = static_cast(data); - popup->destroy(); + MSG_LOG(""); + auto *popup = static_cast(data); + popup->destroy(); } void Popup::on_dismissed_cb(void *data, Evas_Object *obj, void *event_info) { - MSG_LOG(""); - auto *popup = static_cast(data); - popup->View::destroy(); + MSG_LOG(""); + auto *popup = static_cast(data); + popup->View::destroy(); } void Popup::defaultButtonCb(Popup &popup, void *userData) { - popup.destroy(); + popup.destroy(); } diff --git a/src/Common/View/src/PopupAttachmentListItem.cpp b/src/Common/View/src/PopupAttachmentListItem.cpp index ceeffb7..660d72c 100644 --- a/src/Common/View/src/PopupAttachmentListItem.cpp +++ b/src/Common/View/src/PopupAttachmentListItem.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -19,9 +19,9 @@ using namespace Msg; PopupAttachmentListItem::PopupAttachmentListItem(PopupList &parent, const std::string &text, const std::string &path, - PopupListItemPressedCb cb, void *userData) - : PopupCheckListItem(parent, text, cb, userData) - , m_FilePath(path) + PopupListItemPressedCb cb, void *userData) + : PopupCheckListItem(parent, text, cb, userData) + , m_FilePath(path) { } @@ -31,5 +31,5 @@ PopupAttachmentListItem::~PopupAttachmentListItem() const std::string &PopupAttachmentListItem::getFilePath() const { - return m_FilePath; + return m_FilePath; } diff --git a/src/Common/View/src/PopupList.cpp b/src/Common/View/src/PopupList.cpp index 59d2d48..6d42b33 100644 --- a/src/Common/View/src/PopupList.cpp +++ b/src/Common/View/src/PopupList.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -21,10 +21,10 @@ using namespace Msg; PopupList::PopupList() - : Popup() - , m_pList(nullptr) + : Popup() + , m_pList(nullptr) { - create(); + create(); } PopupList::~PopupList() @@ -33,51 +33,51 @@ PopupList::~PopupList() void PopupList::appendItem(PopupListItem &item) { - m_pList->appendItem(item); + m_pList->appendItem(item); } void PopupList::appendItem(const std::string &text, PopupListItemPressedCb cb, void *userData) { - m_pList->appendItem(*new PopupTextListItem(*this, text, cb, userData)); + m_pList->appendItem(*new PopupTextListItem(*this, text, cb, userData)); } void PopupList::appendItem(const std::string &text, const std::string &path, PopupListItemPressedCb cb, void *userData) { - m_pList->appendItem(*new PopupAttachmentListItem(*this, text, path, cb, userData)); + m_pList->appendItem(*new PopupAttachmentListItem(*this, text, path, cb, userData)); } void PopupList::create() { - elm_object_style_set(getEo(), "theme_bg"); - Evas_Object *list = createList(getEo()); - Popup::setContent(list); + elm_object_style_set(getEo(), "theme_bg"); + Evas_Object *list = createList(getEo()); + Popup::setContent(list); - //set popup's behavior - setDismissByOutsideTapFlag(true); + //set popup's behavior + setDismissByOutsideTapFlag(true); } Evas_Object *PopupList::createList(Evas_Object *parent) { - m_pList = new ListView(parent); - m_pList->setListener(this); - m_pList->show(); - m_pList->setMultiSelection(false); - m_pList->setMode(ELM_LIST_EXPAND); - return *m_pList; + m_pList = new ListView(parent); + m_pList->setListener(this); + m_pList->show(); + m_pList->setMultiSelection(false); + m_pList->setMode(ELM_LIST_EXPAND); + return *m_pList; } ListView &PopupList::getListView() { - return *m_pList; + return *m_pList; } const ListView &PopupList::getListView() const { - return *m_pList; + return *m_pList; } void PopupList::onListItemSelected(ListItem &listItem) { - PopupListItem &it = static_cast(listItem); - it.fireCallback(); + PopupListItem &it = static_cast(listItem); + it.fireCallback(); } diff --git a/src/Common/View/src/PopupListItem.cpp b/src/Common/View/src/PopupListItem.cpp index 9e9d0b5..bc7a5ae 100644 --- a/src/Common/View/src/PopupListItem.cpp +++ b/src/Common/View/src/PopupListItem.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -21,27 +21,27 @@ using namespace Msg; const ListItemStyleRef listItemStyle = ListItemStyle::create("type1"); PopupListItem::PopupListItem(PopupList &parent, PopupListItemPressedCb cb, void *userData) - : ListItem(listItemStyle) - , m_Parent(parent) - , m_Cb(cb) - , m_pUserData(userData) + : ListItem(listItemStyle) + , m_Parent(parent) + , m_Cb(cb) + , m_pUserData(userData) { } void PopupListItem::fireCallback() { - if (m_Cb) - m_Cb(*this, m_pUserData); + if (m_Cb) + m_Cb(*this, m_pUserData); } PopupList &PopupListItem::getParent() { - return m_Parent; + return m_Parent; } PopupTextListItem::PopupTextListItem(PopupList &parent, const std::string &text, PopupListItemPressedCb cb, void *userData) - : PopupListItem(parent, cb, userData) - , m_Text(text) + : PopupListItem(parent, cb, userData) + , m_Text(text) { } @@ -51,14 +51,14 @@ PopupTextListItem::~PopupTextListItem() std::string PopupTextListItem::getText(ListItem &item, const char *part) { - if (strcmp(part, "elm.text") == 0) - return m_Text; - return std::string(); + if (strcmp(part, "elm.text") == 0) + return m_Text; + return std::string(); } PopupCheckListItem::PopupCheckListItem(PopupList &parent, const std::string &text, PopupListItemPressedCb cb, void *userData) - : PopupListItem(parent, cb, userData) - , m_Text(text) + : PopupListItem(parent, cb, userData) + , m_Text(text) { } @@ -68,12 +68,12 @@ PopupCheckListItem::~PopupCheckListItem() const char *PopupCheckListItem::getCheckPart(ListItem &item) { - return "elm.swallow.end"; + return "elm.swallow.end"; } std::string PopupCheckListItem::getText(ListItem &item, const char *part) { - if (strcmp(part, "elm.text") == 0) - return m_Text; - return std::string(); + if (strcmp(part, "elm.text") == 0) + return m_Text; + return std::string(); } diff --git a/src/Common/View/src/PopupManager.cpp b/src/Common/View/src/PopupManager.cpp index dfef547..940eeef 100644 --- a/src/Common/View/src/PopupManager.cpp +++ b/src/Common/View/src/PopupManager.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -24,29 +24,29 @@ using namespace Msg; PopupManager::PopupManager(Window &window) - : m_pPopup(nullptr) - , m_Window(window) - , m_pPopupId(nullptr) + : m_pPopup(nullptr) + , m_Window(window) + , m_pPopupId(nullptr) { } Window &PopupManager::getWindow() const { - return m_Window; + return m_Window; } void PopupManager::addListener(IPopupManagerListener &listener) { - auto found = std::find(m_Listeners.begin(), m_Listeners.end(), &listener); - if (found == m_Listeners.end()) - m_Listeners.push_back(&listener); + auto found = std::find(m_Listeners.begin(), m_Listeners.end(), &listener); + if (found == m_Listeners.end()) + m_Listeners.push_back(&listener); } void PopupManager::removeListener(IPopupManagerListener &listener) { - auto found = std::find(m_Listeners.begin(), m_Listeners.end(), &listener); - if (found != m_Listeners.end()) - m_Listeners.erase(found); + auto found = std::find(m_Listeners.begin(), m_Listeners.end(), &listener); + if (found != m_Listeners.end()) + m_Listeners.erase(found); } PopupManager::~PopupManager() @@ -55,65 +55,65 @@ PopupManager::~PopupManager() void PopupManager::pop(void *id, bool anim) { - if (!id || (id == m_pPopupId)) - destroyPopup(anim); + if (!id || (id == m_pPopupId)) + destroyPopup(anim); } void PopupManager::pop(BasePopup *popup, bool anim) { - if (!popup || (popup == m_pPopup)) - destroyPopup(anim); + if (!popup || (popup == m_pPopup)) + destroyPopup(anim); } void PopupManager::destroyPopup(bool anim) { - if (m_pPopup) { - auto *popup = m_pPopup; - m_pPopup = nullptr; - m_pPopupId = nullptr; + if (m_pPopup) { + auto *popup = m_pPopup; + m_pPopup = nullptr; + m_pPopupId = nullptr; - for (auto *l : m_Listeners) - l->onPop(*popup); + for (auto *l : m_Listeners) + l->onPop(*popup); - anim ? popup->dismiss() : popup->View::destroy(); - } + anim ? popup->dismiss() : popup->View::destroy(); + } } void PopupManager::push(BasePopup &popup, void *id) { - if (&popup != m_pPopup) { - pop(); - popup.addHwButtonEvent(EEXT_CALLBACK_BACK, makeCbFirst(&PopupManager::onHwBackButtonClicked), this); - m_pPopup = &popup; - m_pPopupId = id; - - for (auto *l : m_Listeners) - l->onPush(popup); - } + if (&popup != m_pPopup) { + pop(); + popup.addHwButtonEvent(EEXT_CALLBACK_BACK, makeCbFirst(&PopupManager::onHwBackButtonClicked), this); + m_pPopup = &popup; + m_pPopupId = id; + + for (auto *l : m_Listeners) + l->onPush(popup); + } } BasePopup *PopupManager::getTop() const { - return m_pPopup; + return m_pPopup; } bool PopupManager::isEmpty() const { - return !getTop(); + return !getTop(); } void PopupManager::onHwBackButtonClicked(Evas_Object *obj, void *eventInfo) { - MSG_LOG(""); - if (m_pPopup && - m_pPopup->getEo() == obj && - m_pPopup->getDismissByBackButtonFlag()) - pop(); + MSG_LOG(""); + if (m_pPopup && + m_pPopup->getEo() == obj && + m_pPopup->getDismissByBackButtonFlag()) + pop(); } void PopupManager::onPause() { - if (m_pPopup && m_pPopup->getDismissByPauseAppFlag()) - pop(); + if (m_pPopup && m_pPopup->getDismissByPauseAppFlag()) + pop(); } diff --git a/src/Common/View/src/SearchBar.cpp b/src/Common/View/src/SearchBar.cpp index 101a705..d713516 100644 --- a/src/Common/View/src/SearchBar.cpp +++ b/src/Common/View/src/SearchBar.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -22,39 +22,39 @@ using namespace Msg; SearchBar::SearchBar(Evas_Object *parent) - : m_pListener(nullptr) + : m_pListener(nullptr) { - setEo(addLayout(parent, SEARCH_BAR_EDJ_PATH, "main")); - Evas_Object *button = addIconButton(getEo(), "prediction_icon", makeCbFirst(&SearchBar::onButtonClicked), this); - setContent(button, "swl.button"); - Atspi(button).setName(msg("IDS_ACCS_BUTTON_MORE_VZW")); - addSignalCb("mouse,clicked,*", "elm.text", makeCbFirst(&SearchBar::onTextClicked), this); + setEo(addLayout(parent, SEARCH_BAR_EDJ_PATH, "main")); + Evas_Object *button = addIconButton(getEo(), "prediction_icon", makeCbFirst(&SearchBar::onButtonClicked), this); + setContent(button, "swl.button"); + Atspi(button).setName(msg("IDS_ACCS_BUTTON_MORE_VZW")); + addSignalCb("mouse,clicked,*", "elm.text", makeCbFirst(&SearchBar::onTextClicked), this); - m_AoSearchText = registerAccessObj(getEo(), "elm.text"); - m_AoSearchText.setReadingInfo(ELM_ACCESSIBLE_READING_INFO_TYPE_NAME); + m_AoSearchText = registerAccessObj(getEo(), "elm.text"); + m_AoSearchText.setReadingInfo(ELM_ACCESSIBLE_READING_INFO_TYPE_NAME); - elm_object_tree_focus_allow_set(getEo(), false); + elm_object_tree_focus_allow_set(getEo(), false); } void SearchBar::setListener(ISearchBarListener *l) { - m_pListener = l; + m_pListener = l; } void SearchBar::setText(const std::string &text) { - View::setText(text, "elm.text"); - m_AoSearchText.setName(TextDecorator::makePlainText(text)); + View::setText(text, "elm.text"); + m_AoSearchText.setName(TextDecorator::makePlainText(text)); } void SearchBar::onButtonClicked(Evas_Object *obj, void *event) { - if (m_pListener) - m_pListener->onButtonClicked(*this); + if (m_pListener) + m_pListener->onButtonClicked(*this); } void SearchBar::onTextClicked(Evas_Object *obj, const char *emission, const char *source) { - if (m_pListener) - m_pListener->onTextClicked(*this); + if (m_pListener) + m_pListener->onTextClicked(*this); } diff --git a/src/Common/View/src/SelectAllListItem.cpp b/src/Common/View/src/SelectAllListItem.cpp index 511481c..cf31200 100644 --- a/src/Common/View/src/SelectAllListItem.cpp +++ b/src/Common/View/src/SelectAllListItem.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -23,13 +23,13 @@ using namespace Msg; namespace { - ListItemStyleRef style = ListItemStyle::create("type1"); - const char *textPart = "elm.text"; - const char *checkPart = "elm.swallow.end"; + ListItemStyleRef style = ListItemStyle::create("type1"); + const char *textPart = "elm.text"; + const char *checkPart = "elm.swallow.end"; } SelectAllListItem::SelectAllListItem() - : ListItem(style, ELM_GENLIST_ITEM_NONE) + : ListItem(style, ELM_GENLIST_ITEM_NONE) { } @@ -39,17 +39,17 @@ SelectAllListItem::~SelectAllListItem() const char *SelectAllListItem::getCheckPart(ListItem &item) { - return checkPart; + return checkPart; } std::string SelectAllListItem::getText(ListItem &item, const char *part) { - if (strcmp(part, textPart) == 0) - { - return msg("WDS_MSG_OPT_SELECT_ALL_ABB"); - } + if (strcmp(part, textPart) == 0) + { + return msg("WDS_MSG_OPT_SELECT_ALL_ABB"); + } - return ""; + return ""; } diff --git a/src/Common/View/src/SelectButton.cpp b/src/Common/View/src/SelectButton.cpp index d94f59b..fd83cb7 100644 --- a/src/Common/View/src/SelectButton.cpp +++ b/src/Common/View/src/SelectButton.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -19,27 +19,27 @@ using namespace Msg; SelectButton::SelectButton(Evas_Object *parent) - : m_pButton(nullptr) + : m_pButton(nullptr) { - setEo(elm_layout_add(parent)); - elm_layout_theme_set(getEo(), "layout", "select_mode", "default"); - m_pButton = elm_button_add(getEo()); - setStyle(m_pButton, "select_mode"); - setContent(m_pButton, "elm.swallow.icon"); + setEo(elm_layout_add(parent)); + elm_layout_theme_set(getEo(), "layout", "select_mode", "default"); + m_pButton = elm_button_add(getEo()); + setStyle(m_pButton, "select_mode"); + setContent(m_pButton, "elm.swallow.icon"); } Evas_Object *SelectButton::getInnerButton() const { - return m_pButton; + return m_pButton; } void SelectButton::showButton(bool show) { - const char *sig = show ? "select_mode,button,show" : "select_mode,button,hide"; - emitSignal(sig); + const char *sig = show ? "select_mode,button,show" : "select_mode,button,hide"; + emitSignal(sig); } void SelectButton::setText(const std::string &text) { - View::setText(m_pButton, text); + View::setText(m_pButton, text); } diff --git a/src/Common/View/src/StandardPopup.cpp b/src/Common/View/src/StandardPopup.cpp index 5ac3e97..860e0dc 100644 --- a/src/Common/View/src/StandardPopup.cpp +++ b/src/Common/View/src/StandardPopup.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -23,13 +23,13 @@ const char *StandardPopup::buttons1Style = "content/circle/buttons1"; const char *StandardPopup::buttons2Style = "content/circle/buttons2"; StandardPopup::StandardPopup(const char *style) - : Popup() - , m_pLayout(nullptr) + : Popup() + , m_pLayout(nullptr) { - setStyle("circle"); - m_pLayout = elm_layout_add(getEo()); - elm_layout_theme_set(m_pLayout, "layout", "popup", style); - View::setContent(m_pLayout); + setStyle("circle"); + m_pLayout = elm_layout_add(getEo()); + elm_layout_theme_set(m_pLayout, "layout", "popup", style); + View::setContent(m_pLayout); } StandardPopup::~StandardPopup() @@ -38,30 +38,30 @@ StandardPopup::~StandardPopup() Evas_Object *StandardPopup::getLayout() const { - return m_pLayout; + return m_pLayout; } void StandardPopup::setText(const std::string &text) { - View::setText(m_pLayout, text, "elm.text"); + View::setText(m_pLayout, text, "elm.text"); } void StandardPopup::setText(const TText &text) { - View::setText(m_pLayout, text, "elm.text"); + View::setText(m_pLayout, text, "elm.text"); } void StandardPopup::setTitle(const std::string &title) { - View::setText(m_pLayout, title, "elm.text.title"); + View::setText(m_pLayout, title, "elm.text.title"); } void StandardPopup::setTitle(const TText &title) { - View::setText(m_pLayout, title, "elm.text.title"); + View::setText(m_pLayout, title, "elm.text.title"); } void StandardPopup::setContent(Evas_Object *content) { - View::setContent(m_pLayout, content); + View::setContent(m_pLayout, content); } diff --git a/src/Common/View/src/StandardWindow.cpp b/src/Common/View/src/StandardWindow.cpp index 649c48c..84e96e9 100644 --- a/src/Common/View/src/StandardWindow.cpp +++ b/src/Common/View/src/StandardWindow.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -22,30 +22,30 @@ using namespace Msg; StandardWindow::StandardWindow() - : Window() - , m_pConform(nullptr) - , m_pBg(nullptr) - , m_pCircleSurface(nullptr) + : Window() + , m_pConform(nullptr) + , m_pBg(nullptr) + , m_pCircleSurface(nullptr) { - // Window: - setEo(elm_win_add(nullptr, PACKAGE_NAME, ELM_WIN_BASIC)); - elm_win_conformant_set(getEo(), true); - elm_win_autodel_set(getEo(), true); - getAtspi().setName(msg("WDS_MSG_HEADER_MESSAGES_ABB")); - - // Conform: - m_pConform = elm_conformant_add(getEo()); - elm_win_indicator_mode_set(getEo(), ELM_WIN_INDICATOR_SHOW); - elm_win_indicator_opacity_set(getEo(), ELM_WIN_INDICATOR_OPAQUE); - evas_object_size_hint_weight_set(m_pConform, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - elm_win_resize_object_add(getEo(), m_pConform); - evas_object_show(m_pConform); - - m_pCircleSurface = eext_circle_surface_conformant_add(m_pConform); - - // Bg: - m_pBg = elm_bg_add(m_pConform); - elm_object_part_content_set(m_pConform, "elm.swallow.bg", m_pBg); + // Window: + setEo(elm_win_add(nullptr, PACKAGE_NAME, ELM_WIN_BASIC)); + elm_win_conformant_set(getEo(), true); + elm_win_autodel_set(getEo(), true); + getAtspi().setName(msg("WDS_MSG_HEADER_MESSAGES_ABB")); + + // Conform: + m_pConform = elm_conformant_add(getEo()); + elm_win_indicator_mode_set(getEo(), ELM_WIN_INDICATOR_SHOW); + elm_win_indicator_opacity_set(getEo(), ELM_WIN_INDICATOR_OPAQUE); + evas_object_size_hint_weight_set(m_pConform, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + elm_win_resize_object_add(getEo(), m_pConform); + evas_object_show(m_pConform); + + m_pCircleSurface = eext_circle_surface_conformant_add(m_pConform); + + // Bg: + m_pBg = elm_bg_add(m_pConform); + elm_object_part_content_set(m_pConform, "elm.swallow.bg", m_pBg); } StandardWindow::~StandardWindow() @@ -54,46 +54,46 @@ StandardWindow::~StandardWindow() void StandardWindow::lower() { - elm_win_lower(getEo()); + elm_win_lower(getEo()); } void StandardWindow::raise() { - elm_win_raise(getEo()); + elm_win_raise(getEo()); } Evas_Object *StandardWindow::getWinEvasObject() const { - return getEo(); + return getEo(); } Evas_Object *StandardWindow::getConformEvasObject() const { - return m_pConform; + return m_pConform; } Evas_Object *StandardWindow::getHostEvasObject() const { - return m_pConform; + return m_pConform; } Eext_Circle_Surface *StandardWindow::getCircleSurface() const { - return m_pCircleSurface; + return m_pCircleSurface; } void StandardWindow::setContent(Evas_Object *content) { - elm_object_content_set(m_pConform, content); + elm_object_content_set(m_pConform, content); } void StandardWindow::getScreenSize(int *x, int *y, int *w, int *h) const { - elm_win_screen_size_get(getEo(), x, y, w, h); + elm_win_screen_size_get(getEo(), x, y, w, h); } int StandardWindow::getRotation() const { - return elm_win_rotation_get(getEo()); + return elm_win_rotation_get(getEo()); } diff --git a/src/Common/View/src/TitleListItem.cpp b/src/Common/View/src/TitleListItem.cpp index 50483cb..2e2569e 100644 --- a/src/Common/View/src/TitleListItem.cpp +++ b/src/Common/View/src/TitleListItem.cpp @@ -22,49 +22,49 @@ using namespace Msg; const auto titleTextStyle = TextStyle(). - setSize(30). - setAlign(TextStyle::Align::Center). - setWeight(TextStyle::Weight::Bold). - setColor("#ffae0d"); + setSize(30). + setAlign(TextStyle::Align::Center). + setWeight(TextStyle::Weight::Bold). + setColor("#ffae0d"); TitleListItem::TitleListItem() - : ListItem(ListItemStyle::create("custom_title")) + : ListItem(ListItemStyle::create("custom_title")) { } void TitleListItem::setTitle(TText title) { - m_Title = std::move(title); + m_Title = std::move(title); } Evas_Object *TitleListItem::createLabel() { - static const double slideDuration = 3.0; + static const double slideDuration = 3.0; - Evas_Object *label = elm_label_add(*getOwner()); - elm_object_focus_allow_set(label, false); - elm_object_style_set(label, "slide_roll"); - elm_label_ellipsis_set(label, true); - elm_label_slide_mode_set(label, ELM_LABEL_SLIDE_MODE_AUTO); - elm_label_slide_duration_set(label, slideDuration); - std::string resultText = TextDecorator::make(m_Title, titleTextStyle); + Evas_Object *label = elm_label_add(*getOwner()); + elm_object_focus_allow_set(label, false); + elm_object_style_set(label, "slide_roll"); + elm_label_ellipsis_set(label, true); + elm_label_slide_mode_set(label, ELM_LABEL_SLIDE_MODE_AUTO); + elm_label_slide_duration_set(label, slideDuration); + std::string resultText = TextDecorator::make(m_Title, titleTextStyle); - View::setText(label, resultText); - elm_label_slide_go(label); + View::setText(label, resultText); + elm_label_slide_go(label); - Atspi ao = Atspi(label); - ao.setName(m_Title); - ao.setReadingInfo(ELM_ACCESSIBLE_READING_INFO_TYPE_NAME); + Atspi ao = Atspi(label); + ao.setName(m_Title); + ao.setReadingInfo(ELM_ACCESSIBLE_READING_INFO_TYPE_NAME); - return label; + return label; } Evas_Object *TitleListItem::getContent(ListItem &item, const char *part) { - return createLabel(); + return createLabel(); } void TitleListItem::onAttached(ViewItem &item) { - getAtspi().canHighlight(false); + getAtspi().canHighlight(false); } diff --git a/src/Common/View/src/ToastPopup.cpp b/src/Common/View/src/ToastPopup.cpp index 1daacf4..a6f9c3a 100644 --- a/src/Common/View/src/ToastPopup.cpp +++ b/src/Common/View/src/ToastPopup.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -19,22 +19,22 @@ using namespace Msg; namespace { - ToastPopup *createToast(const char *iconName) - { - auto *toast = new ToastPopup; - if (iconName) - toast->setIcon(iconName); - toast->show(); - return toast; - } + ToastPopup *createToast(const char *iconName) + { + auto *toast = new ToastPopup; + if (iconName) + toast->setIcon(iconName); + toast->show(); + return toast; + } } ToastPopup::ToastPopup(double timeout) - : Popup() + : Popup() { - setStyle("toast/circle"); - setTimeOut(timeout); - evas_object_size_hint_weight_set(getEo(), EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + setStyle("toast/circle"); + setTimeOut(timeout); + evas_object_size_hint_weight_set(getEo(), EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); } ToastPopup::~ToastPopup() @@ -43,27 +43,27 @@ ToastPopup::~ToastPopup() void ToastPopup::setIcon(const char *iconName) { - static const std::string imagesPath = PathUtils::getResourcePath(IMAGES_EDJ_PATH); - Evas_Object *icon = elm_image_add(getEo()); - elm_image_file_set(icon, imagesPath.c_str(), iconName); - setContent(icon, "toast,icon"); + static const std::string imagesPath = PathUtils::getResourcePath(IMAGES_EDJ_PATH); + Evas_Object *icon = elm_image_add(getEo()); + elm_image_file_set(icon, imagesPath.c_str(), iconName); + setContent(icon, "toast,icon"); } void ToastPopup::setText(const TText &text) { - View::setText(text, "elm.text"); + View::setText(text, "elm.text"); } void ToastPopup::setText(const std::string &text) { - View::setText(text, "elm.text"); + View::setText(text, "elm.text"); } ToastPopup *ToastPopup::toast(const TText &text, const char *iconName) { - auto *toast = createToast(iconName); - if (text.getMsg()) - toast->setText(text); - return toast; + auto *toast = createToast(iconName); + if (text.getMsg()) + toast->setText(text); + return toast; } diff --git a/src/Common/View/src/View.cpp b/src/Common/View/src/View.cpp index c7b1289..115ca3d 100644 --- a/src/Common/View/src/View.cpp +++ b/src/Common/View/src/View.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -26,7 +26,7 @@ using namespace Msg; namespace { - const char *thisKey = "this"; + const char *thisKey = "this"; } View::View() @@ -39,176 +39,176 @@ View::~View() Evas_Object_Event_Cb View::getCb(Evas_Callback_Type type) { - static std::map cbMap = - { - {EVAS_CALLBACK_FREE, on_free_cb}, - {EVAS_CALLBACK_DEL, on_del_cb} - }; + static std::map cbMap = + { + {EVAS_CALLBACK_FREE, on_free_cb}, + {EVAS_CALLBACK_DEL, on_del_cb} + }; - auto it = cbMap.find(type); - return it != cbMap.end() ? it->second : nullptr; + auto it = cbMap.find(type); + return it != cbMap.end() ? it->second : nullptr; } void View::setEventCb(Evas_Callback_Type type) { - Evas_Object_Event_Cb cb = getCb(type); - if (cb) - { - evas_object_event_callback_add(m_pEo, type, cb, this); - } else { - MSG_LOG_ERROR("Not implemented"); - assert(false); - } + Evas_Object_Event_Cb cb = getCb(type); + if (cb) + { + evas_object_event_callback_add(m_pEo, type, cb, this); + } else { + MSG_LOG_ERROR("Not implemented"); + assert(false); + } } void View::setEo(Evas_Object *eo) { - if (m_pEo) - { - MSG_LOG_ERROR("m_pEo not null"); - assert(false); - } + if (m_pEo) + { + MSG_LOG_ERROR("m_pEo not null"); + assert(false); + } - BaseView::setEo(eo); + BaseView::setEo(eo); - if (eo) - { - setData(this); - setEventCb(EVAS_CALLBACK_FREE); - setEventCb(EVAS_CALLBACK_DEL); - } + if (eo) + { + setData(this); + setEventCb(EVAS_CALLBACK_FREE); + setEventCb(EVAS_CALLBACK_DEL); + } } void View::unsetEventCb(Evas_Callback_Type type) { - Evas_Object_Event_Cb cb = getCb(type); - if (cb) - { - evas_object_event_callback_del(m_pEo, type, cb); - } else { - MSG_LOG_ERROR("Not implemented"); - assert(false); - } + Evas_Object_Event_Cb cb = getCb(type); + if (cb) + { + evas_object_event_callback_del(m_pEo, type, cb); + } else { + MSG_LOG_ERROR("Not implemented"); + assert(false); + } } -Evas_Object *View::setContent(Evas_Object *obj, Evas_Object *content, const char *part, bool saveOldContent) +Evas_Object *View::setContent(Evas_Object *obj, Evas_Object *content, const char *part, bool saveOldContent) { - Evas_Object *oldContent = saveOldContent ? elm_object_part_content_unset(obj, part) : nullptr; - elm_object_part_content_set(obj, part, content); - return oldContent; + Evas_Object *oldContent = saveOldContent ? elm_object_part_content_unset(obj, part) : nullptr; + elm_object_part_content_set(obj, part, content); + return oldContent; } Evas_Object *View::setContent(Evas_Object *content, const char *part, bool saveOldContent) { - return setContent(m_pEo, content, part, saveOldContent); + return setContent(m_pEo, content, part, saveOldContent); } void View::on_free_cb(void *data, Evas *e, Evas_Object *obj, void *event_info) { - View *view = static_cast(data); - if (view) - view->onViewDestroyed(); + View *view = static_cast(data); + if (view) + view->onViewDestroyed(); } void View::on_del_cb(void *data, Evas *e, Evas_Object *obj, void *event_info) { - View *view = static_cast(data); - if (view) - view->onBeforeDelete(*view); + View *view = static_cast(data); + if (view) + view->onBeforeDelete(*view); } void View::expand() { - expand(m_pEo); + expand(m_pEo); } void View::expand(Evas_Object *obj) { - evas_object_size_hint_weight_set(obj, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(obj, EVAS_HINT_FILL, EVAS_HINT_FILL); + evas_object_size_hint_weight_set(obj, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(obj, EVAS_HINT_FILL, EVAS_HINT_FILL); } void View::processSignal(Evas_Object *obj) { - Evas_Object *edj = elm_layout_edje_get(obj); - edje_object_message_signal_process(edj); + Evas_Object *edj = elm_layout_edje_get(obj); + edje_object_message_signal_process(edj); } void View::emitSignal(Evas_Object *obj, const char *emission, const char *source, bool async) { - elm_object_signal_emit(obj, emission, source); - if (!async) - processSignal(obj); + elm_object_signal_emit(obj, emission, source); + if (!async) + processSignal(obj); } Evas_Object *View::addLayout(Evas_Object *parent, const std::string &edjePath, const std::string &group) { - Evas_Object *layout = elm_layout_add(parent); - std::string edjAbsPath = PathUtils::getResourcePath(edjePath); - elm_layout_file_set(layout, edjAbsPath.c_str(), group.c_str()); - return layout; + Evas_Object *layout = elm_layout_add(parent); + std::string edjAbsPath = PathUtils::getResourcePath(edjePath); + elm_layout_file_set(layout, edjAbsPath.c_str(), group.c_str()); + return layout; } Evas_Object *View::addIconButton(Evas_Object *parent, const std::string &iconName, Evas_Smart_Cb clickedCb, void *cbData) { - Evas_Object *button = elm_button_add(parent); - elm_object_style_set(button, "transparent"); - Evas_Object *icon = addLayout(button, ICONS_EDJ_PATH, iconName.c_str()); - if (icon) - setContent(button, icon); - if (clickedCb) - addSmartCb(button, "clicked", clickedCb, cbData); - return button; + Evas_Object *button = elm_button_add(parent); + elm_object_style_set(button, "transparent"); + Evas_Object *icon = addLayout(button, ICONS_EDJ_PATH, iconName.c_str()); + if (icon) + setContent(button, icon); + if (clickedCb) + addSmartCb(button, "clicked", clickedCb, cbData); + return button; } void View::setData(Evas_Object *obj, const void *data) { - evas_object_data_set(obj, thisKey, (void*)data); + evas_object_data_set(obj, thisKey, (void*)data); } void *View::getData(Evas_Object *obj) { - return evas_object_data_get(obj, thisKey); + return evas_object_data_get(obj, thisKey); } std::string Msg::markupToUtf8(const char *str) { - if (!str) - return std::string(); + if (!str) + return std::string(); - std::string res; - char *markup = elm_entry_markup_to_utf8(str); - if (markup) - { - res = markup; - free(markup); - } + std::string res; + char *markup = elm_entry_markup_to_utf8(str); + if (markup) + { + res = markup; + free(markup); + } - return res; + return res; } std::string Msg::utf8ToMarkup(const char *str) { - if (!str) - return std::string(); + if (!str) + return std::string(); - std::string res; - char *markup = elm_entry_utf8_to_markup(str); - if (markup) - { - res = markup; - free(markup); - } + std::string res; + char *markup = elm_entry_utf8_to_markup(str); + if (markup) + { + res = markup; + free(markup); + } - return res; + return res; } std::string Msg::markupToUtf8(const std::string &str) { - return markupToUtf8(str.c_str()); + return markupToUtf8(str.c_str()); } std::string Msg::utf8ToMarkup(const std::string &str) { - return utf8ToMarkup(str.c_str()); + return utf8ToMarkup(str.c_str()); } diff --git a/src/Common/View/src/ViewItem.cpp b/src/Common/View/src/ViewItem.cpp index 4b4c1a3..506f83f 100644 --- a/src/Common/View/src/ViewItem.cpp +++ b/src/Common/View/src/ViewItem.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -28,38 +28,38 @@ ViewItem::~ViewItem() void ViewItem::setElmObjItem(Elm_Object_Item *item) { - BaseView::setEo(item); - setData(this); - elm_object_item_del_cb_set(getElmObjItem(), on_delete_cb); - onAttached(*this); + BaseView::setEo(item); + setData(this); + elm_object_item_del_cb_set(getElmObjItem(), on_delete_cb); + onAttached(*this); } void ViewItem::destroy() { - elm_object_item_del(getElmObjItem()); + elm_object_item_del(getElmObjItem()); } void ViewItem::on_delete_cb(void *data, Evas_Object *obj, void *event_info) { - Elm_Object_Item *it = static_cast(event_info); - ViewItem *self = static_cast(elm_object_item_data_get(it)); - self->onViewDestroyed(); + Elm_Object_Item *it = static_cast(event_info); + ViewItem *self = static_cast(elm_object_item_data_get(it)); + self->onViewDestroyed(); } Evas_Object *ViewItem::setContent(Evas_Object *content, const char *part, bool saveOldContent) { - Evas_Object *oldContent = saveOldContent ? elm_object_item_part_content_unset(getElmObjItem(), part) : nullptr; - elm_object_item_part_content_set(getElmObjItem(), part, content); - return oldContent; + Evas_Object *oldContent = saveOldContent ? elm_object_item_part_content_unset(getElmObjItem(), part) : nullptr; + elm_object_item_part_content_set(getElmObjItem(), part, content); + return oldContent; } Evas_Object *ViewItem::getContent(const char *part) const { - return getElmObjItem() ? elm_object_item_part_content_get(getElmObjItem(), part) : nullptr; + return getElmObjItem() ? elm_object_item_part_content_get(getElmObjItem(), part) : nullptr; } void ViewItem::emitSignal(const char *signal, const char *source) { - elm_object_item_signal_emit(getElmObjItem(), signal, source); + elm_object_item_signal_emit(getElmObjItem(), signal, source); } diff --git a/src/Composer/Controller/inc/Composer.h b/src/Composer/Controller/inc/Composer.h index 26d9a42..1bb41fc 100644 --- a/src/Composer/Controller/inc/Composer.h +++ b/src/Composer/Controller/inc/Composer.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -34,121 +34,121 @@ namespace Msg { - class MsgEngine; - class IComposerListener; - class IconTextPopup; - class Popup; - - class Composer - : private IMsgTransportListener - , private ISendingOptionsFrameListener { - - public: - Composer(); - virtual ~Composer(); - - void setListener(IComposerListener *l); - void setRecip(Recipient recip); - const Recipient &getRecip() const; - void setText(std::string text); - bool addFile(const std::string &file); - void send(); - ThreadId getThreadId() const; - void reset(); - void clear(); - - private: - struct SendInfo { - SendInfo (); - void reset(); - std::vector msgs; - std::set requestIdSet; - Message::NetworkStatus status; - ThreadId threadId; - bool inProgress; - }; - - // IMsgTransportListener: - void onMsgTransportSentStatus(const MsgSentStatus &status) override; - - // ISendingOptionsFrameListener: - void onSendAsText(SendingOptionsFrame &sender) override; - void onSendAsAudio(SendingOptionsFrame &sender) override; - void onDestroy(SendingOptionsFrame &sender) override; - - void notifyOnSendStart(); - void notifyOnSendFinished(); - void notifyOnCloseSendPopup(); - - // Popup: - void showSendingProgressPopup(); - void showUnableDataRoamingPopup(); - void showSentWhenServiceBecomesAvailablePopup(); - void showMmsTextLimitExceededPopup(int smsCount, int mmsCount, int maxChars); - - // Popup callbacks: - void onSendingPopupDestroy(Evas *e, Evas_Object *obj, void *event_info); - void onSendingPopupBackButtonPressed(Evas_Object *obj, void *event_info); - void onMmsTextLimitExceededOkPressed(Popup &popup); - - bool checkConnectivity(Message::Type type); - bool checkSendingOptions(); - - void sendMessage(); - void sendState0(); - void sendState1(); - void sendState2(); - void sendState3(); - void sendState4(); - void sendStateEnd(); - - std::vector createMessage(); - void sendMessageStep1(); - void sendMessageStep2(); - void sendMessageStep3(); - - bool readAddress(Message &msg); - void handleSendResult(MsgTransport::SendResult result); - void destroySendingPopup(bool anim = true); - void navigateToSendingOptions(); - - void setText(MessageRef msg, const std::string &text); - void setText(MessageSMS &msg, const std::string &text); - void setText(MessageMms &msg, const std::string &text); - void addFile(MessageMms &msg, const std::string &filePath); - void removeAudioFiles(); - - MsgEngine &getMsgEngine(); - - private: - enum SendingState { - SndState0, - SndState1, - SndState2, - SndState3, - SndState4, - SndStateEnd - }; - - private: - Recipient m_Recip; - std::string m_Text; - std::list m_Files; - IconTextPopup *m_pSendingPopup; - MsgTextMetric m_TextMetric; - SendInfo m_SendInfo; - WorkingDirRef m_WorkingDir; - IComposerListener *m_pListener; - SendingState m_SendingState; - }; - - class IComposerListener { - public: - virtual ~IComposerListener() {} - virtual void onSendStart(Composer &composer) {}; - virtual void onSendFinished(Composer &composer) {}; - virtual void onCloseSendPopup(Composer &composer) {}; - }; + class MsgEngine; + class IComposerListener; + class IconTextPopup; + class Popup; + + class Composer + : private IMsgTransportListener + , private ISendingOptionsFrameListener { + + public: + Composer(); + virtual ~Composer(); + + void setListener(IComposerListener *l); + void setRecip(Recipient recip); + const Recipient &getRecip() const; + void setText(std::string text); + bool addFile(const std::string &file); + void send(); + ThreadId getThreadId() const; + void reset(); + void clear(); + + private: + struct SendInfo { + SendInfo (); + void reset(); + std::vector msgs; + std::set requestIdSet; + Message::NetworkStatus status; + ThreadId threadId; + bool inProgress; + }; + + // IMsgTransportListener: + void onMsgTransportSentStatus(const MsgSentStatus &status) override; + + // ISendingOptionsFrameListener: + void onSendAsText(SendingOptionsFrame &sender) override; + void onSendAsAudio(SendingOptionsFrame &sender) override; + void onDestroy(SendingOptionsFrame &sender) override; + + void notifyOnSendStart(); + void notifyOnSendFinished(); + void notifyOnCloseSendPopup(); + + // Popup: + void showSendingProgressPopup(); + void showUnableDataRoamingPopup(); + void showSentWhenServiceBecomesAvailablePopup(); + void showMmsTextLimitExceededPopup(int smsCount, int mmsCount, int maxChars); + + // Popup callbacks: + void onSendingPopupDestroy(Evas *e, Evas_Object *obj, void *event_info); + void onSendingPopupBackButtonPressed(Evas_Object *obj, void *event_info); + void onMmsTextLimitExceededOkPressed(Popup &popup); + + bool checkConnectivity(Message::Type type); + bool checkSendingOptions(); + + void sendMessage(); + void sendState0(); + void sendState1(); + void sendState2(); + void sendState3(); + void sendState4(); + void sendStateEnd(); + + std::vector createMessage(); + void sendMessageStep1(); + void sendMessageStep2(); + void sendMessageStep3(); + + bool readAddress(Message &msg); + void handleSendResult(MsgTransport::SendResult result); + void destroySendingPopup(bool anim = true); + void navigateToSendingOptions(); + + void setText(MessageRef msg, const std::string &text); + void setText(MessageSMS &msg, const std::string &text); + void setText(MessageMms &msg, const std::string &text); + void addFile(MessageMms &msg, const std::string &filePath); + void removeAudioFiles(); + + MsgEngine &getMsgEngine(); + + private: + enum SendingState { + SndState0, + SndState1, + SndState2, + SndState3, + SndState4, + SndStateEnd + }; + + private: + Recipient m_Recip; + std::string m_Text; + std::list m_Files; + IconTextPopup *m_pSendingPopup; + MsgTextMetric m_TextMetric; + SendInfo m_SendInfo; + WorkingDirRef m_WorkingDir; + IComposerListener *m_pListener; + SendingState m_SendingState; + }; + + class IComposerListener { + public: + virtual ~IComposerListener() {} + virtual void onSendStart(Composer &composer) {}; + virtual void onSendFinished(Composer &composer) {}; + virtual void onCloseSendPopup(Composer &composer) {}; + }; } #endif /* Composer_h_ */ diff --git a/src/Composer/Controller/inc/ContactFrame.h b/src/Composer/Controller/inc/ContactFrame.h index 71823ad..4667fd2 100644 --- a/src/Composer/Controller/inc/ContactFrame.h +++ b/src/Composer/Controller/inc/ContactFrame.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -25,53 +25,53 @@ namespace Msg { - class IContactFrameListener; - class PaddingListViewItem; + class IContactFrameListener; + class PaddingListViewItem; - class ContactFrame - : public FrameController - , private IListViewListener - , private IContactManagerListener { + class ContactFrame + : public FrameController + , private IListViewListener + , private IContactManagerListener { - public: - ContactFrame(NaviFrameController &parent, std::list recips, std::string searchWord); - virtual ~ContactFrame(); + public: + ContactFrame(NaviFrameController &parent, std::list recips, std::string searchWord); + virtual ~ContactFrame(); - void setListener(IContactFrameListener *l); + void setListener(IContactFrameListener *l); - private: - // NaviFrameItem: - void onAttached(ViewItem &item) override; + private: + // NaviFrameItem: + void onAttached(ViewItem &item) override; - // Hw buttons: - void onHwBackButtonPreessed(Evas_Object *obj, void *event); + // Hw buttons: + void onHwBackButtonPreessed(Evas_Object *obj, void *event); - // IListViewListener: - void onListItemSelected(ListItem &listItem) override; + // IListViewListener: + void onListItemSelected(ListItem &listItem) override; - // IContactManagerListener: - void onContactChanged() override; + // IContactManagerListener: + void onContactChanged() override; - private: - void prepareList(); - void updateList(); - void updateCounterItem(); - void fillList(std::list recips); + private: + void prepareList(); + void updateList(); + void updateCounterItem(); + void fillList(std::list recips); - private: - ListView *m_pList; - IContactFrameListener *m_pListener; - std::string m_SearchWord; - LineListViewItem *m_pInfoItem; - int m_ItemsCount; - }; + private: + ListView *m_pList; + IContactFrameListener *m_pListener; + std::string m_SearchWord; + LineListViewItem *m_pInfoItem; + int m_ItemsCount; + }; - class IContactFrameListener { - public: - virtual ~IContactFrameListener() {} - virtual void onContactSelected(ContactFrame &sender, const Recipient &recip) {}; - }; + class IContactFrameListener { + public: + virtual ~IContactFrameListener() {} + virtual void onContactSelected(ContactFrame &sender, const Recipient &recip) {}; + }; } #endif /* ContactFrame_h_ */ diff --git a/src/Composer/Controller/inc/ContactListItem.h b/src/Composer/Controller/inc/ContactListItem.h index fd44c7b..f03a77c 100644 --- a/src/Composer/Controller/inc/ContactListItem.h +++ b/src/Composer/Controller/inc/ContactListItem.h @@ -21,24 +21,24 @@ #include "Recipient.h" namespace Msg { - class ContactListItem - : public ContactListViewItem { + class ContactListItem + : public ContactListViewItem { - public: - ContactListItem(Recipient recip, const std::string &searchWord); - virtual ~ContactListItem(); + public: + ContactListItem(Recipient recip, const std::string &searchWord); + virtual ~ContactListItem(); - const Recipient &getRecip() const; + const Recipient &getRecip() const; - private: - std::string getSubText() override; - std::string getMainText() override; + private: + std::string getSubText() override; + std::string getMainText() override; - private: - Recipient m_Recip; - std::string m_DispName; - std::string m_Address; - }; + private: + Recipient m_Recip; + std::string m_DispName; + std::string m_Address; + }; } #endif // ContactListItem_h_ diff --git a/src/Composer/Controller/inc/MsgBodyFrame.h b/src/Composer/Controller/inc/MsgBodyFrame.h index 9acba6b..dd45a52 100644 --- a/src/Composer/Controller/inc/MsgBodyFrame.h +++ b/src/Composer/Controller/inc/MsgBodyFrame.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -23,63 +23,63 @@ namespace Msg { - class IMsgBodyFrameListener; - class DefaultLayout; - class Popup; - - class MsgBodyFrame - : public FrameController - , private IMsgBodyViewListener { - - public: - MsgBodyFrame(NaviFrameController &parent); - virtual ~MsgBodyFrame(); - - void setText(const std::string &text); - std::string getText() const; - std::string getRawText() const; - void setListener(IMsgBodyFrameListener *l); - - private: - // NaviFrameItem: - void onAttached(ViewItem &item) override; - - // Hw buttons: - void onHwBackButtonPreessed(Evas_Object *obj, void *event); - - void prepareLayout(); - void prepareBody(); - void updateTextCounter(); - - // Popup: - void showMaxCharactersPopup(); - void showDiscardMsgPopup(); - - void onDiscardMsgClicked(Popup &popup); - - // Entry cb: - void onEntryChanged(Evas_Object *obj, void *event); - void onEntryPress(Evas_Object *obj, void *event); - void onEntryActivated(Evas_Object *obj, void *event); - void onEntryFilter(Evas_Object *obj, char **text); - - // IMsgBodyViewListener: - void onSendButtonClicked() override; - - private: - DefaultLayout *m_pLayout; - MsgBodyView *m_pBody; - MsgTextMetric m_TextMetric; - IMsgBodyFrameListener *m_pListener; - }; - - class IMsgBodyFrameListener { - public: - virtual ~IMsgBodyFrameListener() {} - virtual void onDestroy(MsgBodyFrame &frame) {}; - virtual void onSendRequest(MsgBodyFrame &frame) {}; - virtual void onPress(MsgBodyFrame &frame) {}; - }; + class IMsgBodyFrameListener; + class DefaultLayout; + class Popup; + + class MsgBodyFrame + : public FrameController + , private IMsgBodyViewListener { + + public: + MsgBodyFrame(NaviFrameController &parent); + virtual ~MsgBodyFrame(); + + void setText(const std::string &text); + std::string getText() const; + std::string getRawText() const; + void setListener(IMsgBodyFrameListener *l); + + private: + // NaviFrameItem: + void onAttached(ViewItem &item) override; + + // Hw buttons: + void onHwBackButtonPreessed(Evas_Object *obj, void *event); + + void prepareLayout(); + void prepareBody(); + void updateTextCounter(); + + // Popup: + void showMaxCharactersPopup(); + void showDiscardMsgPopup(); + + void onDiscardMsgClicked(Popup &popup); + + // Entry cb: + void onEntryChanged(Evas_Object *obj, void *event); + void onEntryPress(Evas_Object *obj, void *event); + void onEntryActivated(Evas_Object *obj, void *event); + void onEntryFilter(Evas_Object *obj, char **text); + + // IMsgBodyViewListener: + void onSendButtonClicked() override; + + private: + DefaultLayout *m_pLayout; + MsgBodyView *m_pBody; + MsgTextMetric m_TextMetric; + IMsgBodyFrameListener *m_pListener; + }; + + class IMsgBodyFrameListener { + public: + virtual ~IMsgBodyFrameListener() {} + virtual void onDestroy(MsgBodyFrame &frame) {}; + virtual void onSendRequest(MsgBodyFrame &frame) {}; + virtual void onPress(MsgBodyFrame &frame) {}; + }; } diff --git a/src/Composer/Controller/inc/MsgInputSelector.h b/src/Composer/Controller/inc/MsgInputSelector.h index bcb6403..61b34cc 100644 --- a/src/Composer/Controller/inc/MsgInputSelector.h +++ b/src/Composer/Controller/inc/MsgInputSelector.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -26,50 +26,50 @@ namespace Msg { - class FrameController; - class NaviFrameController; + class FrameController; + class NaviFrameController; - class MsgInputSelector - : public InputSelector - , private IComposerListener - , private IMsgBodyFrameListener { + class MsgInputSelector + : public InputSelector + , private IComposerListener + , private IMsgBodyFrameListener { - public: - MsgInputSelector(); - virtual ~MsgInputSelector(); + public: + MsgInputSelector(); + virtual ~MsgInputSelector(); - void setRecip(Recipient recip); - bool execCmd(const AppControlComposeRef &cmd); - void reset(); + void setRecip(Recipient recip); + bool execCmd(const AppControlComposeRef &cmd); + void reset(); - protected: - void onTemplateReply(const std::string &text) override; - void onKeyboardReply(const std::string &text) override; - void onVoiceReply(const std::string &text, const std::list &fileList) override; - void onEmoticonReply(const std::string &emoticon) override; + protected: + void onTemplateReply(const std::string &text) override; + void onKeyboardReply(const std::string &text) override; + void onVoiceReply(const std::string &text, const std::list &fileList) override; + void onEmoticonReply(const std::string &emoticon) override; - private: - NaviFrameController &getNavigation(); - void showMsgBody(const std::string &text); - void navigateToConv(ThreadId threadId); - void send(); - void addDummyAudio(); + private: + NaviFrameController &getNavigation(); + void showMsgBody(const std::string &text); + void navigateToConv(ThreadId threadId); + void send(); + void addDummyAudio(); - // IComposerListener: - void onSendStart(Composer &composer) override; - void onSendFinished(Composer &composer) override; - void onCloseSendPopup(Composer &composer) override; + // IComposerListener: + void onSendStart(Composer &composer) override; + void onSendFinished(Composer &composer) override; + void onCloseSendPopup(Composer &composer) override; - // IMsgBodyFrameListener: - void onDestroy(MsgBodyFrame &frame) override; - void onSendRequest(MsgBodyFrame &frame) override; - void onPress(MsgBodyFrame &frame) override; + // IMsgBodyFrameListener: + void onDestroy(MsgBodyFrame &frame) override; + void onSendRequest(MsgBodyFrame &frame) override; + void onPress(MsgBodyFrame &frame) override; - private: - Composer m_Composer; - MsgBodyFrame *m_pMsgBodyFrame; - bool m_CloseAfterSent; - }; + private: + Composer m_Composer; + MsgBodyFrame *m_pMsgBodyFrame; + bool m_CloseAfterSent; + }; } #endif /* MsgInputSelector_h_ */ diff --git a/src/Composer/Controller/inc/RecipFrame.h b/src/Composer/Controller/inc/RecipFrame.h index 3cd7484..add7903 100644 --- a/src/Composer/Controller/inc/RecipFrame.h +++ b/src/Composer/Controller/inc/RecipFrame.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -26,70 +26,70 @@ namespace Msg { - class RecipInputFrame; - class BottomButton; - class RecipLayout; - class DefaultLayout; - - class RecipFrame - : public FrameController - , private IRecipFieldViewListener - , private IContactPickerListener - , private IContactManagerListener { - - public: - RecipFrame(NaviFrameController &parent); - virtual ~RecipFrame(); - - bool execCmd(const AppControlComposeRef &cmd); - - private: - // NaviFrameItem: - void onAttached(ViewItem &item) override; - void onInputFramePop(NaviFrameItem &item); - - // Hw buttons: - void onHwBackButtonPreessed(Evas_Object *obj, void *event); - - // Bottom Button: - void onNextButtonClicked(Evas_Object *obj, void *event); - - // IRecipFieldViewListener: - void onFieldClicked(RecipFieldView &obj) override; - void onClearButtonClicked(RecipFieldView &obj) override; - void onContactButtonClicked(RecipFieldView &obj) override; - - // Entry(RecipField): - void onEntryChanged(Evas_Object *obj, void *event); - - // IContactPickerListener: - void onContactsPicked(const std::list &numberIdList) override; - - // IContactManagerListener: - void onContactChanged() override; - - private: - void prepareLayouts(); - void prepareNextButton(); - void prepareRecipField(); - void showInputFrame(); - void updateNextButton(); - void updateRecipFieldButton(); - void setRecip(Recipient recip); - void setRecip(std::string address); - void clearRecip(); - void navigateToMsgInput(); - - private: - DefaultLayout *m_pBaseLayout; - RecipLayout *m_pLayout; - BottomButton *m_pNextButton; - RecipFieldView *m_pRecipField; - RecipInputFrame *m_pInputFrame; - Recipient m_Recip; - ContactPicker m_ContactPicker; - AppControlComposeRef m_ComposeCmd; - }; + class RecipInputFrame; + class BottomButton; + class RecipLayout; + class DefaultLayout; + + class RecipFrame + : public FrameController + , private IRecipFieldViewListener + , private IContactPickerListener + , private IContactManagerListener { + + public: + RecipFrame(NaviFrameController &parent); + virtual ~RecipFrame(); + + bool execCmd(const AppControlComposeRef &cmd); + + private: + // NaviFrameItem: + void onAttached(ViewItem &item) override; + void onInputFramePop(NaviFrameItem &item); + + // Hw buttons: + void onHwBackButtonPreessed(Evas_Object *obj, void *event); + + // Bottom Button: + void onNextButtonClicked(Evas_Object *obj, void *event); + + // IRecipFieldViewListener: + void onFieldClicked(RecipFieldView &obj) override; + void onClearButtonClicked(RecipFieldView &obj) override; + void onContactButtonClicked(RecipFieldView &obj) override; + + // Entry(RecipField): + void onEntryChanged(Evas_Object *obj, void *event); + + // IContactPickerListener: + void onContactsPicked(const std::list &numberIdList) override; + + // IContactManagerListener: + void onContactChanged() override; + + private: + void prepareLayouts(); + void prepareNextButton(); + void prepareRecipField(); + void showInputFrame(); + void updateNextButton(); + void updateRecipFieldButton(); + void setRecip(Recipient recip); + void setRecip(std::string address); + void clearRecip(); + void navigateToMsgInput(); + + private: + DefaultLayout *m_pBaseLayout; + RecipLayout *m_pLayout; + BottomButton *m_pNextButton; + RecipFieldView *m_pRecipField; + RecipInputFrame *m_pInputFrame; + Recipient m_Recip; + ContactPicker m_ContactPicker; + AppControlComposeRef m_ComposeCmd; + }; } #endif /* RecipFrame_h_ */ diff --git a/src/Composer/Controller/inc/RecipInputFrame.h b/src/Composer/Controller/inc/RecipInputFrame.h index 1d22ded..ea51f45 100644 --- a/src/Composer/Controller/inc/RecipInputFrame.h +++ b/src/Composer/Controller/inc/RecipInputFrame.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -25,58 +25,58 @@ namespace Msg { - class RecipInputFrame - : public InputFrame - , private ISearchBarListener - , private IContactFrameListener - , private IContactManagerListener { - - public: - RecipInputFrame(NaviFrameController &parent, const Recipient &recip); - virtual ~RecipInputFrame(); - - const Recipient &getRecip() const; - - private: - // NaviFrame: - void onAttached(ViewItem &item) override; - void onInputPanelHide() override; - - - // Entry: - void onEntryChanged(Evas_Object *obj, void *event_info); - void onEntryActivated(Evas_Object *obj, void *event_info); - void onEntryFilter(Evas_Object *obj, char **text); - - // ISearchBarListener: - void onButtonClicked(SearchBar &obj) override; - void onTextClicked(SearchBar &obj) override; - - // ISearchBarListener: - void onContactSelected(ContactFrame &sender, const Recipient &recip) override; - - // Timer: - Eina_Bool onSearchTimerTick(); - - // IContactManagerListener: - void onContactChanged() override; - - private: - void showSearchBar(bool show); - void prepareEntry(std::string initText); - void setRecip(std::string address = {}, std::string dispName = {}); - void close(std::string address = {}, std::string dispName = {}); - void reqestSearch(); - void cancelSearch(); - void searchButtonHandler(); - void navigateToContactFrame(std::list recips, std::string searchWord); - - private: - SearchBar *m_pSearchBar; - Ecore_Timer *m_pTimer; - Recipient m_Recip; - bool m_IsClosed; - }; + class RecipInputFrame + : public InputFrame + , private ISearchBarListener + , private IContactFrameListener + , private IContactManagerListener { + + public: + RecipInputFrame(NaviFrameController &parent, const Recipient &recip); + virtual ~RecipInputFrame(); + + const Recipient &getRecip() const; + + private: + // NaviFrame: + void onAttached(ViewItem &item) override; + void onInputPanelHide() override; + + + // Entry: + void onEntryChanged(Evas_Object *obj, void *event_info); + void onEntryActivated(Evas_Object *obj, void *event_info); + void onEntryFilter(Evas_Object *obj, char **text); + + // ISearchBarListener: + void onButtonClicked(SearchBar &obj) override; + void onTextClicked(SearchBar &obj) override; + + // ISearchBarListener: + void onContactSelected(ContactFrame &sender, const Recipient &recip) override; + + // Timer: + Eina_Bool onSearchTimerTick(); + + // IContactManagerListener: + void onContactChanged() override; + + private: + void showSearchBar(bool show); + void prepareEntry(std::string initText); + void setRecip(std::string address = {}, std::string dispName = {}); + void close(std::string address = {}, std::string dispName = {}); + void reqestSearch(); + void cancelSearch(); + void searchButtonHandler(); + void navigateToContactFrame(std::list recips, std::string searchWord); + + private: + SearchBar *m_pSearchBar; + Ecore_Timer *m_pTimer; + Recipient m_Recip; + bool m_IsClosed; + }; } #endif /* RecipInputFrame_h_ */ diff --git a/src/Composer/Controller/inc/SendingOptionsFrame.h b/src/Composer/Controller/inc/SendingOptionsFrame.h index b22ffbf..a43e867 100644 --- a/src/Composer/Controller/inc/SendingOptionsFrame.h +++ b/src/Composer/Controller/inc/SendingOptionsFrame.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -24,51 +24,51 @@ namespace Msg { - class SendingOptionListViewItem; - class AlwaysSendAsTextListViewItem; - class ISendingOptionsFrameListener; + class SendingOptionListViewItem; + class AlwaysSendAsTextListViewItem; + class ISendingOptionsFrameListener; - class SendingOptionsFrame - : public FrameController - , private IListViewListener - , private ISendingOptionListViewItemListener { + class SendingOptionsFrame + : public FrameController + , private IListViewListener + , private ISendingOptionListViewItemListener { - public: - SendingOptionsFrame(NaviFrameController &parent); - virtual ~SendingOptionsFrame(); + public: + SendingOptionsFrame(NaviFrameController &parent); + virtual ~SendingOptionsFrame(); - void setListener(ISendingOptionsFrameListener *l); + void setListener(ISendingOptionsFrameListener *l); - private: - // NaviFrameItem: - void onAttached(ViewItem &item) override; + private: + // NaviFrameItem: + void onAttached(ViewItem &item) override; - // ISendingOptionListViewItemListener - void onTextButtonClicked() override; - void onAudioButtonClicked() override; + // ISendingOptionListViewItemListener + void onTextButtonClicked() override; + void onAudioButtonClicked() override; - void onSendAsTextItemSelected(ListItem &item); - void onCheckItemClicked(AlwaysSendAsTextListViewItem &item); + void onSendAsTextItemSelected(ListItem &item); + void onCheckItemClicked(AlwaysSendAsTextListViewItem &item); - private: - void preapareList(); - void fillList(); - void alwaysSendTextHandler(bool value); + private: + void preapareList(); + void fillList(); + void alwaysSendTextHandler(bool value); - private: - ListView *m_pList; - SendingOptionListViewItem *m_pSendingOptionItem; - AlwaysSendAsTextListViewItem *m_pSendAsTextItem; - ISendingOptionsFrameListener *m_pListener; - }; + private: + ListView *m_pList; + SendingOptionListViewItem *m_pSendingOptionItem; + AlwaysSendAsTextListViewItem *m_pSendAsTextItem; + ISendingOptionsFrameListener *m_pListener; + }; - class ISendingOptionsFrameListener { - public: - virtual ~ISendingOptionsFrameListener() {} - virtual void onSendAsText(SendingOptionsFrame &sender) {}; - virtual void onSendAsAudio(SendingOptionsFrame &sender) {}; - virtual void onDestroy(SendingOptionsFrame &sender) {}; - }; + class ISendingOptionsFrameListener { + public: + virtual ~ISendingOptionsFrameListener() {} + virtual void onSendAsText(SendingOptionsFrame &sender) {}; + virtual void onSendAsAudio(SendingOptionsFrame &sender) {}; + virtual void onDestroy(SendingOptionsFrame &sender) {}; + }; } #endif /* SendingOptionsFrame_h_ */ diff --git a/src/Composer/Controller/src/Composer.cpp b/src/Composer/Controller/src/Composer.cpp index 6d95ace..bcd0c25 100644 --- a/src/Composer/Controller/src/Composer.cpp +++ b/src/Composer/Controller/src/Composer.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -33,525 +33,525 @@ using namespace Msg; Composer::SendInfo::SendInfo() - : requestIdSet() - , status(Message::NS_Unknown) - , threadId() - , inProgress(false) + : requestIdSet() + , status(Message::NS_Unknown) + , threadId() + , inProgress(false) { } void Composer::SendInfo::reset() { - msgs.clear(); - inProgress = false; - requestIdSet.clear(); - status = Message::NS_Unknown; - threadId.reset(); + msgs.clear(); + inProgress = false; + requestIdSet.clear(); + status = Message::NS_Unknown; + threadId.reset(); } Composer::Composer() - : m_pSendingPopup(nullptr) - , m_TextMetric() - , m_WorkingDir(std::make_shared()) - , m_pListener(nullptr) - , m_SendingState(SndState0) + : m_pSendingPopup(nullptr) + , m_TextMetric() + , m_WorkingDir(std::make_shared()) + , m_pListener(nullptr) + , m_SendingState(SndState0) { - App::getInst().getMsgEngine().getTransport().addListener(*this); + App::getInst().getMsgEngine().getTransport().addListener(*this); } Composer::~Composer() { - MSG_LOG(""); - destroySendingPopup(false); - App::getInst().getMsgEngine().getTransport().removeListener(*this); + MSG_LOG(""); + destroySendingPopup(false); + App::getInst().getMsgEngine().getTransport().removeListener(*this); } MsgEngine &Composer::getMsgEngine() { - return App::getInst().getMsgEngine(); + return App::getInst().getMsgEngine(); } void Composer::setListener(IComposerListener *l) { - m_pListener = l; + m_pListener = l; } void Composer::setRecip(Recipient recip) { - m_Recip = std::move(recip); + m_Recip = std::move(recip); } const Recipient &Composer::getRecip() const { - return m_Recip; + return m_Recip; } void Composer::setText(std::string text) { - m_Text = std::move(text); + m_Text = std::move(text); } bool Composer::addFile(const std::string &file) { - std::string newFilePath = m_WorkingDir->addFile(file); - bool isValid = !newFilePath.empty(); - if (isValid) - m_Files.push_back(std::move(newFilePath)); - return isValid; + std::string newFilePath = m_WorkingDir->addFile(file); + bool isValid = !newFilePath.empty(); + if (isValid) + m_Files.push_back(std::move(newFilePath)); + return isValid; } void Composer::addFile(MessageMms &msg, const std::string &filePath) { - constexpr int defaultPageDuration = 5000; // msec - if (!filePath.empty()) { - MsgPage &msgPage = msg.addPage(); - MediaTypeData mediaData = getMsgMediaTypeByFileExt(filePath); - int pageDuration = 0; + constexpr int defaultPageDuration = 5000; // msec + if (!filePath.empty()) { + MsgPage &msgPage = msg.addPage(); + MediaTypeData mediaData = getMsgMediaTypeByFileExt(filePath); + int pageDuration = 0; - if (mediaData.type == MsgMedia::VideoType || mediaData.type == MsgMedia::AudioType) - pageDuration = MediaUtils::getDuration(filePath); + if (mediaData.type == MsgMedia::VideoType || mediaData.type == MsgMedia::AudioType) + pageDuration = MediaUtils::getDuration(filePath); - if (pageDuration <= 0) - pageDuration = defaultPageDuration; + if (pageDuration <= 0) + pageDuration = defaultPageDuration; - msgPage.setPageDuration(pageDuration); - MsgMedia &media = msgPage.addMedia(); - media.setFilePath(filePath); - } + msgPage.setPageDuration(pageDuration); + MsgMedia &media = msgPage.addMedia(); + media.setFilePath(filePath); + } } void Composer::removeAudioFiles() { - decltype(m_Files) newFileList; - for (std::string &file : m_Files) { - if (getMsgMediaTypeByFileExt(file).type != MsgMedia::AudioType) - newFileList.push_back(std::move(file)); - } - m_Files = std::move(newFileList); + decltype(m_Files) newFileList; + for (std::string &file : m_Files) { + if (getMsgMediaTypeByFileExt(file).type != MsgMedia::AudioType) + newFileList.push_back(std::move(file)); + } + m_Files = std::move(newFileList); } void Composer::send() { - m_SendingState = SndState0; - sendMessage(); + m_SendingState = SndState0; + sendMessage(); } ThreadId Composer::getThreadId() const { - return m_SendInfo.threadId; + return m_SendInfo.threadId; } void Composer::reset() { - m_SendInfo.reset(); - // TODO: check popups + m_SendInfo.reset(); + // TODO: check popups } void Composer::clear() { - m_Recip.clear(); - m_Text.clear(); - m_Files.clear(); - if (m_WorkingDir) - m_WorkingDir->clear(); + m_Recip.clear(); + m_Text.clear(); + m_Files.clear(); + if (m_WorkingDir) + m_WorkingDir->clear(); } bool Composer::readAddress(Message &msg) { - if(m_Recip.isValid()) { - MsgAddress &msgAddr = msg.addAddress(); - msgAddr.setAddress(m_Recip.getAddress()); - msgAddr.setRecipientType(MsgAddress::To); - msgAddr.setAddressType(MsgAddress::Phone); - return true; - } + if(m_Recip.isValid()) { + MsgAddress &msgAddr = msg.addAddress(); + msgAddr.setAddress(m_Recip.getAddress()); + msgAddr.setRecipientType(MsgAddress::To); + msgAddr.setAddressType(MsgAddress::Phone); + return true; + } - return false; + return false; } void Composer::setText(MessageRef msg, const std::string &text) { - if (msg && !text.empty()) { - if (auto *sms = dynamic_cast(msg.get())) - setText(*sms, text); - else if (auto *mms = dynamic_cast(msg.get())) - setText(*mms, text); - } + if (msg && !text.empty()) { + if (auto *sms = dynamic_cast(msg.get())) + setText(*sms, text); + else if (auto *mms = dynamic_cast(msg.get())) + setText(*mms, text); + } } void Composer::setText(MessageSMS &msg, const std::string &text) { - msg.setText(text); + msg.setText(text); } void Composer::setText(MessageMms &msg, const std::string &text) { - static const int defaultPageDuration = 5000; // msec - std::string filePath = m_WorkingDir->addTextFile(text); - if (!filePath.empty()) { - MsgPage &page = msg.addPage(); - page.setPageDuration(defaultPageDuration); - page.addMedia().setFilePath(filePath); - } + static const int defaultPageDuration = 5000; // msec + std::string filePath = m_WorkingDir->addTextFile(text); + if (!filePath.empty()) { + MsgPage &page = msg.addPage(); + page.setPageDuration(defaultPageDuration); + page.addMedia().setFilePath(filePath); + } } bool Composer::checkConnectivity(Message::Type type) { - auto &checker = App::getInst().getNavigation().getConnectivityChecker(); - return MsgUtils::isMms(type) ? checker.isReadyToSendMms() - : checker.isReadyToSendSms(); + auto &checker = App::getInst().getNavigation().getConnectivityChecker(); + return MsgUtils::isMms(type) ? checker.isReadyToSendMms() + : checker.isReadyToSendSms(); } void Composer::navigateToSendingOptions() { - auto &navi = App::getInst().getNavigation(); - auto *frame = new SendingOptionsFrame(navi); - frame->setListener(this); - navi.push(*frame); + auto &navi = App::getInst().getNavigation(); + auto *frame = new SendingOptionsFrame(navi); + frame->setListener(this); + navi.push(*frame); } bool Composer::checkSendingOptions() { - if (!getMsgEngine().getSettings().getSendAsAudio() || m_Files.empty()) - return true; + if (!getMsgEngine().getSettings().getSendAsAudio() || m_Files.empty()) + return true; - bool onlyAudio = true; - long long msgSize = 0; - for (const std::string &file : m_Files) { - onlyAudio &= getMsgMediaTypeByFileExt(file).type == MsgMedia::AudioType; - if (onlyAudio) - msgSize += FileUtils::getFileSize(file); - else - break; - } + bool onlyAudio = true; + long long msgSize = 0; + for (const std::string &file : m_Files) { + onlyAudio &= getMsgMediaTypeByFileExt(file).type == MsgMedia::AudioType; + if (onlyAudio) + msgSize += FileUtils::getFileSize(file); + else + break; + } - if (onlyAudio && msgSize <= getMsgEngine().getSettings().getMaxMmsSize()) { - navigateToSendingOptions(); - return false; - } - return true; + if (onlyAudio && msgSize <= getMsgEngine().getSettings().getMaxMmsSize()) { + navigateToSendingOptions(); + return false; + } + return true; } void Composer::sendMessage() { - switch (m_SendingState) { - case SndState0: - m_SendingState = SndState1; - sendState0(); - break; - case SndState1: - m_SendingState = SndState2; - sendState1(); - break; - case SndState2: - m_SendingState = SndState3; - sendState2(); - break; - case SndState3: - m_SendingState = SndState4; - sendState3(); - break; - case SndState4: - m_SendingState = SndStateEnd; - sendState4(); - break; - case SndStateEnd: - break; - } + switch (m_SendingState) { + case SndState0: + m_SendingState = SndState1; + sendState0(); + break; + case SndState1: + m_SendingState = SndState2; + sendState1(); + break; + case SndState2: + m_SendingState = SndState3; + sendState2(); + break; + case SndState3: + m_SendingState = SndState4; + sendState3(); + break; + case SndState4: + m_SendingState = SndStateEnd; + sendState4(); + break; + case SndStateEnd: + break; + } } void Composer::sendState0() { - MSG_LOG(""); - reset(); - destroySendingPopup(false); + MSG_LOG(""); + reset(); + destroySendingPopup(false); - if (!checkSendingOptions()) - return; + if (!checkSendingOptions()) + return; - removeAudioFiles(); - sendMessage(); + removeAudioFiles(); + sendMessage(); } void Composer::sendState1() { - MSG_LOG(""); - int smsCount = 0; - int mmsCount = 0; + MSG_LOG(""); + int smsCount = 0; + int mmsCount = 0; - m_SendInfo.msgs = createMessage(); + m_SendInfo.msgs = createMessage(); - MsgTextMetric textMetric; - getMsgEngine().getComposer().calculateTextMetric(m_Text, textMetric); + MsgTextMetric textMetric; + getMsgEngine().getComposer().calculateTextMetric(m_Text, textMetric); - for (MessageRef msg : m_SendInfo.msgs) { - if (msg->getType() == Message::MT_MMS) - ++mmsCount; - else if (msg->getType() == Message::MT_SMS) - ++smsCount; - } - bool isTextMms = mmsCount > 0 && m_Files.empty(); - if (isTextMms) - showMmsTextLimitExceededPopup(smsCount, mmsCount, textMetric.maxSmsLen); - else - sendMessage(); + for (MessageRef msg : m_SendInfo.msgs) { + if (msg->getType() == Message::MT_MMS) + ++mmsCount; + else if (msg->getType() == Message::MT_SMS) + ++smsCount; + } + bool isTextMms = mmsCount > 0 && m_Files.empty(); + if (isTextMms) + showMmsTextLimitExceededPopup(smsCount, mmsCount, textMetric.maxSmsLen); + else + sendMessage(); } void Composer::sendState2() { - MSG_LOG(""); - sendMessage(); + MSG_LOG(""); + sendMessage(); } void Composer::sendState3() { - MSG_LOG(""); - if (m_SendInfo.msgs.empty()) { - MSG_LOG_ERROR("m_SendInfo.msgs is empty") - return; - } + MSG_LOG(""); + if (m_SendInfo.msgs.empty()) { + MSG_LOG_ERROR("m_SendInfo.msgs is empty") + return; + } - // Check connectivity: - if (!checkConnectivity(m_SendInfo.msgs[0]->getType())) - return; + // Check connectivity: + if (!checkConnectivity(m_SendInfo.msgs[0]->getType())) + return; - sendMessage(); + sendMessage(); } void Composer::sendState4() { - MSG_LOG(""); + MSG_LOG(""); - // Send message: - MsgTransport::SendResult sendRes = MsgTransport::SendFail; - MessageRef lastSentMsg; + // Send message: + MsgTransport::SendResult sendRes = MsgTransport::SendFail; + MessageRef lastSentMsg; - for (MessageRef msg : m_SendInfo.msgs) { - lastSentMsg = msg; - RequestId reqId; - sendRes = getMsgEngine().getTransport().sendMessage(msg, &m_SendInfo.threadId, &reqId); + for (MessageRef msg : m_SendInfo.msgs) { + lastSentMsg = msg; + RequestId reqId; + sendRes = getMsgEngine().getTransport().sendMessage(msg, &m_SendInfo.threadId, &reqId); - MSG_LOG("Send result = ", sendRes); - MSG_LOG("Thread id = ", m_SendInfo.threadId); - MSG_LOG("Request id = ", reqId); + MSG_LOG("Send result = ", sendRes); + MSG_LOG("Thread id = ", m_SendInfo.threadId); + MSG_LOG("Request id = ", reqId); - if (sendRes != MsgTransport::SendSuccess) - break; + if (sendRes != MsgTransport::SendSuccess) + break; - m_SendInfo.inProgress = true; - m_SendInfo.requestIdSet.insert(reqId); - } + m_SendInfo.inProgress = true; + m_SendInfo.requestIdSet.insert(reqId); + } - if (sendRes == MsgTransport::SendSuccess && m_SendInfo.threadId.isValid()) { - showSendingProgressPopup(); - notifyOnSendStart(); - } else { - notifyOnSendStart(); - handleSendResult(sendRes); - } + if (sendRes == MsgTransport::SendSuccess && m_SendInfo.threadId.isValid()) { + showSendingProgressPopup(); + notifyOnSendStart(); + } else { + notifyOnSendStart(); + handleSendResult(sendRes); + } - sendMessage(); + sendMessage(); } std::vector Composer::createMessage() { - std::vector msgList; - auto &msgEngine = getMsgEngine(); - const int maxMsgSize = msgEngine.getSettings().getMaxMmsSize(); - - if (maxMsgSize <= 0) { - MSG_LOG_ERROR("getMaxMmsSize() returns 0"); - return {}; - } - - MSG_LOG(""); - if (m_Files.empty()) { - MSG_LOG(""); - // Text messages: - auto textList = MsgUtils::splitUtf8String(m_Text, maxMsgSize); - for (auto &&text : textList) { - MsgTextMetric metric; - msgEngine.getComposer().calculateTextMetric(m_Text, metric); - Message::Type type = metric.isMms ? Message::MT_MMS : Message::MT_SMS; - auto msg = msgEngine.getComposer().createMessage(type); - if (msg && readAddress(*msg)) { - setText(msg, text); - msgList.push_back(msg); - } - } - } else { - MSG_LOG(""); - // Create MMS: - auto mms = msgEngine.getComposer().createMms(); - if (mms) { - if (readAddress(*mms)) { - for (const std::string &file : m_Files) - addFile(*mms, file); - msgList.push_back(mms); - } - } - } - return msgList; + std::vector msgList; + auto &msgEngine = getMsgEngine(); + const int maxMsgSize = msgEngine.getSettings().getMaxMmsSize(); + + if (maxMsgSize <= 0) { + MSG_LOG_ERROR("getMaxMmsSize() returns 0"); + return {}; + } + + MSG_LOG(""); + if (m_Files.empty()) { + MSG_LOG(""); + // Text messages: + auto textList = MsgUtils::splitUtf8String(m_Text, maxMsgSize); + for (auto &&text : textList) { + MsgTextMetric metric; + msgEngine.getComposer().calculateTextMetric(m_Text, metric); + Message::Type type = metric.isMms ? Message::MT_MMS : Message::MT_SMS; + auto msg = msgEngine.getComposer().createMessage(type); + if (msg && readAddress(*msg)) { + setText(msg, text); + msgList.push_back(msg); + } + } + } else { + MSG_LOG(""); + // Create MMS: + auto mms = msgEngine.getComposer().createMms(); + if (mms) { + if (readAddress(*mms)) { + for (const std::string &file : m_Files) + addFile(*mms, file); + msgList.push_back(mms); + } + } + } + return msgList; } void Composer::notifyOnSendStart() { - if (m_pListener) - m_pListener->onSendStart(*this); + if (m_pListener) + m_pListener->onSendStart(*this); } void Composer::notifyOnSendFinished() { - if (m_pListener) - m_pListener->onSendFinished(*this); + if (m_pListener) + m_pListener->onSendFinished(*this); } void Composer::notifyOnCloseSendPopup() { - if (m_pListener) - m_pListener->onCloseSendPopup(*this); + if (m_pListener) + m_pListener->onCloseSendPopup(*this); } void Composer::handleSendResult(MsgTransport::SendResult result) { - notifyOnSendFinished(); + notifyOnSendFinished(); } void Composer::destroySendingPopup(bool anim) { - if (m_pSendingPopup) { - m_pSendingPopup->destroy(anim); - m_pSendingPopup = nullptr; - } + if (m_pSendingPopup) { + m_pSendingPopup->destroy(anim); + m_pSendingPopup = nullptr; + } } void Composer::showSendingProgressPopup() { - if (!m_pSendingPopup) { - m_pSendingPopup = new IconTextPopup; - m_pSendingPopup->setDismissByBackButtonFlag(false); - m_pSendingPopup->addEventCb(EVAS_CALLBACK_DEL, makeCbFirst(&Composer::onSendingPopupDestroy), this); - m_pSendingPopup->addHwButtonEvent(EEXT_CALLBACK_BACK, makeCbFirst(&Composer::onSendingPopupBackButtonPressed), this); - m_pSendingPopup->setIcon(IconTextPopup::ProgressIcon); - m_pSendingPopup->setText(msgt("IDS_MSG_BODY_SENDING_ING_M_STATUS_ABB")); - m_pSendingPopup->show(); - } + if (!m_pSendingPopup) { + m_pSendingPopup = new IconTextPopup; + m_pSendingPopup->setDismissByBackButtonFlag(false); + m_pSendingPopup->addEventCb(EVAS_CALLBACK_DEL, makeCbFirst(&Composer::onSendingPopupDestroy), this); + m_pSendingPopup->addHwButtonEvent(EEXT_CALLBACK_BACK, makeCbFirst(&Composer::onSendingPopupBackButtonPressed), this); + m_pSendingPopup->setIcon(IconTextPopup::ProgressIcon); + m_pSendingPopup->setText(msgt("IDS_MSG_BODY_SENDING_ING_M_STATUS_ABB")); + m_pSendingPopup->show(); + } } void Composer::showMmsTextLimitExceededPopup(int smsCount, int mmsCount, int maxChars) { - auto *popup = new StandardPopup(StandardPopup::buttons2Style); - std::string popupMessage = msgArgs("WDS_MSG_BODY_MAXIMUM_NUMBER_OF_CHARACTERS_HPD_EXCEEDED", maxChars); - popupMessage += "
"; + auto *popup = new StandardPopup(StandardPopup::buttons2Style); + std::string popupMessage = msgArgs("WDS_MSG_BODY_MAXIMUM_NUMBER_OF_CHARACTERS_HPD_EXCEEDED", maxChars); + popupMessage += "
"; - if (smsCount == 0) - popupMessage += msgArgs("WDS_MSG_BODY_MESSAGE_WILL_BE_SENT_AS_PD_MMS_MESSAGES", mmsCount); - else - popupMessage += msgArgs("WDS_MSG_BODY_MESSAGE_WILL_BE_SENT_AS_PD_MMS_MESSAGES_AND_1_SMS_MESSAGE", mmsCount); + if (smsCount == 0) + popupMessage += msgArgs("WDS_MSG_BODY_MESSAGE_WILL_BE_SENT_AS_PD_MMS_MESSAGES", mmsCount); + else + popupMessage += msgArgs("WDS_MSG_BODY_MESSAGE_WILL_BE_SENT_AS_PD_MMS_MESSAGES_AND_1_SMS_MESSAGE", mmsCount); - popup->setText(popupMessage); - popup->addLeftButton(CANCEL_BUTTON_POPUP); - popup->addRightButton(OK_BUTTON_POPUP, makeCbLast(&Composer::onMmsTextLimitExceededOkPressed), this); - popup->show(); + popup->setText(popupMessage); + popup->addLeftButton(CANCEL_BUTTON_POPUP); + popup->addRightButton(OK_BUTTON_POPUP, makeCbLast(&Composer::onMmsTextLimitExceededOkPressed), this); + popup->show(); } void Composer::showSentWhenServiceBecomesAvailablePopup() { - auto *popup = new StandardPopup(StandardPopup::buttons1Style); - popup->setText(msgt("WDS_MSG_BODY_UNABLE_TO_SEND_MESSAGE_IT_WILL_BE_SENT_WHEN_SERVICE_BECOMES_AVAILABLE")); - popup->addBottomButton(msgt("WDS_MSG_ACBUTTON_OK_ABB")); - popup->show(); + auto *popup = new StandardPopup(StandardPopup::buttons1Style); + popup->setText(msgt("WDS_MSG_BODY_UNABLE_TO_SEND_MESSAGE_IT_WILL_BE_SENT_WHEN_SERVICE_BECOMES_AVAILABLE")); + popup->addBottomButton(msgt("WDS_MSG_ACBUTTON_OK_ABB")); + popup->show(); } void Composer::onMsgTransportSentStatus(const MsgSentStatus &status) { - MSG_LOG(""); - RequestId id = status.getId(); - Message::NetworkStatus networkStatus = status.getNetworkStatus(); + MSG_LOG(""); + RequestId id = status.getId(); + Message::NetworkStatus networkStatus = status.getNetworkStatus(); - MSG_LOG("Id = ", id); - MSG_LOG("Network status = ", networkStatus); + MSG_LOG("Id = ", id); + MSG_LOG("Network status = ", networkStatus); - auto reqIdIt = m_SendInfo.requestIdSet.find(id); - bool reqFound = reqIdIt != m_SendInfo.requestIdSet.end(); + auto reqIdIt = m_SendInfo.requestIdSet.find(id); + bool reqFound = reqIdIt != m_SendInfo.requestIdSet.end(); - // Skip unknown request - if (!reqFound) - return; + // Skip unknown request + if (!reqFound) + return; - if (networkStatus == Message::NS_Sending) - return; + if (networkStatus == Message::NS_Sending) + return; - m_SendInfo.requestIdSet.erase(reqIdIt); - bool isLast = m_SendInfo.requestIdSet.empty(); + m_SendInfo.requestIdSet.erase(reqIdIt); + bool isLast = m_SendInfo.requestIdSet.empty(); - if (networkStatus == Message::NS_Send_Fail) - m_SendInfo.status = Message::NS_Send_Fail; - else if (networkStatus == Message::NS_Send_Pending && m_SendInfo.status != Message::NS_Send_Fail) - m_SendInfo.status = Message::NS_Send_Pending; - else if (m_SendInfo.status == Message::NS_Unknown) - m_SendInfo.status = networkStatus; + if (networkStatus == Message::NS_Send_Fail) + m_SendInfo.status = Message::NS_Send_Fail; + else if (networkStatus == Message::NS_Send_Pending && m_SendInfo.status != Message::NS_Send_Fail) + m_SendInfo.status = Message::NS_Send_Pending; + else if (m_SendInfo.status == Message::NS_Unknown) + m_SendInfo.status = networkStatus; - if (isLast || m_SendInfo.status == Message::NS_Send_Fail) { + if (isLast || m_SendInfo.status == Message::NS_Send_Fail) { - m_SendInfo.inProgress = false; - m_SendInfo.requestIdSet.clear(); + m_SendInfo.inProgress = false; + m_SendInfo.requestIdSet.clear(); - if (m_SendInfo.status == Message::NS_Send_Success) { - m_pSendingPopup->setIcon(IconTextPopup::CheckIcon); - m_pSendingPopup->setText(msgt("WDS_WNOTI_TPOP_SENT_ABB")); - m_pSendingPopup->setTimeOut(); - } else if (m_SendInfo.status == Message::NS_Send_Fail) { - m_pSendingPopup->setIcon(IconTextPopup::FailedIcon); - m_pSendingPopup->setText(msgt("WDS_MSG_TPOP_SENDING_FAILED_ABB")); - m_pSendingPopup->setTimeOut(); - } else if (m_SendInfo.status != Message::NS_Send_Pending) { - destroySendingPopup(); - showSentWhenServiceBecomesAvailablePopup(); - } + if (m_SendInfo.status == Message::NS_Send_Success) { + m_pSendingPopup->setIcon(IconTextPopup::CheckIcon); + m_pSendingPopup->setText(msgt("WDS_WNOTI_TPOP_SENT_ABB")); + m_pSendingPopup->setTimeOut(); + } else if (m_SendInfo.status == Message::NS_Send_Fail) { + m_pSendingPopup->setIcon(IconTextPopup::FailedIcon); + m_pSendingPopup->setText(msgt("WDS_MSG_TPOP_SENDING_FAILED_ABB")); + m_pSendingPopup->setTimeOut(); + } else if (m_SendInfo.status != Message::NS_Send_Pending) { + destroySendingPopup(); + showSentWhenServiceBecomesAvailablePopup(); + } - notifyOnSendFinished(); - } + notifyOnSendFinished(); + } } void Composer::onSendingPopupDestroy(Evas *e, Evas_Object *obj, void *event_info) { - MSG_LOG(""); - m_pSendingPopup = nullptr; - notifyOnCloseSendPopup(); + MSG_LOG(""); + m_pSendingPopup = nullptr; + notifyOnCloseSendPopup(); } void Composer::onSendingPopupBackButtonPressed(Evas_Object *obj, void *event_info) { - MSG_LOG(""); - destroySendingPopup(); - if (m_SendInfo.inProgress) - m_SendInfo.reset(); + MSG_LOG(""); + destroySendingPopup(); + if (m_SendInfo.inProgress) + m_SendInfo.reset(); } void Composer::onMmsTextLimitExceededOkPressed(Popup &popup) { - MSG_LOG(""); - popup.destroy(); - sendMessage(); + MSG_LOG(""); + popup.destroy(); + sendMessage(); } void Composer::onSendAsText(SendingOptionsFrame &sender) { - MSG_LOG(""); - removeAudioFiles(); - sendMessage(); + MSG_LOG(""); + removeAudioFiles(); + sendMessage(); } void Composer::onSendAsAudio(SendingOptionsFrame &sender) { - MSG_LOG(""); - m_Text.clear(); - sendMessage(); + MSG_LOG(""); + m_Text.clear(); + sendMessage(); } void Composer::onDestroy(SendingOptionsFrame &sender) { - MSG_LOG(""); + MSG_LOG(""); } diff --git a/src/Composer/Controller/src/ContactFrame.cpp b/src/Composer/Controller/src/ContactFrame.cpp index cd64e2d..6db2f47 100644 --- a/src/Composer/Controller/src/ContactFrame.cpp +++ b/src/Composer/Controller/src/ContactFrame.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -25,101 +25,101 @@ using namespace Msg; ContactFrame::ContactFrame(NaviFrameController &parent, std::list recips, std::string searchWord) - : FrameController(parent, ComposerGroup) - , m_pList(nullptr) - , m_pListener(nullptr) - , m_SearchWord(std::move(searchWord)) - , m_pInfoItem(nullptr) - , m_ItemsCount(0) + : FrameController(parent, ComposerGroup) + , m_pList(nullptr) + , m_pListener(nullptr) + , m_SearchWord(std::move(searchWord)) + , m_pInfoItem(nullptr) + , m_ItemsCount(0) { - MSG_LOG(""); - App::getInst().getContactManager().addListener(*this); - prepareList(); - fillList(std::move(recips)); + MSG_LOG(""); + App::getInst().getContactManager().addListener(*this); + prepareList(); + fillList(std::move(recips)); } ContactFrame::~ContactFrame() { - MSG_LOG(""); - App::getInst().getContactManager().removeListener(*this); + MSG_LOG(""); + App::getInst().getContactManager().removeListener(*this); } void ContactFrame::setListener(IContactFrameListener *l) { - m_pListener = l; + m_pListener = l; } void ContactFrame::prepareList() { - if (!m_pList) { - m_pList = new ListView(getParent(), App::getInst().getWindow().getCircleSurface()); - m_pList->addHwButtonEvent(EEXT_CALLBACK_BACK, makeCbFirst(&ContactFrame::onHwBackButtonPreessed), this); - m_pList->setHomogeneous(false); - m_pList->setListener(this); - } + if (!m_pList) { + m_pList = new ListView(getParent(), App::getInst().getWindow().getCircleSurface()); + m_pList->addHwButtonEvent(EEXT_CALLBACK_BACK, makeCbFirst(&ContactFrame::onHwBackButtonPreessed), this); + m_pList->setHomogeneous(false); + m_pList->setListener(this); + } } void ContactFrame::updateList() { - auto recips = Recipient::searchAll(m_SearchWord); - m_pList->clear(); - fillList(recips); + auto recips = Recipient::searchAll(m_SearchWord); + m_pList->clear(); + fillList(recips); } void ContactFrame::updateCounterItem() { - if (m_pInfoItem) - m_pInfoItem->setText(msgArgs("WDS_PB_HEADER_PD_RESULTS_FOUND_ABB", m_ItemsCount)); + if (m_pInfoItem) + m_pInfoItem->setText(msgArgs("WDS_PB_HEADER_PD_RESULTS_FOUND_ABB", m_ItemsCount)); } void ContactFrame::fillList(std::list recips) { - m_ItemsCount = recips.size(); + m_ItemsCount = recips.size(); - // Top padding: - m_pList->appendItem(*new PaddingListViewItem); + // Top padding: + m_pList->appendItem(*new PaddingListViewItem); - m_pInfoItem = new LineListViewItem; - updateCounterItem(); - m_pList->appendItem(*m_pInfoItem); + m_pInfoItem = new LineListViewItem; + updateCounterItem(); + m_pList->appendItem(*m_pInfoItem); - for (Recipient recip : recips) { - auto *item = new ContactListItem(std::move(recip), m_SearchWord); - m_pList->appendItem(*item); - } + for (Recipient recip : recips) { + auto *item = new ContactListItem(std::move(recip), m_SearchWord); + m_pList->appendItem(*item); + } - // Bottom padding: - m_pList->appendItem(*new PaddingListViewItem); + // Bottom padding: + m_pList->appendItem(*new PaddingListViewItem); } void ContactFrame::onAttached(ViewItem &item) { - MSG_LOG(""); - FrameController::onAttached(item); - setContent(*m_pList); + MSG_LOG(""); + FrameController::onAttached(item); + setContent(*m_pList); } void ContactFrame::onListItemSelected(ListItem &listItem) { - MSG_LOG(""); - - auto *item = dynamic_cast(&listItem); - if (item) { - if (m_pListener) - m_pListener->onContactSelected(*this, item->getRecip()); - pop(); - } + MSG_LOG(""); + + auto *item = dynamic_cast(&listItem); + if (item) { + if (m_pListener) + m_pListener->onContactSelected(*this, item->getRecip()); + pop(); + } } void ContactFrame::onHwBackButtonPreessed(Evas_Object *obj, void *event) { - MSG_LOG(""); - pop(); + MSG_LOG(""); + pop(); } void ContactFrame::onContactChanged() { - MSG_LOG(""); - updateList(); + MSG_LOG(""); + updateList(); } diff --git a/src/Composer/Controller/src/ContactListItem.cpp b/src/Composer/Controller/src/ContactListItem.cpp index 7e36bce..9e73e5b 100644 --- a/src/Composer/Controller/src/ContactListItem.cpp +++ b/src/Composer/Controller/src/ContactListItem.cpp @@ -20,13 +20,13 @@ using namespace Msg; ContactListItem::ContactListItem(Recipient recip, const std::string &searchWord) - : m_Recip(std::move(recip)) + : m_Recip(std::move(recip)) { - ListItemStyleRef style = recip.getDispName().empty() ? text1 : text2; - setStyle(style); + ListItemStyleRef style = recip.getDispName().empty() ? text1 : text2; + setStyle(style); - m_DispName = TextDecorator::highlightKeyword(recip.getDispName(), searchWord); - m_Address = TextDecorator::highlightKeyword(recip.getAddress(), searchWord); + m_DispName = TextDecorator::highlightKeyword(recip.getDispName(), searchWord); + m_Address = TextDecorator::highlightKeyword(recip.getAddress(), searchWord); } ContactListItem::~ContactListItem() @@ -35,15 +35,15 @@ ContactListItem::~ContactListItem() const Recipient &ContactListItem::getRecip() const { - return m_Recip; + return m_Recip; } std::string ContactListItem::getSubText() { - return m_Address; + return m_Address; } std::string ContactListItem::getMainText() { - return m_DispName; + return m_DispName; } diff --git a/src/Composer/Controller/src/MsgBodyFrame.cpp b/src/Composer/Controller/src/MsgBodyFrame.cpp index bad521d..947c9a2 100644 --- a/src/Composer/Controller/src/MsgBodyFrame.cpp +++ b/src/Composer/Controller/src/MsgBodyFrame.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -33,154 +33,154 @@ using namespace Msg; MsgBodyFrame::MsgBodyFrame(NaviFrameController &parent) - : FrameController(parent, ComposerGroup) - , m_pLayout(nullptr) - , m_pBody(nullptr) - , m_TextMetric() - , m_pListener(nullptr) + : FrameController(parent, ComposerGroup) + , m_pLayout(nullptr) + , m_pBody(nullptr) + , m_TextMetric() + , m_pListener(nullptr) { - MSG_LOG(""); - prepareLayout(); - prepareBody(); + MSG_LOG(""); + prepareLayout(); + prepareBody(); } MsgBodyFrame::~MsgBodyFrame() { - if (m_pListener) - m_pListener->onDestroy(*this); + if (m_pListener) + m_pListener->onDestroy(*this); } void MsgBodyFrame::setText(const std::string &text) { - m_pBody->getEntry().setText(text); - m_pBody->getEntry().setCursorPosToEnd(); + m_pBody->getEntry().setText(text); + m_pBody->getEntry().setCursorPosToEnd(); } std::string MsgBodyFrame::getText() const { - return m_pBody->getEntry().getText(); + return m_pBody->getEntry().getText(); } std::string MsgBodyFrame::getRawText() const { - const char *text = m_pBody->getEntry().getEntry(); - return text ? text : ""; + const char *text = m_pBody->getEntry().getEntry(); + return text ? text : ""; } void MsgBodyFrame::setListener(IMsgBodyFrameListener *l) { - m_pListener = l; + m_pListener = l; } void MsgBodyFrame::prepareLayout() { - if (!m_pLayout) { - m_pLayout = new DefaultLayout(getParent()); - m_pLayout->addHwButtonEvent(EEXT_CALLBACK_BACK, makeCbFirst(&MsgBodyFrame::onHwBackButtonPreessed), this); - } + if (!m_pLayout) { + m_pLayout = new DefaultLayout(getParent()); + m_pLayout->addHwButtonEvent(EEXT_CALLBACK_BACK, makeCbFirst(&MsgBodyFrame::onHwBackButtonPreessed), this); + } } void MsgBodyFrame::prepareBody() { - if (!m_pBody) { - m_pBody = new MsgBodyView(*m_pLayout); - m_pBody->setListener(this); - m_pBody->getEntry().enabledInputPanel(false); - m_pBody->getEntry().addChangedCb(makeCbFirst(&MsgBodyFrame::onEntryChanged), this); - m_pBody->getEntry().addMarkupFilterCb(makeCbFirst(&MsgBodyFrame::onEntryFilter), this); - m_pBody->getEntry().addActivatedCb(makeCbFirst(&MsgBodyFrame::onEntryActivated), this); - m_pBody->getEntry().addSmartCb("press", makeCbFirst(&MsgBodyFrame::onEntryPress), this); - m_pLayout->setContent(*m_pBody); - updateTextCounter(); - } + if (!m_pBody) { + m_pBody = new MsgBodyView(*m_pLayout); + m_pBody->setListener(this); + m_pBody->getEntry().enabledInputPanel(false); + m_pBody->getEntry().addChangedCb(makeCbFirst(&MsgBodyFrame::onEntryChanged), this); + m_pBody->getEntry().addMarkupFilterCb(makeCbFirst(&MsgBodyFrame::onEntryFilter), this); + m_pBody->getEntry().addActivatedCb(makeCbFirst(&MsgBodyFrame::onEntryActivated), this); + m_pBody->getEntry().addSmartCb("press", makeCbFirst(&MsgBodyFrame::onEntryPress), this); + m_pLayout->setContent(*m_pBody); + updateTextCounter(); + } } void MsgBodyFrame::updateTextCounter() { - const std::string &text = m_pBody->getEntry().getText(); - App::getInst().getMsgEngine().getComposer().calculateTextMetric(text, m_TextMetric); + const std::string &text = m_pBody->getEntry().getText(); + App::getInst().getMsgEngine().getComposer().calculateTextMetric(text, m_TextMetric); - m_TextMetric.isMms ? - m_pBody->setCounter(msgt("WDS_MSG_SBODY_MMS_ABB")) : - m_pBody->setCounter(m_TextMetric.textLen, m_TextMetric.maxLen); + m_TextMetric.isMms ? + m_pBody->setCounter(msgt("WDS_MSG_SBODY_MMS_ABB")) : + m_pBody->setCounter(m_TextMetric.textLen, m_TextMetric.maxLen); - m_pBody->getEntry().disabledReturnKey(text.empty()); - m_pBody->disabledSendButton(text.empty()); + m_pBody->getEntry().disabledReturnKey(text.empty()); + m_pBody->disabledSendButton(text.empty()); } void MsgBodyFrame::showMaxCharactersPopup() { - ToastPopup::toast(msgt("WDS_WIFI_TPOP_MAXIMUM_NUMBER_OF_CHARACTERS_REACHED")); + ToastPopup::toast(msgt("WDS_WIFI_TPOP_MAXIMUM_NUMBER_OF_CHARACTERS_REACHED")); } void MsgBodyFrame::showDiscardMsgPopup() { - auto *popup = new StandardPopup(StandardPopup::buttons2Style); - popup->setDismissByPauseAppFlag(true); - popup->setText(msgt("WDS_MSG_POP_DISCARD_MESSAGE_Q")); - popup->addRightButton(OK_BUTTON_POPUP, makeCbLast(&MsgBodyFrame::onDiscardMsgClicked), this); - popup->addLeftButton(CANCEL_BUTTON_POPUP); - popup->show(); + auto *popup = new StandardPopup(StandardPopup::buttons2Style); + popup->setDismissByPauseAppFlag(true); + popup->setText(msgt("WDS_MSG_POP_DISCARD_MESSAGE_Q")); + popup->addRightButton(OK_BUTTON_POPUP, makeCbLast(&MsgBodyFrame::onDiscardMsgClicked), this); + popup->addLeftButton(CANCEL_BUTTON_POPUP); + popup->show(); } void MsgBodyFrame::onDiscardMsgClicked(Popup &popup) { - MSG_LOG(""); - popup.destroy(); - pop(); + MSG_LOG(""); + popup.destroy(); + pop(); } void MsgBodyFrame::onAttached(ViewItem &item) { - MSG_LOG(""); - FrameController::onAttached(item); - setContent(*m_pLayout); + MSG_LOG(""); + FrameController::onAttached(item); + setContent(*m_pLayout); } void MsgBodyFrame::onHwBackButtonPreessed(Evas_Object *obj, void *event_info) { - MSG_LOG(""); - if (m_pBody->getEntry().isEmpty()) - pop(); - else - showDiscardMsgPopup(); + MSG_LOG(""); + if (m_pBody->getEntry().isEmpty()) + pop(); + else + showDiscardMsgPopup(); } -void MsgBodyFrame::onEntryChanged(Evas_Object *obj, void *event) +void MsgBodyFrame::onEntryChanged(Evas_Object *obj, void *event) { - MSG_LOG(""); - updateTextCounter(); + MSG_LOG(""); + updateTextCounter(); } void MsgBodyFrame::onEntryPress(Evas_Object *obj, void *event) { - MSG_LOG(""); - if (m_pListener) - m_pListener->onPress(*this); + MSG_LOG(""); + if (m_pListener) + m_pListener->onPress(*this); } void MsgBodyFrame::onEntryActivated(Evas_Object *obj, void *event) { - MSG_LOG(""); - if (m_pListener) - m_pListener->onSendRequest(*this); + MSG_LOG(""); + if (m_pListener) + m_pListener->onSendRequest(*this); } void MsgBodyFrame::onSendButtonClicked() { - MSG_LOG(""); - if (m_pListener) - m_pListener->onSendRequest(*this); + MSG_LOG(""); + if (m_pListener) + m_pListener->onSendRequest(*this); } void MsgBodyFrame::onEntryFilter(Evas_Object *obj, char **text) { - if (*text) { - if (m_TextMetric.isMms && m_TextMetric.bytes == m_TextMetric.maxLen) { - free(*text); - *text = nullptr; - showMaxCharactersPopup(); - } - } + if (*text) { + if (m_TextMetric.isMms && m_TextMetric.bytes == m_TextMetric.maxLen) { + free(*text); + *text = nullptr; + showMaxCharactersPopup(); + } + } } diff --git a/src/Composer/Controller/src/MsgInputSelector.cpp b/src/Composer/Controller/src/MsgInputSelector.cpp index f91a7ba..bb133a5 100644 --- a/src/Composer/Controller/src/MsgInputSelector.cpp +++ b/src/Composer/Controller/src/MsgInputSelector.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -25,175 +25,175 @@ using namespace Msg; MsgInputSelector::MsgInputSelector() - : m_pMsgBodyFrame(nullptr) - , m_CloseAfterSent(false) + : m_pMsgBodyFrame(nullptr) + , m_CloseAfterSent(false) { - MSG_LOG(""); - m_Composer.setListener(this); + MSG_LOG(""); + m_Composer.setListener(this); } MsgInputSelector::~MsgInputSelector() { - MSG_LOG(""); - m_Composer.setListener(nullptr); - reset(); + MSG_LOG(""); + m_Composer.setListener(nullptr); + reset(); } NaviFrameController &MsgInputSelector::getNavigation() { - return App::getInst().getNavigation(); + return App::getInst().getNavigation(); } void MsgInputSelector::showMsgBody(const std::string &text) { - NaviFrameController &navi = getNavigation(); - if (m_pMsgBodyFrame) { - navi.promote(*m_pMsgBodyFrame); - } else { - m_pMsgBodyFrame = new MsgBodyFrame(navi); - m_pMsgBodyFrame->setListener(this); - navi.push(*m_pMsgBodyFrame); - } + NaviFrameController &navi = getNavigation(); + if (m_pMsgBodyFrame) { + navi.promote(*m_pMsgBodyFrame); + } else { + m_pMsgBodyFrame = new MsgBodyFrame(navi); + m_pMsgBodyFrame->setListener(this); + navi.push(*m_pMsgBodyFrame); + } - m_pMsgBodyFrame->setText(text); + m_pMsgBodyFrame->setText(text); } void MsgInputSelector::setRecip(Recipient recip) { - m_Composer.setRecip(recip); + m_Composer.setRecip(recip); } bool MsgInputSelector::execCmd(const AppControlComposeRef &cmd) { - if (!cmd) - return false; + if (!cmd) + return false; - reset(); - m_CloseAfterSent = true; + reset(); + m_CloseAfterSent = true; - auto &recips = cmd->getRecipientList(); - if (recips.empty()) - m_Composer.setRecip({}); - else - m_Composer.setRecip(Recipient(recips.front())); + auto &recips = cmd->getRecipientList(); + if (recips.empty()) + m_Composer.setRecip({}); + else + m_Composer.setRecip(Recipient(recips.front())); - std::string text = cmd->getMessageText(); - bool isEmpty = text.empty(); - InputSelector::setText(text); - m_Composer.setText(std::move(text)); - if (isEmpty) - return launch(); - else - return launch(KeyboardType); + std::string text = cmd->getMessageText(); + bool isEmpty = text.empty(); + InputSelector::setText(text); + m_Composer.setText(std::move(text)); + if (isEmpty) + return launch(); + else + return launch(KeyboardType); } void MsgInputSelector::reset() { - m_CloseAfterSent = false; - m_Composer.reset(); - m_Composer.clear(); - if (m_pMsgBodyFrame) { - m_pMsgBodyFrame->setListener(this); - m_pMsgBodyFrame->pop(); - m_pMsgBodyFrame = nullptr; - } + m_CloseAfterSent = false; + m_Composer.reset(); + m_Composer.clear(); + if (m_pMsgBodyFrame) { + m_pMsgBodyFrame->setListener(this); + m_pMsgBodyFrame->pop(); + m_pMsgBodyFrame = nullptr; + } } void MsgInputSelector::navigateToConv(ThreadId threadId) { - NaviFrameController &navi = getNavigation(); - auto *frame = navi.findTopFrame(); + NaviFrameController &navi = getNavigation(); + auto *frame = navi.findTopFrame(); - if (frame) { - navi.promote(*frame); - } else { - frame = new ConvFrame(navi); - navi.push(*frame); - } + if (frame) { + navi.promote(*frame); + } else { + frame = new ConvFrame(navi); + navi.push(*frame); + } - frame->setThreadId(threadId); + frame->setThreadId(threadId); } void MsgInputSelector::send() { - m_Composer.send(); + m_Composer.send(); } void MsgInputSelector::addDummyAudio() { - std::string file = PathUtils::getResourcePath("dummy_res/1.mp3"); - m_Composer.addFile(file); + std::string file = PathUtils::getResourcePath("dummy_res/1.mp3"); + m_Composer.addFile(file); } void MsgInputSelector::onSendStart(Composer &composer) { - MSG_LOG(""); - ThreadId id = composer.getThreadId(); + MSG_LOG(""); + ThreadId id = composer.getThreadId(); - if (m_CloseAfterSent || !id.isValid()) { - getNavigation().popGroup(FrameController::ComposerGroup); - } else { - navigateToConv(id); - } + if (m_CloseAfterSent || !id.isValid()) { + getNavigation().popGroup(FrameController::ComposerGroup); + } else { + navigateToConv(id); + } } void MsgInputSelector::onSendFinished(Composer &composer) { - MSG_LOG(""); + MSG_LOG(""); } void MsgInputSelector::onCloseSendPopup(Composer &composer) { - MSG_LOG(""); - getNavigation().popGroup(FrameController::ComposerGroup); + MSG_LOG(""); + getNavigation().popGroup(FrameController::ComposerGroup); } void MsgInputSelector::onDestroy(MsgBodyFrame &frame) { - MSG_LOG(""); - m_pMsgBodyFrame = nullptr; + MSG_LOG(""); + m_pMsgBodyFrame = nullptr; } void MsgInputSelector::onSendRequest(MsgBodyFrame &frame) { - MSG_LOG(""); - m_Composer.setText(frame.getText()); - send(); + MSG_LOG(""); + m_Composer.setText(frame.getText()); + send(); } void MsgInputSelector::onPress(MsgBodyFrame &frame) { - setText(frame.getRawText()); - launch(KeyboardType); + setText(frame.getRawText()); + launch(KeyboardType); } void MsgInputSelector::onKeyboardReply(const std::string &text) { - MSG_LOG(""); - showMsgBody(text); + MSG_LOG(""); + showMsgBody(text); } void MsgInputSelector::onTemplateReply(const std::string &text) { - MSG_LOG(""); - m_Composer.setText(text); - send(); + MSG_LOG(""); + m_Composer.setText(text); + send(); } void MsgInputSelector::onEmoticonReply(const std::string &emoticon) { - MSG_LOG(""); - m_Composer.setText(emoticon); - // addDummyAudio(); // Only for test will be removed - send(); + MSG_LOG(""); + m_Composer.setText(emoticon); + // addDummyAudio(); // Only for test will be removed + send(); } void MsgInputSelector::onVoiceReply(const std::string &text, const std::list &fileList) { - MSG_LOG(""); - m_Composer.setText(text); - for (const std::string &file : fileList) { - m_Composer.addFile(file); - } - send(); + MSG_LOG(""); + m_Composer.setText(text); + for (const std::string &file : fileList) { + m_Composer.addFile(file); + } + send(); } diff --git a/src/Composer/Controller/src/RecipFrame.cpp b/src/Composer/Controller/src/RecipFrame.cpp index d88659c..f171705 100644 --- a/src/Composer/Controller/src/RecipFrame.cpp +++ b/src/Composer/Controller/src/RecipFrame.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -27,208 +27,208 @@ using namespace Msg; RecipFrame::RecipFrame(NaviFrameController &parent) - : FrameController(parent, ComposerGroup) - , m_pBaseLayout(nullptr) - , m_pLayout(nullptr) - , m_pNextButton(nullptr) - , m_pRecipField(nullptr) - , m_pInputFrame(nullptr) + : FrameController(parent, ComposerGroup) + , m_pBaseLayout(nullptr) + , m_pLayout(nullptr) + , m_pNextButton(nullptr) + , m_pRecipField(nullptr) + , m_pInputFrame(nullptr) { - MSG_LOG(""); + MSG_LOG(""); - prepareLayouts(); - prepareNextButton(); - prepareRecipField(); + prepareLayouts(); + prepareNextButton(); + prepareRecipField(); - updateRecipFieldButton(); - updateNextButton(); + updateRecipFieldButton(); + updateNextButton(); - m_ContactPicker.setListener(this); - App::getInst().getContactManager().addListener(*this); + m_ContactPicker.setListener(this); + App::getInst().getContactManager().addListener(*this); } bool RecipFrame::execCmd(const AppControlComposeRef &cmd) { - m_ComposeCmd = cmd; + m_ComposeCmd = cmd; - if (!cmd) - return false; + if (!cmd) + return false; - auto &recips = cmd->getRecipientList(); - if (!recips.empty()) - setRecip(recips.front()); + auto &recips = cmd->getRecipientList(); + if (!recips.empty()) + setRecip(recips.front()); - return true; + return true; } RecipFrame::~RecipFrame() { - MSG_LOG(""); - App::getInst().getContactManager().removeListener(*this); + MSG_LOG(""); + App::getInst().getContactManager().removeListener(*this); } void RecipFrame::prepareLayouts() { - if (!m_pBaseLayout) { - m_pBaseLayout = new DefaultLayout(getParent()); - m_pBaseLayout->addHwButtonEvent(EEXT_CALLBACK_BACK, makeCbFirst(&RecipFrame::onHwBackButtonPreessed), this); - } + if (!m_pBaseLayout) { + m_pBaseLayout = new DefaultLayout(getParent()); + m_pBaseLayout->addHwButtonEvent(EEXT_CALLBACK_BACK, makeCbFirst(&RecipFrame::onHwBackButtonPreessed), this); + } - if (!m_pLayout) { - m_pLayout = new RecipLayout(*m_pBaseLayout); - m_pBaseLayout->setContent(*m_pLayout); - } + if (!m_pLayout) { + m_pLayout = new RecipLayout(*m_pBaseLayout); + m_pBaseLayout->setContent(*m_pLayout); + } } void RecipFrame::prepareNextButton() { - if (!m_pNextButton) { - m_pNextButton = new BottomButton(*m_pBaseLayout); - View::addSmartCb(m_pNextButton->getInnerButton(), "clicked", makeCbFirst(&RecipFrame::onNextButtonClicked), this); - m_pNextButton->setText(msgt("WDS_MSG_ACBUTTON_NEXT")); - m_pBaseLayout->setBottomButton(*m_pNextButton); - m_pBaseLayout->showBottomButton(true); - } + if (!m_pNextButton) { + m_pNextButton = new BottomButton(*m_pBaseLayout); + View::addSmartCb(m_pNextButton->getInnerButton(), "clicked", makeCbFirst(&RecipFrame::onNextButtonClicked), this); + m_pNextButton->setText(msgt("WDS_MSG_ACBUTTON_NEXT")); + m_pBaseLayout->setBottomButton(*m_pNextButton); + m_pBaseLayout->showBottomButton(true); + } } void RecipFrame::prepareRecipField() { - if (!m_pRecipField) { - m_pRecipField = new RecipFieldView(*m_pLayout); - m_pRecipField->getEntry().addChangedCb(makeCbFirst(&RecipFrame::onEntryChanged), this); - m_pRecipField->setListener(this); - m_pLayout->setRecipField(*m_pRecipField); - } + if (!m_pRecipField) { + m_pRecipField = new RecipFieldView(*m_pLayout); + m_pRecipField->getEntry().addChangedCb(makeCbFirst(&RecipFrame::onEntryChanged), this); + m_pRecipField->setListener(this); + m_pLayout->setRecipField(*m_pRecipField); + } } void RecipFrame::updateNextButton() { - bool disabled = m_pRecipField->getEntry().isEmpty(); - m_pNextButton->disabled(disabled); + bool disabled = m_pRecipField->getEntry().isEmpty(); + m_pNextButton->disabled(disabled); } void RecipFrame::updateRecipFieldButton() { - bool isEmpty = m_pRecipField->getEntry().isEmpty(); - RecipFieldView::ButtonId buttonId = isEmpty ? RecipFieldView::ContactButtonId : RecipFieldView::ClearButtonId; - m_pRecipField->showButton(buttonId); + bool isEmpty = m_pRecipField->getEntry().isEmpty(); + RecipFieldView::ButtonId buttonId = isEmpty ? RecipFieldView::ContactButtonId : RecipFieldView::ClearButtonId; + m_pRecipField->showButton(buttonId); } void RecipFrame::setRecip(Recipient recip) { - m_Recip = std::move(recip); - m_pRecipField->getEntry().setText(m_Recip.getDispName()); + m_Recip = std::move(recip); + m_pRecipField->getEntry().setText(m_Recip.getDispName()); } void RecipFrame::setRecip(std::string address) { - Recipient recip = Recipient::getByAddress(address); - setRecip(recip); + Recipient recip = Recipient::getByAddress(address); + setRecip(recip); } void RecipFrame::clearRecip() { - m_Recip.clear(); - m_pRecipField->getEntry().clear(); + m_Recip.clear(); + m_pRecipField->getEntry().clear(); } void RecipFrame::showInputFrame() { - if (!m_pInputFrame) { - m_pInputFrame = new RecipInputFrame(getParent(), m_Recip); - addToGroup(*m_pInputFrame); - m_pInputFrame->setOnPopCb(makeCbLast(&RecipFrame::onInputFramePop), this); - getParent().push(*m_pInputFrame); - } + if (!m_pInputFrame) { + m_pInputFrame = new RecipInputFrame(getParent(), m_Recip); + addToGroup(*m_pInputFrame); + m_pInputFrame->setOnPopCb(makeCbLast(&RecipFrame::onInputFramePop), this); + getParent().push(*m_pInputFrame); + } } void RecipFrame::navigateToMsgInput() { - MsgInputSelector &inputSelector = getParent().getInputSelector(); - inputSelector.reset(); + MsgInputSelector &inputSelector = getParent().getInputSelector(); + inputSelector.reset(); - if (m_ComposeCmd) - inputSelector.execCmd(m_ComposeCmd); - else - inputSelector.launch(); + if (m_ComposeCmd) + inputSelector.execCmd(m_ComposeCmd); + else + inputSelector.launch(); - inputSelector.setRecip(m_Recip); + inputSelector.setRecip(m_Recip); } void RecipFrame::onAttached(ViewItem &item) { - MSG_LOG(""); - FrameController::onAttached(item); - setContent(*m_pBaseLayout); + MSG_LOG(""); + FrameController::onAttached(item); + setContent(*m_pBaseLayout); } void RecipFrame::onHwBackButtonPreessed(Evas_Object *obj, void *event_info) { - MSG_LOG(""); - pop(); + MSG_LOG(""); + pop(); } void RecipFrame::onNextButtonClicked(Evas_Object *obj, void *event) { - MSG_LOG(""); - if (m_Recip.isValid()) - navigateToMsgInput(); - else - ToastPopup::toast(msgt("IDS_MSG_HEADER_INVALID_RECIPIENT_ABB")); + MSG_LOG(""); + if (m_Recip.isValid()) + navigateToMsgInput(); + else + ToastPopup::toast(msgt("IDS_MSG_HEADER_INVALID_RECIPIENT_ABB")); } void RecipFrame::onFieldClicked(RecipFieldView &obj) { - MSG_LOG(""); - showInputFrame(); + MSG_LOG(""); + showInputFrame(); } void RecipFrame::onClearButtonClicked(RecipFieldView &obj) { - MSG_LOG(""); - clearRecip(); + MSG_LOG(""); + clearRecip(); } void RecipFrame::onContactButtonClicked(RecipFieldView &obj) { - MSG_LOG(""); - m_ContactPicker.launch(1); // How many to pick + MSG_LOG(""); + m_ContactPicker.launch(1); // How many to pick } void RecipFrame::onInputFramePop(NaviFrameItem &item) { - MSG_LOG(""); - setRecip(m_pInputFrame->getRecip()); - m_pInputFrame = nullptr; + MSG_LOG(""); + setRecip(m_pInputFrame->getRecip()); + m_pInputFrame = nullptr; } void RecipFrame::onEntryChanged(Evas_Object *obj, void *event) { - MSG_LOG(""); - updateNextButton(); - updateRecipFieldButton(); + MSG_LOG(""); + updateNextButton(); + updateRecipFieldButton(); } void RecipFrame::onContactsPicked(const std::list &numberIdList) { - MSG_LOG("", numberIdList.size()); - MSG_LOG("", numberIdList.front().id); - MSG_LOG("", numberIdList.front().type); - auto rec = Recipient::getByContactPersonNmberId(numberIdList.front().id); + MSG_LOG("", numberIdList.size()); + MSG_LOG("", numberIdList.front().id); + MSG_LOG("", numberIdList.front().type); + auto rec = Recipient::getByContactPersonNmberId(numberIdList.front().id); - MSG_LOG("", rec.getAddress()); - MSG_LOG("", rec.getDispName()); + MSG_LOG("", rec.getAddress()); + MSG_LOG("", rec.getDispName()); - if (!numberIdList.empty() && numberIdList.front().type == IContactPickerListener::PhoneType) - setRecip(Recipient::getByContactPersonNmberId(numberIdList.front().id)); + if (!numberIdList.empty() && numberIdList.front().type == IContactPickerListener::PhoneType) + setRecip(Recipient::getByContactPersonNmberId(numberIdList.front().id)); } void RecipFrame::onContactChanged() { - MSG_LOG(""); - if (m_Recip.isValid()) { - m_Recip.updateContactInfo(); - m_pRecipField->getEntry().setText(m_Recip.getDispName()); - } + MSG_LOG(""); + if (m_Recip.isValid()) { + m_Recip.updateContactInfo(); + m_pRecipField->getEntry().setText(m_Recip.getDispName()); + } } diff --git a/src/Composer/Controller/src/RecipInputFrame.cpp b/src/Composer/Controller/src/RecipInputFrame.cpp index 442f911..481eba6 100644 --- a/src/Composer/Controller/src/RecipInputFrame.cpp +++ b/src/Composer/Controller/src/RecipInputFrame.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -29,253 +29,253 @@ using namespace Msg; namespace { - const int minDigits = 3; - const int minCharacters = 2; - - bool isDigit(const std::string &str) { - auto itEnd = str.end(); - for (auto it = str.begin() ;it != itEnd; ++it) { - if (!isdigit(*it)) - return false; - } - return true; - } - - bool isSeparatorChar(char c) - { - return c == ';' || c == ','; - } - - bool isSeparatorChar(const std::string &str) - { - return str.size() == 1 && isSeparatorChar(str[0]); - } + const int minDigits = 3; + const int minCharacters = 2; + + bool isDigit(const std::string &str) { + auto itEnd = str.end(); + for (auto it = str.begin() ;it != itEnd; ++it) { + if (!isdigit(*it)) + return false; + } + return true; + } + + bool isSeparatorChar(char c) + { + return c == ';' || c == ','; + } + + bool isSeparatorChar(const std::string &str) + { + return str.size() == 1 && isSeparatorChar(str[0]); + } } RecipInputFrame::RecipInputFrame(NaviFrameController &parent, const Recipient &recip) - : InputFrame(parent, ComposerGroup) - , m_pSearchBar(nullptr) - , m_pTimer(nullptr) - , m_Recip(recip) - , m_IsClosed(false) + : InputFrame(parent, ComposerGroup) + , m_pSearchBar(nullptr) + , m_pTimer(nullptr) + , m_Recip(recip) + , m_IsClosed(false) { - prepareEntry(m_Recip.getAddress()); - App::getInst().getContactManager().addListener(*this); + prepareEntry(m_Recip.getAddress()); + App::getInst().getContactManager().addListener(*this); } RecipInputFrame::~RecipInputFrame() { - cancelSearch(); - App::getInst().getContactManager().removeListener(*this); + cancelSearch(); + App::getInst().getContactManager().removeListener(*this); } const Recipient &RecipInputFrame::getRecip() const { - return m_Recip; + return m_Recip; } void RecipInputFrame::showSearchBar(bool show) { - if (show && !m_pSearchBar) { - m_pSearchBar = new SearchBar(getLayout()); - m_pSearchBar->setListener(this); - setPredictBar(*m_pSearchBar); - } - showPredictBar(show); + if (show && !m_pSearchBar) { + m_pSearchBar = new SearchBar(getLayout()); + m_pSearchBar->setListener(this); + setPredictBar(*m_pSearchBar); + } + showPredictBar(show); } void RecipInputFrame::prepareEntry(std::string initText) { - getEntry().setText(std::move(initText)); - getEntry().setCursorPosToEnd(); - getEntry().setInputPanelReturnType(ELM_INPUT_PANEL_RETURN_KEY_TYPE_SEARCH); - getEntry().addChangedCb(makeCbFirst(&RecipInputFrame::onEntryChanged), this); - getEntry().addActivatedCb(makeCbFirst(&RecipInputFrame::onEntryActivated), this); - getEntry().addMarkupFilterCb(makeCbFirst(&RecipInputFrame::onEntryFilter), this); + getEntry().setText(std::move(initText)); + getEntry().setCursorPosToEnd(); + getEntry().setInputPanelReturnType(ELM_INPUT_PANEL_RETURN_KEY_TYPE_SEARCH); + getEntry().addChangedCb(makeCbFirst(&RecipInputFrame::onEntryChanged), this); + getEntry().addActivatedCb(makeCbFirst(&RecipInputFrame::onEntryActivated), this); + getEntry().addMarkupFilterCb(makeCbFirst(&RecipInputFrame::onEntryFilter), this); } void RecipInputFrame::setRecip(std::string address, std::string dispName) { - if (!address.empty()) - m_Recip.setAddress(std::move(address)); + if (!address.empty()) + m_Recip.setAddress(std::move(address)); - if (!dispName.empty()) - m_Recip.setDispName(std::move(dispName)); + if (!dispName.empty()) + m_Recip.setDispName(std::move(dispName)); - if (m_Recip.getAddress().empty()) - m_Recip.setAddress(getEntry().getText()); + if (m_Recip.getAddress().empty()) + m_Recip.setAddress(getEntry().getText()); - if (m_Recip.getDispName().empty()) - m_Recip.setDispName(m_Recip.getAddress()); + if (m_Recip.getDispName().empty()) + m_Recip.setDispName(m_Recip.getAddress()); } void RecipInputFrame::close(std::string address, std::string dispName) { - if (!m_IsClosed) { - m_IsClosed = true; - setRecip(std::move(address), std::move(dispName)); - cancelSearch(); - pop(); - } + if (!m_IsClosed) { + m_IsClosed = true; + setRecip(std::move(address), std::move(dispName)); + cancelSearch(); + pop(); + } } void RecipInputFrame::onContactChanged() { - MSG_LOG(""); - reqestSearch(); + MSG_LOG(""); + reqestSearch(); } Eina_Bool RecipInputFrame::onSearchTimerTick() { - std::string searchWord = getEntry().getText(); - std::string highlightWord; + std::string searchWord = getEntry().getText(); + std::string highlightWord; - int len = eina_unicode_utf8_get_len(searchWord.c_str()); - bool isDig = isDigit(searchWord); + int len = eina_unicode_utf8_get_len(searchWord.c_str()); + bool isDig = isDigit(searchWord); - if ((isDig && len >= minDigits) || (!isDig && len >= minCharacters)) { + if ((isDig && len >= minDigits) || (!isDig && len >= minCharacters)) { - m_Recip = Recipient::searchFirst(searchWord); + m_Recip = Recipient::searchFirst(searchWord); - if (!m_Recip.getDispName().empty()) - highlightWord = TextDecorator::highlightKeyword(m_Recip.getDispName(), searchWord); - else if (!m_Recip.getAddress().empty()) - highlightWord = TextDecorator::highlightKeyword(m_Recip.getAddress(), searchWord); - } + if (!m_Recip.getDispName().empty()) + highlightWord = TextDecorator::highlightKeyword(m_Recip.getDispName(), searchWord); + else if (!m_Recip.getAddress().empty()) + highlightWord = TextDecorator::highlightKeyword(m_Recip.getAddress(), searchWord); + } - bool showHighlight = !highlightWord.empty(); - showSearchBar(showHighlight); - if (showHighlight) - m_pSearchBar->setText(highlightWord); + bool showHighlight = !highlightWord.empty(); + showSearchBar(showHighlight); + if (showHighlight) + m_pSearchBar->setText(highlightWord); - m_pTimer = nullptr; - return false; // Delete timer + m_pTimer = nullptr; + return false; // Delete timer } void RecipInputFrame::reqestSearch() { - static const double interval = 0.3; - - if (!isPopping()) { - if (!m_pTimer) - m_pTimer = ecore_timer_add(interval, makeCbFirst(&RecipInputFrame::onSearchTimerTick), this); - else - ecore_timer_reset(m_pTimer); - } + static const double interval = 0.3; + + if (!isPopping()) { + if (!m_pTimer) + m_pTimer = ecore_timer_add(interval, makeCbFirst(&RecipInputFrame::onSearchTimerTick), this); + else + ecore_timer_reset(m_pTimer); + } } void RecipInputFrame::cancelSearch() { - if (m_pTimer) { - ecore_timer_del(m_pTimer); - m_pTimer = nullptr; - } + if (m_pTimer) { + ecore_timer_del(m_pTimer); + m_pTimer = nullptr; + } } void RecipInputFrame::searchButtonHandler() { - cancelSearch(); - - std::string input = getEntry().getText(); - int len = eina_unicode_utf8_get_len(input.c_str()); - - if (len > 0) { - bool isDig = isDigit(input); - - if (len < minCharacters && !isDig) { - ToastPopup::toast(msgt("WDS_MSG_TPOP_ENTER_2_OR_MORE_LETTERS_ABB")); - return; - } - - if (len < minDigits && isDig) { - ToastPopup::toast(msgt("WDS_MSG_TPOP_ENTER_3_OR_MORE_DIGITS_ABB")); - return; - } - - auto recips = Recipient::searchAll(input); - if (!recips.empty()) { - navigateToContactFrame(std::move(recips), std::move(input)); - } else { - if (MsgUtils::isValidNumber(input)) { - close(); - } else { - ToastPopup::toast(msgt("WDS_PB_TPOP_NO_RESULTS_FOUND"), FAIL_ICON); - } - } - } + cancelSearch(); + + std::string input = getEntry().getText(); + int len = eina_unicode_utf8_get_len(input.c_str()); + + if (len > 0) { + bool isDig = isDigit(input); + + if (len < minCharacters && !isDig) { + ToastPopup::toast(msgt("WDS_MSG_TPOP_ENTER_2_OR_MORE_LETTERS_ABB")); + return; + } + + if (len < minDigits && isDig) { + ToastPopup::toast(msgt("WDS_MSG_TPOP_ENTER_3_OR_MORE_DIGITS_ABB")); + return; + } + + auto recips = Recipient::searchAll(input); + if (!recips.empty()) { + navigateToContactFrame(std::move(recips), std::move(input)); + } else { + if (MsgUtils::isValidNumber(input)) { + close(); + } else { + ToastPopup::toast(msgt("WDS_PB_TPOP_NO_RESULTS_FOUND"), FAIL_ICON); + } + } + } } void RecipInputFrame::navigateToContactFrame(std::list recips, std::string searchWord) { - auto *frame = new ContactFrame(getParent(), std::move(recips), std::move(searchWord)); - frame->setListener(this); - addToGroup(*frame); - getParent().push(*frame); + auto *frame = new ContactFrame(getParent(), std::move(recips), std::move(searchWord)); + frame->setListener(this); + addToGroup(*frame); + getParent().push(*frame); } void RecipInputFrame::onAttached(ViewItem &item) { - MSG_LOG(""); - InputFrame::onAttached(item); + MSG_LOG(""); + InputFrame::onAttached(item); } void RecipInputFrame::onEntryFilter(Evas_Object *obj, char **text) { - if (*text) { - MSG_LOG(*text); - if (isPreedit(*text)) - return; - - if (isSeparatorChar(*text)) { - free(*text); - *text = nullptr; - std::string text = getEntry().getText(); - close(text, text); - } - } + if (*text) { + MSG_LOG(*text); + if (isPreedit(*text)) + return; + + if (isSeparatorChar(*text)) { + free(*text); + *text = nullptr; + std::string text = getEntry().getText(); + close(text, text); + } + } } void RecipInputFrame::onEntryChanged(Evas_Object *obj, void *event_info) { - MSG_LOG(""); - reqestSearch(); + MSG_LOG(""); + reqestSearch(); } void RecipInputFrame::onButtonClicked(SearchBar &obj) { - MSG_LOG(""); - searchButtonHandler(); + MSG_LOG(""); + searchButtonHandler(); } void RecipInputFrame::onTextClicked(SearchBar &obj) { - MSG_LOG(""); - close(); + MSG_LOG(""); + close(); } void RecipInputFrame::onEntryActivated(Evas_Object *obj, void *event_info) { - MSG_LOG(""); - searchButtonHandler(); + MSG_LOG(""); + searchButtonHandler(); } void RecipInputFrame::onInputPanelHide() { - MSG_LOG(""); - BasePopup *popup = App::getInst().getPopupManager().getTop(); - if (!isPause() && !(popup && popup->isVisible())) { - std::string text = getEntry().getText(); - Recipient recip = Recipient::getByAddress(text); - if (recip.isValid()) - close(recip.getAddress(), recip.getDispName()); - else - close(text, text); - } + MSG_LOG(""); + BasePopup *popup = App::getInst().getPopupManager().getTop(); + if (!isPause() && !(popup && popup->isVisible())) { + std::string text = getEntry().getText(); + Recipient recip = Recipient::getByAddress(text); + if (recip.isValid()) + close(recip.getAddress(), recip.getDispName()); + else + close(text, text); + } } void RecipInputFrame::onContactSelected(ContactFrame &sender, const Recipient &recip) { - MSG_LOG(""); - close(recip.getAddress(), recip.getDispName()); + MSG_LOG(""); + close(recip.getAddress(), recip.getDispName()); } diff --git a/src/Composer/Controller/src/SendingOptionsFrame.cpp b/src/Composer/Controller/src/SendingOptionsFrame.cpp index 63947d5..09dafa4 100644 --- a/src/Composer/Controller/src/SendingOptionsFrame.cpp +++ b/src/Composer/Controller/src/SendingOptionsFrame.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -29,107 +29,107 @@ using namespace Msg; SendingOptionsFrame::SendingOptionsFrame(NaviFrameController &parent) - : FrameController(parent, ComposerGroup) - , m_pList(nullptr) - , m_pSendingOptionItem(nullptr) - , m_pSendAsTextItem(nullptr) - , m_pListener(nullptr) + : FrameController(parent, ComposerGroup) + , m_pList(nullptr) + , m_pSendingOptionItem(nullptr) + , m_pSendAsTextItem(nullptr) + , m_pListener(nullptr) { - preapareList(); + preapareList(); } SendingOptionsFrame::~SendingOptionsFrame() { - if (m_pListener) - m_pListener->onDestroy(*this); + if (m_pListener) + m_pListener->onDestroy(*this); } void SendingOptionsFrame::setListener(ISendingOptionsFrameListener *l) { - m_pListener = l; + m_pListener = l; } void SendingOptionsFrame::preapareList() { - if (!m_pList) { - m_pList = new ListView(getParent(), App::getInst().getWindow().getCircleSurface()); - m_pList->setHomogeneous(false); - m_pList->setMultiSelection(false); - fillList(); - } + if (!m_pList) { + m_pList = new ListView(getParent(), App::getInst().getWindow().getCircleSurface()); + m_pList->setHomogeneous(false); + m_pList->setMultiSelection(false); + fillList(); + } } void SendingOptionsFrame::fillList() { - using namespace std::placeholders; + using namespace std::placeholders; - // Title: - auto *titleItem = new TitleListItem; - titleItem->setTitle(msg("WDS_IME_HEADER_SEND_AS_M_SELECT_ABB")); - m_pList->appendItem(*titleItem); + // Title: + auto *titleItem = new TitleListItem; + titleItem->setTitle(msg("WDS_IME_HEADER_SEND_AS_M_SELECT_ABB")); + m_pList->appendItem(*titleItem); - m_pSendingOptionItem = new SendingOptionListViewItem; - m_pSendingOptionItem->setListener(this); - m_pList->appendItem(*m_pSendingOptionItem); + m_pSendingOptionItem = new SendingOptionListViewItem; + m_pSendingOptionItem->setListener(this); + m_pList->appendItem(*m_pSendingOptionItem); - m_pSendAsTextItem = new AlwaysSendAsTextListViewItem; - m_pSendAsTextItem->setCheckedState(!App::getInst().getMsgEngine().getSettings().getSendAsAudio()); - m_pSendAsTextItem->setOnSelectedCb(std::bind(&SendingOptionsFrame::onSendAsTextItemSelected, this, _1)); - m_pSendAsTextItem->setOnChangedCb(std::bind(&SendingOptionsFrame::onCheckItemClicked, this, _1)); - m_pList->appendItem(*m_pSendAsTextItem); + m_pSendAsTextItem = new AlwaysSendAsTextListViewItem; + m_pSendAsTextItem->setCheckedState(!App::getInst().getMsgEngine().getSettings().getSendAsAudio()); + m_pSendAsTextItem->setOnSelectedCb(std::bind(&SendingOptionsFrame::onSendAsTextItemSelected, this, _1)); + m_pSendAsTextItem->setOnChangedCb(std::bind(&SendingOptionsFrame::onCheckItemClicked, this, _1)); + m_pList->appendItem(*m_pSendAsTextItem); - // Bottom padding: - m_pList->appendItem(*new PaddingListViewItem); + // Bottom padding: + m_pList->appendItem(*new PaddingListViewItem); } void SendingOptionsFrame::alwaysSendTextHandler(bool value) { - App::getInst().getMsgEngine().getSettings().setSendAsAudio(!value); + App::getInst().getMsgEngine().getSettings().setSendAsAudio(!value); - if (m_pListener) { - bool sendAsAudio = App::getInst().getMsgEngine().getSettings().getSendAsAudio(); - sendAsAudio ? m_pListener->onSendAsAudio(*this) : m_pListener->onSendAsText(*this); - } - pop(); + if (m_pListener) { + bool sendAsAudio = App::getInst().getMsgEngine().getSettings().getSendAsAudio(); + sendAsAudio ? m_pListener->onSendAsAudio(*this) : m_pListener->onSendAsText(*this); + } + pop(); } void SendingOptionsFrame::onAttached(ViewItem &item) { - MSG_LOG(""); - FrameController::onAttached(item); - preapareList(); - setContent(*m_pList); + MSG_LOG(""); + FrameController::onAttached(item); + preapareList(); + setContent(*m_pList); } void SendingOptionsFrame::onTextButtonClicked() { - MSG_LOG(""); - if (m_pListener) - m_pListener->onSendAsText(*this); - pop(); + MSG_LOG(""); + if (m_pListener) + m_pListener->onSendAsText(*this); + pop(); } void SendingOptionsFrame::onAudioButtonClicked() { - MSG_LOG(""); - if (m_pListener) - m_pListener->onSendAsAudio(*this); - pop(); + MSG_LOG(""); + if (m_pListener) + m_pListener->onSendAsAudio(*this); + pop(); } void SendingOptionsFrame::onSendAsTextItemSelected(ListItem &item) { - MSG_LOG(""); - auto &textItem = static_cast(item); - textItem.changeCheckedState(); - bool newState = textItem.getCheckedState(); - alwaysSendTextHandler(newState); + MSG_LOG(""); + auto &textItem = static_cast(item); + textItem.changeCheckedState(); + bool newState = textItem.getCheckedState(); + alwaysSendTextHandler(newState); } void SendingOptionsFrame::onCheckItemClicked(AlwaysSendAsTextListViewItem &item) { - MSG_LOG(""); - bool newState = item.getCheckedState(); - alwaysSendTextHandler(newState); + MSG_LOG(""); + bool newState = item.getCheckedState(); + alwaysSendTextHandler(newState); } diff --git a/src/Composer/View/inc/AlwaysSendAsTextListViewItem.h b/src/Composer/View/inc/AlwaysSendAsTextListViewItem.h index 25833bc..d4015e7 100644 --- a/src/Composer/View/inc/AlwaysSendAsTextListViewItem.h +++ b/src/Composer/View/inc/AlwaysSendAsTextListViewItem.h @@ -21,30 +21,30 @@ #include namespace Msg { - class AlwaysSendAsTextListViewItem - : public ListItem { - - public: - AlwaysSendAsTextListViewItem(); - virtual ~AlwaysSendAsTextListViewItem(); - - using OnChangedCb = std::function; - - void setOnChangedCb(OnChangedCb cb); - void setCheckedState(bool state); - void changeCheckedState(); - bool getCheckedState() const; - - private: - std::string getText(ListItem &item, const char *part) override; - Evas_Object *getContent(ListItem &item, const char *part) override; - Evas_Object *createCheck(); - void onCheckChanged(Evas_Object *obj, void *event_info); - - private: - Eina_Bool m_CheckedState; - OnChangedCb m_OnChangedCb; - }; + class AlwaysSendAsTextListViewItem + : public ListItem { + + public: + AlwaysSendAsTextListViewItem(); + virtual ~AlwaysSendAsTextListViewItem(); + + using OnChangedCb = std::function; + + void setOnChangedCb(OnChangedCb cb); + void setCheckedState(bool state); + void changeCheckedState(); + bool getCheckedState() const; + + private: + std::string getText(ListItem &item, const char *part) override; + Evas_Object *getContent(ListItem &item, const char *part) override; + Evas_Object *createCheck(); + void onCheckChanged(Evas_Object *obj, void *event_info); + + private: + Eina_Bool m_CheckedState; + OnChangedCb m_OnChangedCb; + }; } #endif /* AlwaysSendAsTextListViewItem_h_ */ diff --git a/src/Composer/View/inc/ContactListViewItem.h b/src/Composer/View/inc/ContactListViewItem.h index 6210199..876fec5 100644 --- a/src/Composer/View/inc/ContactListViewItem.h +++ b/src/Composer/View/inc/ContactListViewItem.h @@ -21,22 +21,22 @@ #include namespace Msg { - class ContactListViewItem - : public ListItem { - public: - ContactListViewItem(); - virtual ~ContactListViewItem(); + class ContactListViewItem + : public ListItem { + public: + ContactListViewItem(); + virtual ~ContactListViewItem(); - protected: - static ListItemStyleRef text1; - static ListItemStyleRef text2; + protected: + static ListItemStyleRef text1; + static ListItemStyleRef text2; - virtual std::string getSubText() = 0; - virtual std::string getMainText() = 0; + virtual std::string getSubText() = 0; + virtual std::string getMainText() = 0; - private: - std::string getText(ListItem &item, const char *part) override; - }; + private: + std::string getText(ListItem &item, const char *part) override; + }; } #endif // ContactListItemView_h_ diff --git a/src/Composer/View/inc/MsgBodyView.h b/src/Composer/View/inc/MsgBodyView.h index e61fc6e..86e9363 100644 --- a/src/Composer/View/inc/MsgBodyView.h +++ b/src/Composer/View/inc/MsgBodyView.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -23,42 +23,42 @@ namespace Msg { - class IMsgBodyViewListener; + class IMsgBodyViewListener; - class MsgBodyView - : public View { + class MsgBodyView + : public View { - public: - MsgBodyView(Evas_Object *parent); - virtual ~MsgBodyView(); + public: + MsgBodyView(Evas_Object *parent); + virtual ~MsgBodyView(); - void setListener(IMsgBodyViewListener *l); - void disabledSendButton(bool disabled); - void setCounter(int chars, int max); - void setCounter(const TText &text); - Entry &getEntry(); - const Entry &getEntry() const; + void setListener(IMsgBodyViewListener *l); + void disabledSendButton(bool disabled); + void setCounter(int chars, int max); + void setCounter(const TText &text); + Entry &getEntry(); + const Entry &getEntry() const; - private: - void prepareScroller(Evas_Object *parent); - void prepareSendButton(); - void prepareLayout(); - void prepareEntry(); + private: + void prepareScroller(Evas_Object *parent); + void prepareSendButton(); + void prepareLayout(); + void prepareEntry(); - private: - IMsgBodyViewListener *m_pListener; - Evas_Object *m_pSendButton; - Evas_Object *m_pScroller; - Evas_Object *m_pBodyLayout; - Entry *m_pEntry; - Atspi m_AoCounter; - }; + private: + IMsgBodyViewListener *m_pListener; + Evas_Object *m_pSendButton; + Evas_Object *m_pScroller; + Evas_Object *m_pBodyLayout; + Entry *m_pEntry; + Atspi m_AoCounter; + }; - class IMsgBodyViewListener { - public: - virtual ~IMsgBodyViewListener() {} - virtual void onSendButtonClicked() {} - }; + class IMsgBodyViewListener { + public: + virtual ~IMsgBodyViewListener() {} + virtual void onSendButtonClicked() {} + }; } #endif /* MsgBodyView_h_ */ diff --git a/src/Composer/View/inc/RecipFieldView.h b/src/Composer/View/inc/RecipFieldView.h index f391da2..f335a4b 100644 --- a/src/Composer/View/inc/RecipFieldView.h +++ b/src/Composer/View/inc/RecipFieldView.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -21,52 +21,52 @@ namespace Msg { - class IRecipFieldViewListener; + class IRecipFieldViewListener; - class RecipFieldView - : public View { + class RecipFieldView + : public View { - public: - enum ButtonId { - NoneButtonId, - ContactButtonId, - ClearButtonId - }; + public: + enum ButtonId { + NoneButtonId, + ContactButtonId, + ClearButtonId + }; - public: - RecipFieldView(Evas_Object *parent); - virtual ~RecipFieldView(); + public: + RecipFieldView(Evas_Object *parent); + virtual ~RecipFieldView(); - void setListener(IRecipFieldViewListener *l); - void showButton(ButtonId id); - Entry &getEntry(); + void setListener(IRecipFieldViewListener *l); + void showButton(ButtonId id); + Entry &getEntry(); - private: - void onClearButtonClicked(Evas_Object *obj, void *event); - void onContactButtonClicked(Evas_Object *obj, void *event); - void onEntryClicked(Evas_Object *obj, void *event); + private: + void onClearButtonClicked(Evas_Object *obj, void *event); + void onContactButtonClicked(Evas_Object *obj, void *event); + void onEntryClicked(Evas_Object *obj, void *event); - private: - void prepareEntry(); - Evas_Object *createButton(const char *icon); - Evas_Object *prepareClearButton(); - Evas_Object *prepareContactButton(); + private: + void prepareEntry(); + Evas_Object *createButton(const char *icon); + Evas_Object *prepareClearButton(); + Evas_Object *prepareContactButton(); - private: - IRecipFieldViewListener *m_pListener; - Entry *m_pEntry; - Evas_Object *m_pClearButton; - Evas_Object *m_pContactButton; - }; + private: + IRecipFieldViewListener *m_pListener; + Entry *m_pEntry; + Evas_Object *m_pClearButton; + Evas_Object *m_pContactButton; + }; - class IRecipFieldViewListener { - public: - virtual ~IRecipFieldViewListener() {}; + class IRecipFieldViewListener { + public: + virtual ~IRecipFieldViewListener() {}; - virtual void onFieldClicked(RecipFieldView &) {}; - virtual void onClearButtonClicked(RecipFieldView &) {}; - virtual void onContactButtonClicked(RecipFieldView &) {}; - }; + virtual void onFieldClicked(RecipFieldView &) {}; + virtual void onClearButtonClicked(RecipFieldView &) {}; + virtual void onContactButtonClicked(RecipFieldView &) {}; + }; } #endif /* RecipFieldView_h_ */ diff --git a/src/Composer/View/inc/RecipLayout.h b/src/Composer/View/inc/RecipLayout.h index ab89aed..55b581b 100644 --- a/src/Composer/View/inc/RecipLayout.h +++ b/src/Composer/View/inc/RecipLayout.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -20,24 +20,24 @@ #include "View.h" namespace Msg { - class RecipLayout - : public View { + class RecipLayout + : public View { - public: - RecipLayout(Evas_Object *parent); + public: + RecipLayout(Evas_Object *parent); - void setRecipField(Evas_Object *obj); - }; + void setRecipField(Evas_Object *obj); + }; - inline RecipLayout::RecipLayout(Evas_Object *parent) - { - setEo(addLayout(parent, RECIP_LAYOUT_EDJ_PATH, "main")); - } + inline RecipLayout::RecipLayout(Evas_Object *parent) + { + setEo(addLayout(parent, RECIP_LAYOUT_EDJ_PATH, "main")); + } - inline void RecipLayout::setRecipField(Evas_Object *obj) - { - setContent(obj, "swl.entry"); - } + inline void RecipLayout::setRecipField(Evas_Object *obj) + { + setContent(obj, "swl.entry"); + } } #endif /* RecipLayout_h_ */ diff --git a/src/Composer/View/inc/SendingOptionListViewItem.h b/src/Composer/View/inc/SendingOptionListViewItem.h index 5ce507a..488ce73 100644 --- a/src/Composer/View/inc/SendingOptionListViewItem.h +++ b/src/Composer/View/inc/SendingOptionListViewItem.h @@ -22,38 +22,38 @@ namespace Msg { - class ISendingOptionListViewItemListener; + class ISendingOptionListViewItemListener; - class SendingOptionListViewItem - : public ListItem { + class SendingOptionListViewItem + : public ListItem { - public: - SendingOptionListViewItem(); - virtual ~SendingOptionListViewItem(); + public: + SendingOptionListViewItem(); + virtual ~SendingOptionListViewItem(); - void setListener(ISendingOptionListViewItemListener *l); + void setListener(ISendingOptionListViewItemListener *l); - protected: - void onAttached(ViewItem &item) override; + protected: + void onAttached(ViewItem &item) override; - private: - Evas_Object *getTextButton(); - Evas_Object *getAudioButton(); + private: + Evas_Object *getTextButton(); + Evas_Object *getAudioButton(); - Evas_Object *makeButton(const std::string& iconName); - Evas_Object *getContent(ListItem &item, const char *part) override; - std::string getText(ListItem &item, const char *part) override; + Evas_Object *makeButton(const std::string& iconName); + Evas_Object *getContent(ListItem &item, const char *part) override; + std::string getText(ListItem &item, const char *part) override; - private: - ISendingOptionListViewItemListener *m_pListener; - }; + private: + ISendingOptionListViewItemListener *m_pListener; + }; - class ISendingOptionListViewItemListener { - public: - virtual ~ISendingOptionListViewItemListener() {}; - virtual void onTextButtonClicked() {}; - virtual void onAudioButtonClicked() {}; - }; + class ISendingOptionListViewItemListener { + public: + virtual ~ISendingOptionListViewItemListener() {}; + virtual void onTextButtonClicked() {}; + virtual void onAudioButtonClicked() {}; + }; } #endif // SendingOptionListViewItem_h_ diff --git a/src/Composer/View/src/AlwaysSendAsTextListViewItem.cpp b/src/Composer/View/src/AlwaysSendAsTextListViewItem.cpp index 7630260..3c355c2 100644 --- a/src/Composer/View/src/AlwaysSendAsTextListViewItem.cpp +++ b/src/Composer/View/src/AlwaysSendAsTextListViewItem.cpp @@ -21,8 +21,8 @@ using namespace Msg; AlwaysSendAsTextListViewItem::AlwaysSendAsTextListViewItem() - : ListItem(ListItemStyle::create("send_as_text_list_item")) - , m_CheckedState(false) + : ListItem(ListItemStyle::create("send_as_text_list_item")) + , m_CheckedState(false) { } @@ -32,62 +32,62 @@ AlwaysSendAsTextListViewItem::~AlwaysSendAsTextListViewItem() void AlwaysSendAsTextListViewItem::setOnChangedCb(OnChangedCb cb) { - m_OnChangedCb = std::move(cb); + m_OnChangedCb = std::move(cb); } void AlwaysSendAsTextListViewItem::setCheckedState(bool state) { - if (m_CheckedState != state) { - m_CheckedState = state; - update(); - } + if (m_CheckedState != state) { + m_CheckedState = state; + update(); + } } void AlwaysSendAsTextListViewItem::changeCheckedState() { - setCheckedState(!m_CheckedState); + setCheckedState(!m_CheckedState); } bool AlwaysSendAsTextListViewItem::getCheckedState() const { - return m_CheckedState; + return m_CheckedState; } std::string AlwaysSendAsTextListViewItem::getText(ListItem &item, const char *part) { - if (!strcmp(part, "elm.text")) - return msg("WDS_IME_NPBODY_ALWAYS_SEND_AS_TEXT_ABB"); + if (!strcmp(part, "elm.text")) + return msg("WDS_IME_NPBODY_ALWAYS_SEND_AS_TEXT_ABB"); - return ""; + return ""; } Evas_Object *AlwaysSendAsTextListViewItem::getContent(ListItem &item, const char *part) { - if (!strcmp(part, "elm.checkbox")) { - return createCheck(); - } + if (!strcmp(part, "elm.checkbox")) { + return createCheck(); + } - return nullptr; + return nullptr; } Evas_Object *AlwaysSendAsTextListViewItem::createCheck() { - Evas_Object *check = elm_check_add(*getOwner()); - elm_object_style_set(check, "small"); - elm_check_state_set(check, m_CheckedState); - elm_check_state_pointer_set(check, &m_CheckedState); - evas_object_propagate_events_set(check, false); - evas_object_smart_callback_add(check, "changed", makeCbFirst(&AlwaysSendAsTextListViewItem::onCheckChanged), this); - View::processSignal(check); - evas_object_show(check); - - return check; + Evas_Object *check = elm_check_add(*getOwner()); + elm_object_style_set(check, "small"); + elm_check_state_set(check, m_CheckedState); + elm_check_state_pointer_set(check, &m_CheckedState); + evas_object_propagate_events_set(check, false); + evas_object_smart_callback_add(check, "changed", makeCbFirst(&AlwaysSendAsTextListViewItem::onCheckChanged), this); + View::processSignal(check); + evas_object_show(check); + + return check; } void AlwaysSendAsTextListViewItem::onCheckChanged(Evas_Object *obj, void *event_info) { - MSG_LOG(""); - if (m_OnChangedCb) - m_OnChangedCb(*this); + MSG_LOG(""); + if (m_OnChangedCb) + m_OnChangedCb(*this); } diff --git a/src/Composer/View/src/ContactListViewItem.cpp b/src/Composer/View/src/ContactListViewItem.cpp index dda8c5d..197b365 100644 --- a/src/Composer/View/src/ContactListViewItem.cpp +++ b/src/Composer/View/src/ContactListViewItem.cpp @@ -23,12 +23,12 @@ ListItemStyleRef ContactListViewItem::text1 = ListItemStyle::create("1text"); ListItemStyleRef ContactListViewItem::text2 = ListItemStyle::create("2text"); namespace { - const char *mainTextPart = "elm.text"; - const char *subTextPart = "elm.text.1"; + const char *mainTextPart = "elm.text"; + const char *subTextPart = "elm.text.1"; } ContactListViewItem::ContactListViewItem() - : ListItem(ELM_GENLIST_ITEM_NONE) + : ListItem(ELM_GENLIST_ITEM_NONE) { } @@ -38,11 +38,11 @@ ContactListViewItem::~ContactListViewItem() std::string ContactListViewItem::getText(ListItem &item, const char *part) { - if (strcmp(part, mainTextPart) == 0) - return getMainText(); + if (strcmp(part, mainTextPart) == 0) + return getMainText(); - if (getStyle() == text2 && strcmp(part, subTextPart) == 0) - return getSubText(); + if (getStyle() == text2 && strcmp(part, subTextPart) == 0) + return getSubText(); - return ""; + return ""; } diff --git a/src/Composer/View/src/MsgBodyView.cpp b/src/Composer/View/src/MsgBodyView.cpp index 59d49fc..26f14da 100644 --- a/src/Composer/View/src/MsgBodyView.cpp +++ b/src/Composer/View/src/MsgBodyView.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -23,16 +23,16 @@ using namespace Msg; MsgBodyView::MsgBodyView(Evas_Object *parent) - : m_pListener(nullptr) - , m_pSendButton(nullptr) - , m_pScroller(nullptr) - , m_pBodyLayout(nullptr) - , m_pEntry(nullptr) + : m_pListener(nullptr) + , m_pSendButton(nullptr) + , m_pScroller(nullptr) + , m_pBodyLayout(nullptr) + , m_pEntry(nullptr) { - prepareScroller(parent); - prepareLayout(); - prepareEntry(); - prepareSendButton(); + prepareScroller(parent); + prepareLayout(); + prepareEntry(); + prepareSendButton(); } MsgBodyView::~MsgBodyView() @@ -41,93 +41,93 @@ MsgBodyView::~MsgBodyView() void MsgBodyView::setListener(IMsgBodyViewListener *l) { - m_pListener = l; + m_pListener = l; } Entry &MsgBodyView::getEntry() { - return *m_pEntry; + return *m_pEntry; } const Entry &MsgBodyView::getEntry() const { - return *m_pEntry; + return *m_pEntry; } void MsgBodyView::setCounter(int chars, int max) { - std::string text = std::to_string(chars) + "
/" + std::to_string(max); - View::setText(m_pBodyLayout, text, "text.counter"); - m_AoCounter.setName(msgArgs("IDS_MSG_TBBODY_P1SD_CHARACTERS_ENTERED_MAXIMUM_P2SD", chars, max)); + std::string text = std::to_string(chars) + "
/" + std::to_string(max); + View::setText(m_pBodyLayout, text, "text.counter"); + m_AoCounter.setName(msgArgs("IDS_MSG_TBBODY_P1SD_CHARACTERS_ENTERED_MAXIMUM_P2SD", chars, max)); } void MsgBodyView::setCounter(const TText &text) { - View::setText(m_pBodyLayout, text, "text.counter"); - m_AoCounter.setName(text.getMsg()); + View::setText(m_pBodyLayout, text, "text.counter"); + m_AoCounter.setName(text.getMsg()); } void MsgBodyView::disabledSendButton(bool value) { - elm_object_disabled_set(m_pSendButton, value); + elm_object_disabled_set(m_pSendButton, value); } void MsgBodyView::prepareLayout() { - Evas_Object *paddingLayout = addLayout(m_pScroller, MSG_BODY_EDJ_PATH, "body/padding"); - expand(paddingLayout); - evas_object_show(paddingLayout); + Evas_Object *paddingLayout = addLayout(m_pScroller, MSG_BODY_EDJ_PATH, "body/padding"); + expand(paddingLayout); + evas_object_show(paddingLayout); - m_pBodyLayout = addLayout(paddingLayout, MSG_BODY_EDJ_PATH, "body"); + m_pBodyLayout = addLayout(paddingLayout, MSG_BODY_EDJ_PATH, "body"); - m_AoCounter = registerAccessObj(m_pBodyLayout, "text.counter"); - m_AoCounter.setReadingInfo(ELM_ACCESSIBLE_READING_INFO_TYPE_NAME); + m_AoCounter = registerAccessObj(m_pBodyLayout, "text.counter"); + m_AoCounter.setReadingInfo(ELM_ACCESSIBLE_READING_INFO_TYPE_NAME); - setContent(paddingLayout, m_pBodyLayout, "swl.body"); + setContent(paddingLayout, m_pBodyLayout, "swl.body"); - setContent(m_pScroller, paddingLayout); + setContent(m_pScroller, paddingLayout); } void MsgBodyView::prepareScroller(Evas_Object *parent) { - m_pScroller = elm_scroller_add(parent); - setEo(m_pScroller); - elm_object_style_set(m_pScroller, "effect"); - elm_scroller_policy_set(m_pScroller, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO); - elm_scroller_bounce_set(m_pScroller, false, true); - show(); - expand(); - - Evas_Object *circleScroller = eext_circle_object_scroller_add(m_pScroller, App::getInst().getWindow().getCircleSurface()); - eext_circle_object_scroller_policy_set(circleScroller, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO); - eext_rotary_object_event_activated_set(circleScroller, true); + m_pScroller = elm_scroller_add(parent); + setEo(m_pScroller); + elm_object_style_set(m_pScroller, "effect"); + elm_scroller_policy_set(m_pScroller, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO); + elm_scroller_bounce_set(m_pScroller, false, true); + show(); + expand(); + + Evas_Object *circleScroller = eext_circle_object_scroller_add(m_pScroller, App::getInst().getWindow().getCircleSurface()); + eext_circle_object_scroller_policy_set(circleScroller, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO); + eext_rotary_object_event_activated_set(circleScroller, true); } void MsgBodyView::prepareEntry() { - m_pEntry = new Entry(m_pBodyLayout); - m_pEntry->setSingleLine(false); - m_pEntry->setAutocapitalType(ELM_AUTOCAPITAL_TYPE_SENTENCE); - m_pEntry->setInputPanelReturnType(ELM_INPUT_PANEL_RETURN_KEY_TYPE_SEND); - m_pEntry->setFocusAllow(true); - m_pEntry->setGuideText(msgt("WDS_MSG_NPBODY_ENTER_MESSAGE_ABB")); - setContent(m_pBodyLayout, *m_pEntry, "swl.entry"); + m_pEntry = new Entry(m_pBodyLayout); + m_pEntry->setSingleLine(false); + m_pEntry->setAutocapitalType(ELM_AUTOCAPITAL_TYPE_SENTENCE); + m_pEntry->setInputPanelReturnType(ELM_INPUT_PANEL_RETURN_KEY_TYPE_SEND); + m_pEntry->setFocusAllow(true); + m_pEntry->setGuideText(msgt("WDS_MSG_NPBODY_ENTER_MESSAGE_ABB")); + setContent(m_pBodyLayout, *m_pEntry, "swl.entry"); } void MsgBodyView::prepareSendButton() { - m_pSendButton = addIconButton(m_pBodyLayout, "msg_body/compose_icon"); - addSmartCb - (m_pSendButton, "clicked", - [](void *data, Evas_Object *obj, void *event) - { - auto *self = (MsgBodyView*)data; - if (self && self->m_pListener) - self->m_pListener->onSendButtonClicked(); - }, this); - - setContent(m_pBodyLayout, m_pSendButton, "swl.send_button"); - - Atspi(m_pSendButton).setName(msg("IDS_MSG_ACBUTTON_SEND_ABB3")); + m_pSendButton = addIconButton(m_pBodyLayout, "msg_body/compose_icon"); + addSmartCb + (m_pSendButton, "clicked", + [](void *data, Evas_Object *obj, void *event) + { + auto *self = (MsgBodyView*)data; + if (self && self->m_pListener) + self->m_pListener->onSendButtonClicked(); + }, this); + + setContent(m_pBodyLayout, m_pSendButton, "swl.send_button"); + + Atspi(m_pSendButton).setName(msg("IDS_MSG_ACBUTTON_SEND_ABB3")); } diff --git a/src/Composer/View/src/RecipFieldView.cpp b/src/Composer/View/src/RecipFieldView.cpp index 96273cb..77cec24 100644 --- a/src/Composer/View/src/RecipFieldView.cpp +++ b/src/Composer/View/src/RecipFieldView.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -22,14 +22,14 @@ using namespace Msg; RecipFieldView::RecipFieldView(Evas_Object *parent) - : m_pListener(nullptr) - , m_pEntry(nullptr) - , m_pClearButton(nullptr) - , m_pContactButton(nullptr) + : m_pListener(nullptr) + , m_pEntry(nullptr) + , m_pClearButton(nullptr) + , m_pContactButton(nullptr) { - setEo(addLayout(parent, RECIP_ENTRY_EDJ_PATH, "main")); - prepareEntry(); - showButton(ContactButtonId); + setEo(addLayout(parent, RECIP_ENTRY_EDJ_PATH, "main")); + prepareEntry(); + showButton(ContactButtonId); } RecipFieldView::~RecipFieldView() @@ -38,95 +38,95 @@ RecipFieldView::~RecipFieldView() void RecipFieldView::setListener(IRecipFieldViewListener *l) { - m_pListener = l; + m_pListener = l; } void RecipFieldView::prepareEntry() { - m_pEntry = new Entry(getEo()); - m_pEntry->enabledInputPanel(false); - m_pEntry->setEditable(false); - m_pEntry->setSingleLine(true); - m_pEntry->setScrollable(true); - m_pEntry->setScrollerPolicy(ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF); - m_pEntry->setAutocapitalType(ELM_AUTOCAPITAL_TYPE_NONE); - m_pEntry->setInputPanelReturnType(ELM_INPUT_PANEL_RETURN_KEY_TYPE_SEARCH); - m_pEntry->setGuideText(msgt("WDS_MSG_NPBODY_ENTER_RECIPIENT_ABB")); - m_pEntry->addSmartCb("clicked", makeCbFirst(&RecipFieldView::onEntryClicked), this); - setContent(*m_pEntry, "swl.entry"); + m_pEntry = new Entry(getEo()); + m_pEntry->enabledInputPanel(false); + m_pEntry->setEditable(false); + m_pEntry->setSingleLine(true); + m_pEntry->setScrollable(true); + m_pEntry->setScrollerPolicy(ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF); + m_pEntry->setAutocapitalType(ELM_AUTOCAPITAL_TYPE_NONE); + m_pEntry->setInputPanelReturnType(ELM_INPUT_PANEL_RETURN_KEY_TYPE_SEARCH); + m_pEntry->setGuideText(msgt("WDS_MSG_NPBODY_ENTER_RECIPIENT_ABB")); + m_pEntry->addSmartCb("clicked", makeCbFirst(&RecipFieldView::onEntryClicked), this); + setContent(*m_pEntry, "swl.entry"); } Evas_Object *RecipFieldView::createButton(const char *icon) { - Evas_Object *button = addIconButton(getEo(), icon); - return button; + Evas_Object *button = addIconButton(getEo(), icon); + return button; } Evas_Object *RecipFieldView::prepareClearButton() { - if (!m_pClearButton) { - m_pClearButton = createButton("recip/del_icon"); - addSmartCb(m_pClearButton, "clicked", makeCbFirst(&RecipFieldView::onClearButtonClicked), this); - } - return m_pClearButton; + if (!m_pClearButton) { + m_pClearButton = createButton("recip/del_icon"); + addSmartCb(m_pClearButton, "clicked", makeCbFirst(&RecipFieldView::onClearButtonClicked), this); + } + return m_pClearButton; } Evas_Object *RecipFieldView::prepareContactButton() { - if (!m_pContactButton) { - m_pContactButton = createButton("recip/contact_icon"); - addSmartCb(m_pContactButton, "clicked", makeCbFirst(&RecipFieldView::onContactButtonClicked), this); - } - return m_pContactButton; + if (!m_pContactButton) { + m_pContactButton = createButton("recip/contact_icon"); + addSmartCb(m_pContactButton, "clicked", makeCbFirst(&RecipFieldView::onContactButtonClicked), this); + } + return m_pContactButton; } Entry &RecipFieldView::getEntry() { - return *m_pEntry; + return *m_pEntry; } void RecipFieldView::showButton(ButtonId id) { - Evas_Object *curButton = getContent("swl.icon"); - Evas_Object *targetButton = nullptr; - - switch (id) { - case ContactButtonId: - targetButton = prepareContactButton(); - break; - case ClearButtonId: - targetButton = prepareClearButton(); - break; - default: - break; - } - - if (curButton != targetButton) { - Evas_Object *oldButton = setContent(targetButton, "swl.icon", true); - if (oldButton) - evas_object_hide(oldButton); - } - - Atspi ao = Atspi(targetButton); - ao.setName((id == ContactButtonId) ? msg("IDS_MSG_BODY_ADD_FROM_CONTACTS_T_TTS") : "Clear"); // TODO: add IDS TRU-694 - ao.setRole(ELM_ATSPI_ROLE_PUSH_BUTTON); - ao.setReadingInfo(Elm_Accessible_Reading_Info_Type(ELM_ACCESSIBLE_READING_INFO_TYPE_NAME | ELM_ACCESSIBLE_READING_INFO_TYPE_ROLE)); + Evas_Object *curButton = getContent("swl.icon"); + Evas_Object *targetButton = nullptr; + + switch (id) { + case ContactButtonId: + targetButton = prepareContactButton(); + break; + case ClearButtonId: + targetButton = prepareClearButton(); + break; + default: + break; + } + + if (curButton != targetButton) { + Evas_Object *oldButton = setContent(targetButton, "swl.icon", true); + if (oldButton) + evas_object_hide(oldButton); + } + + Atspi ao = Atspi(targetButton); + ao.setName((id == ContactButtonId) ? msg("IDS_MSG_BODY_ADD_FROM_CONTACTS_T_TTS") : "Clear"); // TODO: add IDS TRU-694 + ao.setRole(ELM_ATSPI_ROLE_PUSH_BUTTON); + ao.setReadingInfo(Elm_Accessible_Reading_Info_Type(ELM_ACCESSIBLE_READING_INFO_TYPE_NAME | ELM_ACCESSIBLE_READING_INFO_TYPE_ROLE)); } void RecipFieldView::onClearButtonClicked(Evas_Object *obj, void *event) { - if (m_pListener) - m_pListener->onClearButtonClicked(*this); + if (m_pListener) + m_pListener->onClearButtonClicked(*this); } void RecipFieldView::onContactButtonClicked(Evas_Object *obj, void *event) { - if (m_pListener) - m_pListener->onContactButtonClicked(*this); + if (m_pListener) + m_pListener->onContactButtonClicked(*this); } void RecipFieldView::onEntryClicked(Evas_Object *obj, void *event) { - if (m_pListener) - m_pListener->onFieldClicked(*this); + if (m_pListener) + m_pListener->onFieldClicked(*this); } diff --git a/src/Composer/View/src/SendingOptionListViewItem.cpp b/src/Composer/View/src/SendingOptionListViewItem.cpp index f9f276a..cd6e117 100644 --- a/src/Composer/View/src/SendingOptionListViewItem.cpp +++ b/src/Composer/View/src/SendingOptionListViewItem.cpp @@ -22,17 +22,17 @@ using namespace Msg; namespace { - const char *iconTextPart = "elm.left"; - const char *iconAudioPart = "elm.right"; - const char *stringTextPart = "elm.text.textblock"; - const char *stringAudioPart = "elm.audio.textblock"; - const char *smsTextPart = "elm.sms.textblock"; - const char *mmsTextPart = "elm.mms.textblock"; + const char *iconTextPart = "elm.left"; + const char *iconAudioPart = "elm.right"; + const char *stringTextPart = "elm.text.textblock"; + const char *stringAudioPart = "elm.audio.textblock"; + const char *smsTextPart = "elm.sms.textblock"; + const char *mmsTextPart = "elm.mms.textblock"; } SendingOptionListViewItem::SendingOptionListViewItem() - : ListItem(ListItemStyle::create("select_input_threadlist_item")) - , m_pListener(nullptr) + : ListItem(ListItemStyle::create("select_input_threadlist_item")) + , m_pListener(nullptr) { } @@ -42,75 +42,75 @@ SendingOptionListViewItem::~SendingOptionListViewItem() Evas_Object *SendingOptionListViewItem::getContent(ListItem &item, const char *part) { - Evas_Object *content = nullptr; + Evas_Object *content = nullptr; - if (!strcmp(part, iconTextPart)) - content = getTextButton(); - else if (!strcmp(part, iconAudioPart)) - content = getAudioButton(); + if (!strcmp(part, iconTextPart)) + content = getTextButton(); + else if (!strcmp(part, iconAudioPart)) + content = getAudioButton(); - return content; + return content; } std::string SendingOptionListViewItem::getText(ListItem &item, const char *part) { - if (!strcmp(part, stringTextPart)) - return msg("WDS_MSG_BUTTON_TEXT_ABB"); - else if (!strcmp(part, stringAudioPart)) - return msg("WDS_MSG_BUTTON_AUDIO_ABB"); - else if (!strcmp(part, smsTextPart)) - return msg("WDS_MSG_SBODY_SMS_ABB"); - else if (!strcmp(part, mmsTextPart)) - return msg("WDS_MSG_SBODY_MMS_ABB"); - - return ""; + if (!strcmp(part, stringTextPart)) + return msg("WDS_MSG_BUTTON_TEXT_ABB"); + else if (!strcmp(part, stringAudioPart)) + return msg("WDS_MSG_BUTTON_AUDIO_ABB"); + else if (!strcmp(part, smsTextPart)) + return msg("WDS_MSG_SBODY_SMS_ABB"); + else if (!strcmp(part, mmsTextPart)) + return msg("WDS_MSG_SBODY_MMS_ABB"); + + return ""; } void SendingOptionListViewItem::onAttached(ViewItem &item) { - setSelectable(false); + setSelectable(false); } Evas_Object *SendingOptionListViewItem::getTextButton() { - Evas_Object *btn = makeButton("send_option/text_icon"); - evas_object_smart_callback_add( - btn, "clicked", - [](void *data, Evas_Object *obj, void *event) - { - auto *self = static_cast(data); - if (self && self->m_pListener) - self->m_pListener->onTextButtonClicked(); - }, - this); - - return btn; + Evas_Object *btn = makeButton("send_option/text_icon"); + evas_object_smart_callback_add( + btn, "clicked", + [](void *data, Evas_Object *obj, void *event) + { + auto *self = static_cast(data); + if (self && self->m_pListener) + self->m_pListener->onTextButtonClicked(); + }, + this); + + return btn; } Evas_Object *SendingOptionListViewItem::getAudioButton() { - Evas_Object *btn = makeButton("send_option/audio_icon"); - evas_object_smart_callback_add( - btn, "clicked", - [](void *data, Evas_Object *obj, void *event) - { - auto *self = static_cast(data); - if (self && self->m_pListener) - self->m_pListener->onAudioButtonClicked(); - }, - this); - - return btn; + Evas_Object *btn = makeButton("send_option/audio_icon"); + evas_object_smart_callback_add( + btn, "clicked", + [](void *data, Evas_Object *obj, void *event) + { + auto *self = static_cast(data); + if (self && self->m_pListener) + self->m_pListener->onAudioButtonClicked(); + }, + this); + + return btn; } Evas_Object *SendingOptionListViewItem::makeButton(const std::string& iconName) { - Evas_Object *button = View::addIconButton(*getOwner(), iconName); - return button; + Evas_Object *button = View::addIconButton(*getOwner(), iconName); + return button; } void SendingOptionListViewItem::setListener(ISendingOptionListViewItemListener *l) { - m_pListener = l; + m_pListener = l; } diff --git a/src/Conversation/Controller/inc/BubbleAudioEntity.h b/src/Conversation/Controller/inc/BubbleAudioEntity.h index 457e1ba..126e614 100644 --- a/src/Conversation/Controller/inc/BubbleAudioEntity.h +++ b/src/Conversation/Controller/inc/BubbleAudioEntity.h @@ -24,61 +24,61 @@ #include namespace Msg { - class BubbleAudioEntity - : public BubbleEntity - , private IMediaPlayerProviderClient - , private IMediaPlayerListener { + class BubbleAudioEntity + : public BubbleEntity + , private IMediaPlayerProviderClient + , private IMediaPlayerListener { - public: - BubbleAudioEntity(MediaPlayerProviderRef mediaPlayerProvider, - std::string filePath, - std::string fileName, - Message::Direction direction); + public: + BubbleAudioEntity(MediaPlayerProviderRef mediaPlayerProvider, + std::string filePath, + std::string fileName, + Message::Direction direction); - virtual ~BubbleAudioEntity(); + virtual ~BubbleAudioEntity(); - void clickHandler(); - BubbleAudioViewItem *createView(Evas_Object *parent) override; + void clickHandler(); + BubbleAudioViewItem *createView(Evas_Object *parent) override; - private: - // View: - void onViewDel(Evas *e, Evas_Object *obj, void *event_info); + private: + // View: + void onViewDel(Evas *e, Evas_Object *obj, void *event_info); - // IMediaPlayerProviderClient: - void onAcquire(MediaPlayerProvider &provider) override; - void onRelease(MediaPlayerProvider &provider) override; + // IMediaPlayerProviderClient: + void onAcquire(MediaPlayerProvider &provider) override; + void onRelease(MediaPlayerProvider &provider) override; - // IMediaPlayerListener: - void onCompleted(MediaPlayer &player) override; - void onSoundFocusChanged(MediaPlayer &player) override; + // IMediaPlayerListener: + void onCompleted(MediaPlayer &player) override; + void onSoundFocusChanged(MediaPlayer &player) override; - // Timer: - Eina_Bool onTick(); + // Timer: + Eina_Bool onTick(); - struct PlayInfo { - std::string uri; - int duration; // msec - int playPos; // msec - bool isPlaying; - }; + struct PlayInfo { + std::string uri; + int duration; // msec + int playPos; // msec + bool isPlaying; + }; - void play(); - void stop(); - void stopHandler(); - void stopTimer(); - void startTimer(); - void updateProgress(); - void updatePlayState(); + void play(); + void stop(); + void stopHandler(); + void stopTimer(); + void startTimer(); + void updateProgress(); + void updatePlayState(); - private: - MediaPlayerProviderRef m_MediaPlayerProvider; - BubbleAudioViewItem *m_pView; - Ecore_Timer *m_pTimer; - MediaPlayer *m_pPlayer; - PlayInfo m_PlayInfo; - std::string m_FileName; - std::string m_DurationStr; - }; + private: + MediaPlayerProviderRef m_MediaPlayerProvider; + BubbleAudioViewItem *m_pView; + Ecore_Timer *m_pTimer; + MediaPlayer *m_pPlayer; + PlayInfo m_PlayInfo; + std::string m_FileName; + std::string m_DurationStr; + }; } #endif /* BubbleAudioEntity_h_ */ diff --git a/src/Conversation/Controller/inc/BubbleCalEventEntity.h b/src/Conversation/Controller/inc/BubbleCalEventEntity.h index 06e26cf..804a1e2 100644 --- a/src/Conversation/Controller/inc/BubbleCalEventEntity.h +++ b/src/Conversation/Controller/inc/BubbleCalEventEntity.h @@ -21,18 +21,18 @@ #include "BubbleIconTextLayoutItem.h" namespace Msg { - class BubbleCalEventEntity - : public BubbleEntity { - public: - BubbleCalEventEntity(const std::string &filePath, const std::string fileName, Message::Direction direction); - virtual ~BubbleCalEventEntity(); + class BubbleCalEventEntity + : public BubbleEntity { + public: + BubbleCalEventEntity(const std::string &filePath, const std::string fileName, Message::Direction direction); + virtual ~BubbleCalEventEntity(); - BubbleIconTextLayoutItem *createView(Evas_Object *parent) override; + BubbleIconTextLayoutItem *createView(Evas_Object *parent) override; - private: - std::string m_Name; - std::string m_DateTime; - }; + private: + std::string m_Name; + std::string m_DateTime; + }; } #endif /* BubbleCalEventEntity_h_ */ diff --git a/src/Conversation/Controller/inc/BubbleContactEntity.h b/src/Conversation/Controller/inc/BubbleContactEntity.h index f2d0b07..5d08c3f 100644 --- a/src/Conversation/Controller/inc/BubbleContactEntity.h +++ b/src/Conversation/Controller/inc/BubbleContactEntity.h @@ -21,17 +21,17 @@ #include "BubbleEntity.h" namespace Msg { - class BubbleContactEntity - : public BubbleEntity { - public: - BubbleContactEntity(const std::string &filePath, std::string fileName, Message::Direction direction); - virtual ~BubbleContactEntity(); + class BubbleContactEntity + : public BubbleEntity { + public: + BubbleContactEntity(const std::string &filePath, std::string fileName, Message::Direction direction); + virtual ~BubbleContactEntity(); - BubbleIconTextLayoutItem *createView(Evas_Object *parent) override; + BubbleIconTextLayoutItem *createView(Evas_Object *parent) override; - private: - std::string m_Name; - }; + private: + std::string m_Name; + }; } #endif /* BubbleContactEntity_h_ */ diff --git a/src/Conversation/Controller/inc/BubbleEntity.h b/src/Conversation/Controller/inc/BubbleEntity.h index 97e0ab2..feaab8b 100644 --- a/src/Conversation/Controller/inc/BubbleEntity.h +++ b/src/Conversation/Controller/inc/BubbleEntity.h @@ -27,78 +27,78 @@ #include namespace Msg { - class BubbleEntity; - typedef std::shared_ptr BubbleEntityRef; - - class BubbleEntity { - public: - enum Type { - SubjectItem, - TextItem, - ImageItem, - AudioItem, - VideoItem, - ContactItem, - CalendarEventItem, - UnknownFileItem, - RetrieveMessageItem, - NoContentItem - }; - - public: - BubbleEntity(Type type, Message::Direction direction, std::string filePath = ""); - virtual ~BubbleEntity(); - - Type getType() const; - Message::Direction getDirection() const; - const std::string &getFilePath() const; - void setFilePath(std::string file); - long long getFileSize() const; - virtual BubbleViewItem *createView(Evas_Object *parent) = 0; - - private: - Type m_Type; - Message::Direction m_Direction; - std::string m_FilePath; - long long m_FileSize; - }; - - inline BubbleEntity::BubbleEntity(Type type, Message::Direction direction, std::string filePath) - : m_Type(type) - , m_Direction(direction) - , m_FilePath(std::move(filePath)) - , m_FileSize(!filePath.empty() ? FileUtils::getFileSize(filePath) : 0) - { - } - - inline BubbleEntity::~BubbleEntity() - { - } - - inline BubbleEntity::Type BubbleEntity::getType() const - { - return m_Type; - } - - inline Message::Direction BubbleEntity::getDirection() const - { - return m_Direction; - } - - inline const std::string &BubbleEntity::getFilePath() const - { - return m_FilePath; - } - - inline void BubbleEntity::setFilePath(std::string file) - { - m_FilePath = std::move(file); - } - - inline long long BubbleEntity::getFileSize() const - { - return m_FileSize; - } + class BubbleEntity; + typedef std::shared_ptr BubbleEntityRef; + + class BubbleEntity { + public: + enum Type { + SubjectItem, + TextItem, + ImageItem, + AudioItem, + VideoItem, + ContactItem, + CalendarEventItem, + UnknownFileItem, + RetrieveMessageItem, + NoContentItem + }; + + public: + BubbleEntity(Type type, Message::Direction direction, std::string filePath = ""); + virtual ~BubbleEntity(); + + Type getType() const; + Message::Direction getDirection() const; + const std::string &getFilePath() const; + void setFilePath(std::string file); + long long getFileSize() const; + virtual BubbleViewItem *createView(Evas_Object *parent) = 0; + + private: + Type m_Type; + Message::Direction m_Direction; + std::string m_FilePath; + long long m_FileSize; + }; + + inline BubbleEntity::BubbleEntity(Type type, Message::Direction direction, std::string filePath) + : m_Type(type) + , m_Direction(direction) + , m_FilePath(std::move(filePath)) + , m_FileSize(!filePath.empty() ? FileUtils::getFileSize(filePath) : 0) + { + } + + inline BubbleEntity::~BubbleEntity() + { + } + + inline BubbleEntity::Type BubbleEntity::getType() const + { + return m_Type; + } + + inline Message::Direction BubbleEntity::getDirection() const + { + return m_Direction; + } + + inline const std::string &BubbleEntity::getFilePath() const + { + return m_FilePath; + } + + inline void BubbleEntity::setFilePath(std::string file) + { + m_FilePath = std::move(file); + } + + inline long long BubbleEntity::getFileSize() const + { + return m_FileSize; + } } diff --git a/src/Conversation/Controller/inc/BubbleEntityFactory.h b/src/Conversation/Controller/inc/BubbleEntityFactory.h index 1c3628c..aaaaaab 100644 --- a/src/Conversation/Controller/inc/BubbleEntityFactory.h +++ b/src/Conversation/Controller/inc/BubbleEntityFactory.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -28,39 +28,39 @@ namespace Msg { - class BubbleTextEntity; - class BubbleImageEntity; - class BubbleVideoEntity; - class BubbleRetrieveEntity; - class BubbleUnknownFileEntity; - class BubbleCalEventEntity; - class BubbleContactEntity; - class BubbleNoContentEntity; - class MediaPlayer; + class BubbleTextEntity; + class BubbleImageEntity; + class BubbleVideoEntity; + class BubbleRetrieveEntity; + class BubbleUnknownFileEntity; + class BubbleCalEventEntity; + class BubbleContactEntity; + class BubbleNoContentEntity; + class MediaPlayer; - class BubbleEntityFactory { - public: - BubbleEntityFactory(WorkingDirRef &workingDir); - ~BubbleEntityFactory(); + class BubbleEntityFactory { + public: + BubbleEntityFactory(WorkingDirRef &workingDir); + ~BubbleEntityFactory(); - std::list create(const MsgConversationItem &item); + std::list create(const MsgConversationItem &item); - private: - BubbleEntity *createEntity(const MsgConvMedia &msgMedia, Message::Direction direction); - BubbleTextEntity *createTextEntity(std::string text, Message::Direction direction); - BubbleRetrieveEntity *createRetrieveEntity(Message::Direction direction); - BubbleNoContentEntity *createNoContentEntity(Message::Direction direction); - BubbleEntity *createTextEntityFromFile(std::string filePath, Message::Direction direction); - BubbleEntity *createSubjectEntity(const std::string subject, Message::Direction direction); - BubbleEntity *createVideoEntity(std::string filePath, std::string fileName, Message::Direction direction); - BubbleEntity *createAudioEntity(std::string filePath, std::string fileName, Message::Direction direction); - BubbleEntityFactory(BubbleEntityFactory&) = delete; - BubbleEntityFactory& operator=(const BubbleEntityFactory&) = delete; + private: + BubbleEntity *createEntity(const MsgConvMedia &msgMedia, Message::Direction direction); + BubbleTextEntity *createTextEntity(std::string text, Message::Direction direction); + BubbleRetrieveEntity *createRetrieveEntity(Message::Direction direction); + BubbleNoContentEntity *createNoContentEntity(Message::Direction direction); + BubbleEntity *createTextEntityFromFile(std::string filePath, Message::Direction direction); + BubbleEntity *createSubjectEntity(const std::string subject, Message::Direction direction); + BubbleEntity *createVideoEntity(std::string filePath, std::string fileName, Message::Direction direction); + BubbleEntity *createAudioEntity(std::string filePath, std::string fileName, Message::Direction direction); + BubbleEntityFactory(BubbleEntityFactory&) = delete; + BubbleEntityFactory& operator=(const BubbleEntityFactory&) = delete; - private: - WorkingDirRef m_WorkingDir; - MediaPlayerProviderRef m_MediaPlayerProvider; - }; + private: + WorkingDirRef m_WorkingDir; + MediaPlayerProviderRef m_MediaPlayerProvider; + }; } #endif /* BubbleEntityFactory_h_ */ diff --git a/src/Conversation/Controller/inc/BubbleImageEntity.h b/src/Conversation/Controller/inc/BubbleImageEntity.h index 5d76765..f283ab6 100644 --- a/src/Conversation/Controller/inc/BubbleImageEntity.h +++ b/src/Conversation/Controller/inc/BubbleImageEntity.h @@ -21,30 +21,30 @@ #include "BubbleEntity.h" namespace Msg { - class BubbleImageEntity - : public BubbleEntity { - public: - BubbleImageEntity(const std::string &filePath, Message::Direction direction); - virtual ~BubbleImageEntity(); - - BubbleImageViewItem *createView(Evas_Object *parent) override; - }; - - - inline BubbleImageEntity::BubbleImageEntity(const std::string &filePath, Message::Direction direction) - : BubbleEntity(ImageItem, direction, filePath) - { - } - - inline BubbleImageEntity::~BubbleImageEntity() - { - } - - inline BubbleImageViewItem *BubbleImageEntity::createView(Evas_Object *parent) - { - auto *item = new BubbleImageViewItem(*this, parent, getFilePath()); - return item; - } + class BubbleImageEntity + : public BubbleEntity { + public: + BubbleImageEntity(const std::string &filePath, Message::Direction direction); + virtual ~BubbleImageEntity(); + + BubbleImageViewItem *createView(Evas_Object *parent) override; + }; + + + inline BubbleImageEntity::BubbleImageEntity(const std::string &filePath, Message::Direction direction) + : BubbleEntity(ImageItem, direction, filePath) + { + } + + inline BubbleImageEntity::~BubbleImageEntity() + { + } + + inline BubbleImageViewItem *BubbleImageEntity::createView(Evas_Object *parent) + { + auto *item = new BubbleImageViewItem(*this, parent, getFilePath()); + return item; + } } #endif /* BubbleImageEntity_h_ */ diff --git a/src/Conversation/Controller/inc/BubbleNoContentEntity.h b/src/Conversation/Controller/inc/BubbleNoContentEntity.h index 60b4707..fc9cf78 100644 --- a/src/Conversation/Controller/inc/BubbleNoContentEntity.h +++ b/src/Conversation/Controller/inc/BubbleNoContentEntity.h @@ -21,29 +21,29 @@ #include "BubbleEntity.h" namespace Msg { - class BubbleNoContentEntity - : public BubbleEntity { - public: - BubbleNoContentEntity(Message::Direction direction); - virtual ~BubbleNoContentEntity(); - - BubbleInfoTextViewItem *createView(Evas_Object *parent) override; - }; - - inline BubbleNoContentEntity::BubbleNoContentEntity(Message::Direction direction) - : BubbleEntity(NoContentItem, direction) - { - } - - inline BubbleNoContentEntity::~BubbleNoContentEntity() - { - } - - inline BubbleInfoTextViewItem *BubbleNoContentEntity::createView(Evas_Object *parent) - { - auto *item = new BubbleInfoTextViewItem(*this, parent, "WDS_MSG_NPBODY_NO_CONTENT_ABB"); - return item; - } + class BubbleNoContentEntity + : public BubbleEntity { + public: + BubbleNoContentEntity(Message::Direction direction); + virtual ~BubbleNoContentEntity(); + + BubbleInfoTextViewItem *createView(Evas_Object *parent) override; + }; + + inline BubbleNoContentEntity::BubbleNoContentEntity(Message::Direction direction) + : BubbleEntity(NoContentItem, direction) + { + } + + inline BubbleNoContentEntity::~BubbleNoContentEntity() + { + } + + inline BubbleInfoTextViewItem *BubbleNoContentEntity::createView(Evas_Object *parent) + { + auto *item = new BubbleInfoTextViewItem(*this, parent, "WDS_MSG_NPBODY_NO_CONTENT_ABB"); + return item; + } } #endif /* BubbleNoContentEntity_h_ */ diff --git a/src/Conversation/Controller/inc/BubbleRetrieveEntity.h b/src/Conversation/Controller/inc/BubbleRetrieveEntity.h index 10bc965..1dda4c5 100644 --- a/src/Conversation/Controller/inc/BubbleRetrieveEntity.h +++ b/src/Conversation/Controller/inc/BubbleRetrieveEntity.h @@ -21,29 +21,29 @@ #include "BubbleEntity.h" namespace Msg { - class BubbleRetrieveEntity - : public BubbleEntity { - public: - BubbleRetrieveEntity(Message::Direction direction); - virtual ~BubbleRetrieveEntity(); - - BubbleInfoTextViewItem *createView(Evas_Object *parent) override; - }; - - inline BubbleRetrieveEntity::BubbleRetrieveEntity(Message::Direction direction) - : BubbleEntity(RetrieveMessageItem, direction) - { - } - - inline BubbleRetrieveEntity::~BubbleRetrieveEntity() - { - } - - inline BubbleInfoTextViewItem *BubbleRetrieveEntity::createView(Evas_Object *parent) - { - auto *item = new BubbleInfoTextViewItem(*this, parent, "WDS_MSG_NPBODY_TAP_HERE_TO_RETRIEVE_MESSAGE"); - return item; - } + class BubbleRetrieveEntity + : public BubbleEntity { + public: + BubbleRetrieveEntity(Message::Direction direction); + virtual ~BubbleRetrieveEntity(); + + BubbleInfoTextViewItem *createView(Evas_Object *parent) override; + }; + + inline BubbleRetrieveEntity::BubbleRetrieveEntity(Message::Direction direction) + : BubbleEntity(RetrieveMessageItem, direction) + { + } + + inline BubbleRetrieveEntity::~BubbleRetrieveEntity() + { + } + + inline BubbleInfoTextViewItem *BubbleRetrieveEntity::createView(Evas_Object *parent) + { + auto *item = new BubbleInfoTextViewItem(*this, parent, "WDS_MSG_NPBODY_TAP_HERE_TO_RETRIEVE_MESSAGE"); + return item; + } } #endif /* BubbleRetrieveEntity_h_ */ diff --git a/src/Conversation/Controller/inc/BubbleSubjectEntity.h b/src/Conversation/Controller/inc/BubbleSubjectEntity.h index bdef5f8..0b451c4 100644 --- a/src/Conversation/Controller/inc/BubbleSubjectEntity.h +++ b/src/Conversation/Controller/inc/BubbleSubjectEntity.h @@ -21,17 +21,17 @@ #include "BubbleSubjectViewItem.h" namespace Msg { - class BubbleSubjectEntity - : public BubbleEntity { - public: - BubbleSubjectEntity(const std::string subject, Message::Direction direction); - virtual ~BubbleSubjectEntity(); + class BubbleSubjectEntity + : public BubbleEntity { + public: + BubbleSubjectEntity(const std::string subject, Message::Direction direction); + virtual ~BubbleSubjectEntity(); - BubbleSubjectViewItem *createView(Evas_Object *parent) override; + BubbleSubjectViewItem *createView(Evas_Object *parent) override; - private: - std::string m_Subject; - }; + private: + std::string m_Subject; + }; } #endif /* BubbleSubjectEntity_h_ */ diff --git a/src/Conversation/Controller/inc/BubbleTextEntity.h b/src/Conversation/Controller/inc/BubbleTextEntity.h index 19dd7bd..1e0319a 100644 --- a/src/Conversation/Controller/inc/BubbleTextEntity.h +++ b/src/Conversation/Controller/inc/BubbleTextEntity.h @@ -21,33 +21,33 @@ #include "BubbleEntity.h" namespace Msg { - class BubbleTextEntity - : public BubbleEntity { - public: - BubbleTextEntity(Message::Direction direction, std::string text); - virtual ~BubbleTextEntity(); - - BubbleTextViewItem *createView(Evas_Object *parent) override; - - private: - std::string m_Text; - }; - - inline BubbleTextEntity::BubbleTextEntity(Message::Direction direction, std::string text) - : BubbleEntity(TextItem, direction) - , m_Text(std::move(text)) - { - } - - inline BubbleTextEntity::~BubbleTextEntity() - { - } - - inline BubbleTextViewItem *BubbleTextEntity::createView(Evas_Object *parent) - { - auto *item = new BubbleTextViewItem(*this, parent, m_Text); - return item; - } + class BubbleTextEntity + : public BubbleEntity { + public: + BubbleTextEntity(Message::Direction direction, std::string text); + virtual ~BubbleTextEntity(); + + BubbleTextViewItem *createView(Evas_Object *parent) override; + + private: + std::string m_Text; + }; + + inline BubbleTextEntity::BubbleTextEntity(Message::Direction direction, std::string text) + : BubbleEntity(TextItem, direction) + , m_Text(std::move(text)) + { + } + + inline BubbleTextEntity::~BubbleTextEntity() + { + } + + inline BubbleTextViewItem *BubbleTextEntity::createView(Evas_Object *parent) + { + auto *item = new BubbleTextViewItem(*this, parent, m_Text); + return item; + } } #endif /* BubbleTextEntity_h_ */ diff --git a/src/Conversation/Controller/inc/BubbleUnknownFileEntity.h b/src/Conversation/Controller/inc/BubbleUnknownFileEntity.h index 0d75e33..f454f4b 100644 --- a/src/Conversation/Controller/inc/BubbleUnknownFileEntity.h +++ b/src/Conversation/Controller/inc/BubbleUnknownFileEntity.h @@ -21,34 +21,34 @@ #include "BubbleIconTextLayoutItem.h" namespace Msg { - class BubbleUnknownFileEntity - : public BubbleEntity { - public: - BubbleUnknownFileEntity(const std::string &filePath, const std::string fileName, Message::Direction direction); - virtual ~BubbleUnknownFileEntity(); - - BubbleIconTextLayoutItem *createView(Evas_Object *parent) override; - - private: - std::string m_FileName; - }; - inline BubbleUnknownFileEntity::BubbleUnknownFileEntity(const std::string &filePath, const std::string fileName, Message::Direction direction) - : BubbleEntity(UnknownFileItem, direction, filePath) - , m_FileName(std::move(fileName)) - { - } - - inline BubbleUnknownFileEntity::~BubbleUnknownFileEntity() - { - } - - inline BubbleIconTextLayoutItem *BubbleUnknownFileEntity::createView(Evas_Object *parent) - { - auto *item = new BubbleIconTextLayoutItem(parent, *this); - item->setIcon(item->createIcon(ATTACH_UNKNOWN_ICON)); - item->setMainText(m_FileName); - return item; - } + class BubbleUnknownFileEntity + : public BubbleEntity { + public: + BubbleUnknownFileEntity(const std::string &filePath, const std::string fileName, Message::Direction direction); + virtual ~BubbleUnknownFileEntity(); + + BubbleIconTextLayoutItem *createView(Evas_Object *parent) override; + + private: + std::string m_FileName; + }; + inline BubbleUnknownFileEntity::BubbleUnknownFileEntity(const std::string &filePath, const std::string fileName, Message::Direction direction) + : BubbleEntity(UnknownFileItem, direction, filePath) + , m_FileName(std::move(fileName)) + { + } + + inline BubbleUnknownFileEntity::~BubbleUnknownFileEntity() + { + } + + inline BubbleIconTextLayoutItem *BubbleUnknownFileEntity::createView(Evas_Object *parent) + { + auto *item = new BubbleIconTextLayoutItem(parent, *this); + item->setIcon(item->createIcon(ATTACH_UNKNOWN_ICON)); + item->setMainText(m_FileName); + return item; + } } #endif /* BubbleUnknownFileEntity_h_ */ diff --git a/src/Conversation/Controller/inc/BubbleVideoEntity.h b/src/Conversation/Controller/inc/BubbleVideoEntity.h index f7731ca..9d137a1 100644 --- a/src/Conversation/Controller/inc/BubbleVideoEntity.h +++ b/src/Conversation/Controller/inc/BubbleVideoEntity.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -22,18 +22,18 @@ #include "WorkingDir.h" namespace Msg { - class BubbleVideoEntity - : public BubbleEntity { - public: - BubbleVideoEntity(WorkingDirRef workingDir, const std::string &filePath, Message::Direction direction); - virtual ~BubbleVideoEntity(); + class BubbleVideoEntity + : public BubbleEntity { + public: + BubbleVideoEntity(WorkingDirRef workingDir, const std::string &filePath, Message::Direction direction); + virtual ~BubbleVideoEntity(); - BubbleVideoViewItem *createView(Evas_Object *parent) override; + BubbleVideoViewItem *createView(Evas_Object *parent) override; - private: - std::string m_ImgPath; - WorkingDirRef m_WorkingDir; - }; + private: + std::string m_ImgPath; + WorkingDirRef m_WorkingDir; + }; } #endif /* BubbleVideoEntity_h_ */ diff --git a/src/Conversation/Controller/inc/ConvFrame.h b/src/Conversation/Controller/inc/ConvFrame.h index c2ed939..3c27aa1 100644 --- a/src/Conversation/Controller/inc/ConvFrame.h +++ b/src/Conversation/Controller/inc/ConvFrame.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -26,107 +26,107 @@ namespace Msg { - class DefaultLayout; - class BottomButton; - class SelectButton; - class CtxPopupItem; - - class ConvFrame - : public FrameController - , private IConvListListener { - - public: - ConvFrame(NaviFrameController &parent); - virtual ~ConvFrame(); - - void setThreadId(ThreadId id); - void execCmd(const AppControlComposeRef &cmd); - void execCmd(const AppControlDefaultRef &cmd); - - private: - enum Mode { - InitMode, - NormalMode, - DeleteMode - }; - - private: - // NaviFrameItem: - void onAttached(ViewItem &item) override; - - // HW button: - void onHwBackButtonPreessed(Evas_Object *obj, void *event); - - // MoreOption: - void onReplyClicked(MoreOption &obj); - void onCallClicked(MoreOption &obj); - void onSendMyLocationClicked(MoreOption &obj); - void onRecipientsClicked(MoreOption &obj); - void onBlockNumberClicked(MoreOption &obj); - void onUnblockNumberClicked(MoreOption &obj); - void onDeleteClicked(MoreOption &obj); - - // Popup: - void showNumberBlockUnblockPopup(bool isBlocked); - - // Delete mode cb: - void onDelButtonClicked(Evas_Object *obj, void *event); - void onSelectButtonClicked(Evas_Object *obj, void *event); - void onSelectAllButtonClicked(CtxPopupItem &item); - void onDeselectAllButtonClicked(CtxPopupItem &item); - - // IConvListListener: - void onItemChecked(ConvListItem &item) override; - void onItemRequestDeleteMode(ConvListItem &listItem) override; - void onListChanged(ConvList &list) override; - void onReplyButtonClicked(ConvList &list) override; - - private: - enum MorOptionItemType{ - MorOptionReply, - MorOptionCall, - MorOptionRecip, - MorOptionBlock, - MorOptionUnblock, - MorOptionDelete, - MorOptionMax - }; - - struct MoreOptionItemInfo { - Eext_Object_Item *item; - const char *strId; - const char *icon; - MoreOptionCb cb; - }; - - void prepareWorkingDir(); - void prepareLayout(); - void prepareMoreOption(); - void prepareDeleteViews(); - void prepareList(); - void showSelectPopup(); - void updateDeleteViews(); - void reply(); - void updateMoreOption(); - void prepedItem(MorOptionItemType itemType); - void removeItem(MorOptionItemType itemType); - void navigateToReicpList(); - - void setMode(Mode mode); - void setDeleteMode(bool value); - void setNormalMode(bool value); - - private: - Mode m_Mode; - ThreadId m_ThreadId; - DefaultLayout *m_pLayout; - ConvList *m_pList; - MoreOption *m_pMoreOption; - BottomButton *m_pDeleteButton; - SelectButton *m_pSelectButton; - WorkingDirRef m_WorkingDir; - MoreOptionItemInfo m_MoreOptionItemsInfo[MorOptionMax]; - }; + class DefaultLayout; + class BottomButton; + class SelectButton; + class CtxPopupItem; + + class ConvFrame + : public FrameController + , private IConvListListener { + + public: + ConvFrame(NaviFrameController &parent); + virtual ~ConvFrame(); + + void setThreadId(ThreadId id); + void execCmd(const AppControlComposeRef &cmd); + void execCmd(const AppControlDefaultRef &cmd); + + private: + enum Mode { + InitMode, + NormalMode, + DeleteMode + }; + + private: + // NaviFrameItem: + void onAttached(ViewItem &item) override; + + // HW button: + void onHwBackButtonPreessed(Evas_Object *obj, void *event); + + // MoreOption: + void onReplyClicked(MoreOption &obj); + void onCallClicked(MoreOption &obj); + void onSendMyLocationClicked(MoreOption &obj); + void onRecipientsClicked(MoreOption &obj); + void onBlockNumberClicked(MoreOption &obj); + void onUnblockNumberClicked(MoreOption &obj); + void onDeleteClicked(MoreOption &obj); + + // Popup: + void showNumberBlockUnblockPopup(bool isBlocked); + + // Delete mode cb: + void onDelButtonClicked(Evas_Object *obj, void *event); + void onSelectButtonClicked(Evas_Object *obj, void *event); + void onSelectAllButtonClicked(CtxPopupItem &item); + void onDeselectAllButtonClicked(CtxPopupItem &item); + + // IConvListListener: + void onItemChecked(ConvListItem &item) override; + void onItemRequestDeleteMode(ConvListItem &listItem) override; + void onListChanged(ConvList &list) override; + void onReplyButtonClicked(ConvList &list) override; + + private: + enum MorOptionItemType{ + MorOptionReply, + MorOptionCall, + MorOptionRecip, + MorOptionBlock, + MorOptionUnblock, + MorOptionDelete, + MorOptionMax + }; + + struct MoreOptionItemInfo { + Eext_Object_Item *item; + const char *strId; + const char *icon; + MoreOptionCb cb; + }; + + void prepareWorkingDir(); + void prepareLayout(); + void prepareMoreOption(); + void prepareDeleteViews(); + void prepareList(); + void showSelectPopup(); + void updateDeleteViews(); + void reply(); + void updateMoreOption(); + void prepedItem(MorOptionItemType itemType); + void removeItem(MorOptionItemType itemType); + void navigateToReicpList(); + + void setMode(Mode mode); + void setDeleteMode(bool value); + void setNormalMode(bool value); + + private: + Mode m_Mode; + ThreadId m_ThreadId; + DefaultLayout *m_pLayout; + ConvList *m_pList; + MoreOption *m_pMoreOption; + BottomButton *m_pDeleteButton; + SelectButton *m_pSelectButton; + WorkingDirRef m_WorkingDir; + MoreOptionItemInfo m_MoreOptionItemsInfo[MorOptionMax]; + }; } #endif /* ConvFrame_h_ */ diff --git a/src/Conversation/Controller/inc/ConvList.h b/src/Conversation/Controller/inc/ConvList.h index 5822475..8e5193a 100644 --- a/src/Conversation/Controller/inc/ConvList.h +++ b/src/Conversation/Controller/inc/ConvList.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -33,93 +33,93 @@ namespace Msg { - class PaddingListViewItem; - class ConvReplyListItem; - class IConvListListener; - class TitleListItem; - class DefaultLayout; - - class ConvList - : public ListView - , private IListViewListener - , private IMsgStorageListener - , private IContactManagerListener - , private ISystemSettingsManager { - - public: - ConvList(DefaultLayout *parent, WorkingDirRef &workingDir); - virtual ~ConvList(); - - void setThreadId(ThreadId id); - void setListener(IConvListListener *l); - void setDeleteMode(bool value); - bool isDeleteModeEnabled() const; - bool deleteCheckedItems(); - void navigateToBottom(); - bool isEmpty() const; - const Recipient &getRecip() const; - - private: - typedef std::unordered_map ConvListItemMap; - typedef std::unordered_set DateLineItemSet; - - // IMsgStorageListener: - void onMsgStorageUpdate(const MsgIdList &msgIdList) override; - void onMsgStorageInsert(const MsgIdList &msgIdList) override; - void onMsgStorageDelete(const MsgIdList &msgIdList) override; - - // IListViewListener: - void onListItemSelected(ListItem &listItem) override; - void onListItemChecked(ListItem &listItem) override; - void onListItemLongPressed(ListItem &listItem) override; - - // IContactManagerListener: - void onContactChanged() override; - - // ISystemSettingsManager: - void onTimeFormatChanged() override; - void onLanguageChanged() override; - - void fillList(); - void updateTitle(); - void updateLangInfo(); - void updateDateLineItems(bool updateUi); - MsgStorage &getMsgStorage(); - void delDateLineIfNeeded(ConvListItem &item); - void addDateLineIfNeeded(ConvListItem &item); - ConvListItem *getItem(MsgId msgId) const; - void deleteItem(ConvListItem &item); - bool deleteItems(const MsgIdList &idList); - void insertItem(ConvListItem &item); - ConvListItem *insertItem(const MsgConversationItem &item); - void demoteItem(ConvListItem &item); // move down existing item - void clear(); - void markAsRead(); - void resendMsg(ConvListItem &listItem); - - private: - bool m_IsDeleteMode; - ThreadId m_ThreadId; - Recipient m_Recip; - IConvListListener *m_pListener; - PaddingListViewItem *m_pBottomPadItem; - ConvReplyListItem *m_pReplyItem; - ListItem *m_pItemAfterConv; // Reply or Bottom padding. - TitleListItem *m_pTitleItem; - WorkingDirRef m_WorkingDir; - BubbleEntityFactory m_BubbleEntityFactory; - ConvListItemMap m_ConvListItemMap; - DateLineItemSet m_DateLineItemSet; - }; - - class IConvListListener { - public: - virtual ~IConvListListener() {} - virtual void onItemChecked(ConvListItem &item) {}; - virtual void onItemRequestDeleteMode(ConvListItem &listItem) {}; - virtual void onListChanged(ConvList &list) {}; - virtual void onReplyButtonClicked(ConvList &list) {}; - }; + class PaddingListViewItem; + class ConvReplyListItem; + class IConvListListener; + class TitleListItem; + class DefaultLayout; + + class ConvList + : public ListView + , private IListViewListener + , private IMsgStorageListener + , private IContactManagerListener + , private ISystemSettingsManager { + + public: + ConvList(DefaultLayout *parent, WorkingDirRef &workingDir); + virtual ~ConvList(); + + void setThreadId(ThreadId id); + void setListener(IConvListListener *l); + void setDeleteMode(bool value); + bool isDeleteModeEnabled() const; + bool deleteCheckedItems(); + void navigateToBottom(); + bool isEmpty() const; + const Recipient &getRecip() const; + + private: + typedef std::unordered_map ConvListItemMap; + typedef std::unordered_set DateLineItemSet; + + // IMsgStorageListener: + void onMsgStorageUpdate(const MsgIdList &msgIdList) override; + void onMsgStorageInsert(const MsgIdList &msgIdList) override; + void onMsgStorageDelete(const MsgIdList &msgIdList) override; + + // IListViewListener: + void onListItemSelected(ListItem &listItem) override; + void onListItemChecked(ListItem &listItem) override; + void onListItemLongPressed(ListItem &listItem) override; + + // IContactManagerListener: + void onContactChanged() override; + + // ISystemSettingsManager: + void onTimeFormatChanged() override; + void onLanguageChanged() override; + + void fillList(); + void updateTitle(); + void updateLangInfo(); + void updateDateLineItems(bool updateUi); + MsgStorage &getMsgStorage(); + void delDateLineIfNeeded(ConvListItem &item); + void addDateLineIfNeeded(ConvListItem &item); + ConvListItem *getItem(MsgId msgId) const; + void deleteItem(ConvListItem &item); + bool deleteItems(const MsgIdList &idList); + void insertItem(ConvListItem &item); + ConvListItem *insertItem(const MsgConversationItem &item); + void demoteItem(ConvListItem &item); // move down existing item + void clear(); + void markAsRead(); + void resendMsg(ConvListItem &listItem); + + private: + bool m_IsDeleteMode; + ThreadId m_ThreadId; + Recipient m_Recip; + IConvListListener *m_pListener; + PaddingListViewItem *m_pBottomPadItem; + ConvReplyListItem *m_pReplyItem; + ListItem *m_pItemAfterConv; // Reply or Bottom padding. + TitleListItem *m_pTitleItem; + WorkingDirRef m_WorkingDir; + BubbleEntityFactory m_BubbleEntityFactory; + ConvListItemMap m_ConvListItemMap; + DateLineItemSet m_DateLineItemSet; + }; + + class IConvListListener { + public: + virtual ~IConvListListener() {} + virtual void onItemChecked(ConvListItem &item) {}; + virtual void onItemRequestDeleteMode(ConvListItem &listItem) {}; + virtual void onListChanged(ConvList &list) {}; + virtual void onReplyButtonClicked(ConvList &list) {}; + }; } #endif /* ConvList_h_ */ diff --git a/src/Conversation/Controller/inc/ConvListItem.h b/src/Conversation/Controller/inc/ConvListItem.h index b0f970d..3c6e0ef 100644 --- a/src/Conversation/Controller/inc/ConvListItem.h +++ b/src/Conversation/Controller/inc/ConvListItem.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -30,61 +30,61 @@ namespace Msg { - class MsgConversationItem; - class BubbleEntityFactory; + class MsgConversationItem; + class BubbleEntityFactory; - class ConvListItem - : public ConvListViewItem - , private IBubbleViewItemListener { + class ConvListItem + : public ConvListViewItem + , private IBubbleViewItemListener { - public: - ConvListItem(const MsgConversationItem &item, - WorkingDirRef &workingDir, - BubbleEntityFactory &bubbleEntityFactory); - virtual ~ConvListItem(); + public: + ConvListItem(const MsgConversationItem &item, + WorkingDirRef &workingDir, + BubbleEntityFactory &bubbleEntityFactory); + virtual ~ConvListItem(); - MsgId getMsgId() const; - time_t getRawTime() const; - void updateStatus(); - void updateLangInfo(); - void updateTime(); - void setActionEventFlag(bool isAction = true); - bool getActionEventFlag() const; + MsgId getMsgId() const; + time_t getRawTime() const; + void updateStatus(); + void updateLangInfo(); + void updateTime(); + void setActionEventFlag(bool isAction = true); + bool getActionEventFlag() const; - protected: - Evas_Object *getBubbleContent() override; - std::string getTime() override; - std::string getMsgType() override; + protected: + Evas_Object *getBubbleContent() override; + std::string getTime() override; + std::string getMsgType() override; - private: - void updateViewStatus(); - void prepareContent(const MsgConversationItem &item); + private: + void updateViewStatus(); + void prepareContent(const MsgConversationItem &item); - // Popups: - void showMobileDataOffPopup(); - void showFailedToRetrievePopup(); - void showRetrieveMmsPopup(); + // Popups: + void showMobileDataOffPopup(); + void showFailedToRetrievePopup(); + void showRetrieveMmsPopup(); - // Popup callback: - void onCancelButtonClicked(Popup &popup); - void onRetrieveButtonClicked(Popup &popup); + // Popup callback: + void onCancelButtonClicked(Popup &popup); + void onRetrieveButtonClicked(Popup &popup); - // IBubbleViewItemListener: - void onAction(BubbleViewItem &item) override; + // IBubbleViewItemListener: + void onAction(BubbleViewItem &item) override; - private: - MsgId m_MsgId; - time_t m_Time; - Message::Direction m_Direction; - Message::NetworkStatus m_NetworkStatus; - Message::Type m_Type; - std::string m_TimeStr; - std::list m_BubbleEntityList; - WorkingDirRef m_WorkingDir; - BubbleEntityFactory &m_BubbleEntityFactory; - FileViewer m_FileViewer; - bool m_ActionEventFlag; - }; + private: + MsgId m_MsgId; + time_t m_Time; + Message::Direction m_Direction; + Message::NetworkStatus m_NetworkStatus; + Message::Type m_Type; + std::string m_TimeStr; + std::list m_BubbleEntityList; + WorkingDirRef m_WorkingDir; + BubbleEntityFactory &m_BubbleEntityFactory; + FileViewer m_FileViewer; + bool m_ActionEventFlag; + }; } #endif /* ConvListItem_h_ */ diff --git a/src/Conversation/Controller/inc/RecipListFrame.h b/src/Conversation/Controller/inc/RecipListFrame.h index b54d04e..36e5405 100644 --- a/src/Conversation/Controller/inc/RecipListFrame.h +++ b/src/Conversation/Controller/inc/RecipListFrame.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -27,37 +27,37 @@ namespace Msg { - class PaddingListViewItem; - class RecipListFrame - : public FrameController - , private IListViewListener - , private IContactManagerListener { + class PaddingListViewItem; + class RecipListFrame + : public FrameController + , private IListViewListener + , private IContactManagerListener { - public: - RecipListFrame(NaviFrameController &parent); - virtual ~RecipListFrame(); + public: + RecipListFrame(NaviFrameController &parent); + virtual ~RecipListFrame(); - void setRecips(std::list recips); + void setRecips(std::list recips); - private: - // NaviFrameItem: - void onAttached(ViewItem &item) override; + private: + // NaviFrameItem: + void onAttached(ViewItem &item) override; - // IListViewListener: - void onListItemSelected(ListItem &listItem) override; + // IListViewListener: + void onListItemSelected(ListItem &listItem) override; - // IContactManagerListener: - void onContactChanged() override; + // IContactManagerListener: + void onContactChanged() override; - void prepeareList(); - void fillList(); + void prepeareList(); + void fillList(); - private: - std::list m_Recips; - ListView *m_pList; - PaddingListViewItem *m_pBottomPadItem; - ContactViewer m_ContactViewer; - }; + private: + std::list m_Recips; + ListView *m_pList; + PaddingListViewItem *m_pBottomPadItem; + ContactViewer m_ContactViewer; + }; } #endif /* RecipListFrame_h_ */ diff --git a/src/Conversation/Controller/inc/RecipListItem.h b/src/Conversation/Controller/inc/RecipListItem.h index f1d629b..dc850c7 100644 --- a/src/Conversation/Controller/inc/RecipListItem.h +++ b/src/Conversation/Controller/inc/RecipListItem.h @@ -21,52 +21,52 @@ #include "Recipient.h" namespace Msg { - class RecipListItem - : public RecipListViewItem { + class RecipListItem + : public RecipListViewItem { - public: - RecipListItem(); - virtual ~RecipListItem(); + public: + RecipListItem(); + virtual ~RecipListItem(); - void setRecipient(Recipient recip); - const Recipient &getRecipient() const; - void updateContactInfo(); + void setRecipient(Recipient recip); + const Recipient &getRecipient() const; + void updateContactInfo(); - private: - std::string getRecipText() override; + private: + std::string getRecipText() override; - private: - Recipient m_Recip; - }; + private: + Recipient m_Recip; + }; - inline RecipListItem::RecipListItem() - : RecipListViewItem() - { - } + inline RecipListItem::RecipListItem() + : RecipListViewItem() + { + } - inline RecipListItem::~RecipListItem() - { - } + inline RecipListItem::~RecipListItem() + { + } - inline void RecipListItem::setRecipient(Recipient recip) - { - m_Recip = std::move(recip); - } + inline void RecipListItem::setRecipient(Recipient recip) + { + m_Recip = std::move(recip); + } - const Recipient &RecipListItem::getRecipient() const - { - return m_Recip; - } + const Recipient &RecipListItem::getRecipient() const + { + return m_Recip; + } - inline void RecipListItem::updateContactInfo() - { - m_Recip.updateContactInfo(); - } + inline void RecipListItem::updateContactInfo() + { + m_Recip.updateContactInfo(); + } - inline std::string RecipListItem::getRecipText() - { - return m_Recip.getDispName(); - } + inline std::string RecipListItem::getRecipText() + { + return m_Recip.getDispName(); + } } #endif /* RecipListItem_H_ */ diff --git a/src/Conversation/Controller/src/BubbleAudioEntity.cpp b/src/Conversation/Controller/src/BubbleAudioEntity.cpp index fa6609c..558e29d 100644 --- a/src/Conversation/Controller/src/BubbleAudioEntity.cpp +++ b/src/Conversation/Controller/src/BubbleAudioEntity.cpp @@ -25,162 +25,162 @@ using namespace Msg; namespace { - std::string makeDurationStr(int msec) - { - std::stringstream ss; - int sec = ceil(msec / 1000.0); - int h = sec / 60; - int m = sec % 60; - ss << std::setfill('0') << std::setw(2) << h << ':' - << std::setfill('0') << std::setw(2) << m; - return ss.str(); - } + std::string makeDurationStr(int msec) + { + std::stringstream ss; + int sec = ceil(msec / 1000.0); + int h = sec / 60; + int m = sec % 60; + ss << std::setfill('0') << std::setw(2) << h << ':' + << std::setfill('0') << std::setw(2) << m; + return ss.str(); + } } BubbleAudioEntity::BubbleAudioEntity(MediaPlayerProviderRef mediaPlayerProvider, - std::string filePath, - std::string fileName, - Message::Direction direction) - : BubbleEntity(AudioItem, direction, filePath) - , m_MediaPlayerProvider(mediaPlayerProvider) - , m_pView(nullptr) - , m_pTimer(nullptr) - , m_pPlayer(nullptr) - , m_PlayInfo {} - , m_FileName(std::move(fileName)) - , m_DurationStr() -{ - m_PlayInfo.uri = std::move(filePath); - m_PlayInfo.duration = MediaUtils::getDuration(m_PlayInfo.uri); - m_PlayInfo.isPlaying = false; - m_PlayInfo.playPos = 0; - - m_DurationStr = makeDurationStr(m_PlayInfo.duration); + std::string filePath, + std::string fileName, + Message::Direction direction) + : BubbleEntity(AudioItem, direction, filePath) + , m_MediaPlayerProvider(mediaPlayerProvider) + , m_pView(nullptr) + , m_pTimer(nullptr) + , m_pPlayer(nullptr) + , m_PlayInfo {} + , m_FileName(std::move(fileName)) + , m_DurationStr() +{ + m_PlayInfo.uri = std::move(filePath); + m_PlayInfo.duration = MediaUtils::getDuration(m_PlayInfo.uri); + m_PlayInfo.isPlaying = false; + m_PlayInfo.playPos = 0; + + m_DurationStr = makeDurationStr(m_PlayInfo.duration); } BubbleAudioEntity::~BubbleAudioEntity() { - stop(); + stop(); } void BubbleAudioEntity::clickHandler() { - if (m_pPlayer && m_pPlayer->isPlaying()) - stop(); - else - play(); + if (m_pPlayer && m_pPlayer->isPlaying()) + stop(); + else + play(); } void BubbleAudioEntity::play() { - m_pPlayer = &m_MediaPlayerProvider->acquire(this); - m_pPlayer->setListener(this); - m_pPlayer->setUri(getFilePath()); + m_pPlayer = &m_MediaPlayerProvider->acquire(this); + m_pPlayer->setListener(this); + m_pPlayer->setUri(getFilePath()); - if (m_pPlayer->start()) { - m_PlayInfo.isPlaying = true; - // Warning setPosition() works only after start(); - if (m_PlayInfo.playPos > 0) - m_pPlayer->setPosition(m_PlayInfo.playPos); - startTimer(); - updateProgress(); - updatePlayState(); - } + if (m_pPlayer->start()) { + m_PlayInfo.isPlaying = true; + // Warning setPosition() works only after start(); + if (m_PlayInfo.playPos > 0) + m_pPlayer->setPosition(m_PlayInfo.playPos); + startTimer(); + updateProgress(); + updatePlayState(); + } } void BubbleAudioEntity::stop() { - m_MediaPlayerProvider->release(this); + m_MediaPlayerProvider->release(this); } void BubbleAudioEntity::stopHandler() { - m_PlayInfo.isPlaying = false; - m_PlayInfo.playPos = m_pPlayer ? m_pPlayer->getPosition() : 0; - stopTimer(); - updatePlayState(); - updateProgress(); + m_PlayInfo.isPlaying = false; + m_PlayInfo.playPos = m_pPlayer ? m_pPlayer->getPosition() : 0; + stopTimer(); + updatePlayState(); + updateProgress(); } BubbleAudioViewItem *BubbleAudioEntity::createView(Evas_Object *parent) { - m_pView = new BubbleAudioViewItem(parent, *this); - m_pView->addEventCb(EVAS_CALLBACK_DEL, makeCbFirst(&BubbleAudioEntity::onViewDel), this); - m_pView->setMainText(m_FileName); - m_pView->setTimeText(m_DurationStr); + m_pView = new BubbleAudioViewItem(parent, *this); + m_pView->addEventCb(EVAS_CALLBACK_DEL, makeCbFirst(&BubbleAudioEntity::onViewDel), this); + m_pView->setMainText(m_FileName); + m_pView->setTimeText(m_DurationStr); - updateProgress(); - updatePlayState(); - return m_pView; + updateProgress(); + updatePlayState(); + return m_pView; } void BubbleAudioEntity::startTimer() { - static const double timeInterval = ecore_animator_frametime_get(); - if (!m_pTimer) - m_pTimer = ecore_timer_add(timeInterval, makeCbFirst(&BubbleAudioEntity::onTick), this); + static const double timeInterval = ecore_animator_frametime_get(); + if (!m_pTimer) + m_pTimer = ecore_timer_add(timeInterval, makeCbFirst(&BubbleAudioEntity::onTick), this); } void BubbleAudioEntity::stopTimer() { - if (m_pTimer) { - ecore_timer_del(m_pTimer); - m_pTimer = nullptr; - } + if (m_pTimer) { + ecore_timer_del(m_pTimer); + m_pTimer = nullptr; + } } void BubbleAudioEntity::updateProgress() { - if (m_pView) { - double pos = m_PlayInfo.playPos; - double dur = m_PlayInfo.duration; - double relPos = dur > 0.0 ? pos / dur : 0.0; - m_pView->setProgress(relPos); - } + if (m_pView) { + double pos = m_PlayInfo.playPos; + double dur = m_PlayInfo.duration; + double relPos = dur > 0.0 ? pos / dur : 0.0; + m_pView->setProgress(relPos); + } } void BubbleAudioEntity::updatePlayState() { - if (m_pView) { - auto state = m_PlayInfo.isPlaying ? BubbleAudioViewItem::PauseState : - BubbleAudioViewItem::PlayState; - m_pView->setState(state); - } + if (m_pView) { + auto state = m_PlayInfo.isPlaying ? BubbleAudioViewItem::PauseState : + BubbleAudioViewItem::PlayState; + m_pView->setState(state); + } } Eina_Bool BubbleAudioEntity::onTick() { - m_PlayInfo.playPos = m_pPlayer ? m_pPlayer->getPosition() : 0; - updateProgress(); - return true; + m_PlayInfo.playPos = m_pPlayer ? m_pPlayer->getPosition() : 0; + updateProgress(); + return true; } void BubbleAudioEntity::onViewDel(Evas *e, Evas_Object *obj, void *event_info) { - if (m_pView && obj == *m_pView) - m_pView = nullptr; + if (m_pView && obj == *m_pView) + m_pView = nullptr; } void BubbleAudioEntity::onAcquire(MediaPlayerProvider &provider) { - MSG_LOG(this); + MSG_LOG(this); } void BubbleAudioEntity::onRelease(MediaPlayerProvider &provider) { - MSG_LOG(this); - stopHandler(); - m_pPlayer = nullptr; + MSG_LOG(this); + stopHandler(); + m_pPlayer = nullptr; } void BubbleAudioEntity::onCompleted(MediaPlayer &player) { - MSG_LOG(this); - stopHandler(); + MSG_LOG(this); + stopHandler(); } void BubbleAudioEntity::onSoundFocusChanged(MediaPlayer &player) { - MSG_LOG(this); - stopHandler(); + MSG_LOG(this); + stopHandler(); } diff --git a/src/Conversation/Controller/src/BubbleCalEventEntity.cpp b/src/Conversation/Controller/src/BubbleCalEventEntity.cpp index 7593488..f801219 100644 --- a/src/Conversation/Controller/src/BubbleCalEventEntity.cpp +++ b/src/Conversation/Controller/src/BubbleCalEventEntity.cpp @@ -21,17 +21,17 @@ using namespace Msg; BubbleCalEventEntity::BubbleCalEventEntity(const std::string &filePath, const std::string fileName, Message::Direction direction) - : BubbleEntity(CalendarEventItem, direction, filePath) - , m_Name(std::move(fileName)) + : BubbleEntity(CalendarEventItem, direction, filePath) + , m_Name(std::move(fileName)) { - auto list = VCalendarParser::getInst().parse(filePath); - if (list.size() == 1) { - const CalendarEvent &event = list.front(); - m_Name = event.getSummary(); - m_DateTime = event.getStartDate(); - } else { - m_Name = fileName; - } + auto list = VCalendarParser::getInst().parse(filePath); + if (list.size() == 1) { + const CalendarEvent &event = list.front(); + m_Name = event.getSummary(); + m_DateTime = event.getStartDate(); + } else { + m_Name = fileName; + } } BubbleCalEventEntity::~BubbleCalEventEntity() @@ -40,8 +40,8 @@ BubbleCalEventEntity::~BubbleCalEventEntity() BubbleIconTextLayoutItem *BubbleCalEventEntity::createView(Evas_Object *parent) { - auto *item = new BubbleIconTextLayoutItem(parent, *this); - item->setIcon(item->createIcon(ATTACH_CALENDAR_ICON)); - item->setMainText(m_Name); - return item; + auto *item = new BubbleIconTextLayoutItem(parent, *this); + item->setIcon(item->createIcon(ATTACH_CALENDAR_ICON)); + item->setMainText(m_Name); + return item; } diff --git a/src/Conversation/Controller/src/BubbleContactEntity.cpp b/src/Conversation/Controller/src/BubbleContactEntity.cpp index 2a0a58d..56d2b01 100644 --- a/src/Conversation/Controller/src/BubbleContactEntity.cpp +++ b/src/Conversation/Controller/src/BubbleContactEntity.cpp @@ -21,8 +21,8 @@ using namespace Msg; BubbleContactEntity::BubbleContactEntity(const std::string &filePath, std::string fileName, Message::Direction direction) - : BubbleEntity(ContactItem, direction, filePath) - , m_Name(std::move(fileName)) + : BubbleEntity(ContactItem, direction, filePath) + , m_Name(std::move(fileName)) { } @@ -32,8 +32,8 @@ BubbleContactEntity::~BubbleContactEntity() BubbleIconTextLayoutItem *BubbleContactEntity::createView(Evas_Object *parent) { - auto *item = new BubbleIconTextLayoutItem(parent, *this); - item->setMainText(m_Name); - item->setIcon(item->createIcon(ATTACH_CONTACT_ICON)); - return item; + auto *item = new BubbleIconTextLayoutItem(parent, *this); + item->setMainText(m_Name); + item->setIcon(item->createIcon(ATTACH_CONTACT_ICON)); + return item; } diff --git a/src/Conversation/Controller/src/BubbleEntityFactory.cpp b/src/Conversation/Controller/src/BubbleEntityFactory.cpp index e0611c6..ba0dc57 100644 --- a/src/Conversation/Controller/src/BubbleEntityFactory.cpp +++ b/src/Conversation/Controller/src/BubbleEntityFactory.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -37,8 +37,8 @@ using namespace Msg; BubbleEntityFactory::BubbleEntityFactory(WorkingDirRef &workingDir) - : m_WorkingDir(workingDir) - , m_MediaPlayerProvider(std::make_shared()) + : m_WorkingDir(workingDir) + , m_MediaPlayerProvider(std::make_shared()) { } @@ -48,133 +48,133 @@ BubbleEntityFactory::~BubbleEntityFactory() std::list BubbleEntityFactory::create(const MsgConversationItem &item) { - std::list list; - - Message::Type type = item.getType(); - Message::Direction direct = item.getDirection(); - - if (MsgUtils::isSms(type)) { - // SMS: - auto *entity = createTextEntity(item.getText(), direct); - if (entity) - list.push_back(BubbleEntityRef(entity)); - } else if (type == Message::MT_MMS_Noti) { - // MMS_Noti: - auto *entity = createRetrieveEntity(direct); - if (entity) - list.push_back(BubbleEntityRef(entity)); - } else { - // MMS: - auto *subject = createSubjectEntity(item.getSubject(), direct); - if (subject) - list.push_back(BubbleEntityRef(subject)); - - const MsgConvMediaList &convList = item.getMediaList(); - int convListLen = convList.getLength(); - for (int i = 0; i < convListLen; ++i) { - auto *entity = createEntity(convList[i], direct); - if (entity) - list.push_back(BubbleEntityRef(entity)); - } - } - - // No Content: - if (list.empty()) { - auto *entity = createNoContentEntity(direct); - if (entity) - list.push_back(BubbleEntityRef(entity)); - } - - return list; + std::list list; + + Message::Type type = item.getType(); + Message::Direction direct = item.getDirection(); + + if (MsgUtils::isSms(type)) { + // SMS: + auto *entity = createTextEntity(item.getText(), direct); + if (entity) + list.push_back(BubbleEntityRef(entity)); + } else if (type == Message::MT_MMS_Noti) { + // MMS_Noti: + auto *entity = createRetrieveEntity(direct); + if (entity) + list.push_back(BubbleEntityRef(entity)); + } else { + // MMS: + auto *subject = createSubjectEntity(item.getSubject(), direct); + if (subject) + list.push_back(BubbleEntityRef(subject)); + + const MsgConvMediaList &convList = item.getMediaList(); + int convListLen = convList.getLength(); + for (int i = 0; i < convListLen; ++i) { + auto *entity = createEntity(convList[i], direct); + if (entity) + list.push_back(BubbleEntityRef(entity)); + } + } + + // No Content: + if (list.empty()) { + auto *entity = createNoContentEntity(direct); + if (entity) + list.push_back(BubbleEntityRef(entity)); + } + + return list; } BubbleEntity *BubbleEntityFactory::createEntity(const MsgConvMedia &msgMedia, Message::Direction direction) { - std::string filePath = msgMedia.getPath(); - - if (FileUtils::isExists(filePath)) { - - std::string mime = msgMedia.getMime(); - std::string fileName = msgMedia.getName(); - - if (mime.empty()) - mime = FileUtils::getMimeType(filePath); - - if (fileName.empty()) - fileName = FileUtils::getFileName(filePath); - - std::transform(mime.begin(), mime.end(), mime.begin(), ::tolower); - MsgMedia::Type msgMediaType = getMsgMediaTypeByMime(mime); - - switch (msgMediaType) { - case MsgMedia::TextType: - return createTextEntityFromFile(std::move(filePath), direction); - case MsgMedia::ImageType: - return new BubbleImageEntity(std::move(filePath), direction); - case MsgMedia::AudioType: - return createAudioEntity(std::move(filePath), std::move(fileName), direction); - case MsgMedia::VideoType: - return createVideoEntity(std::move(filePath), std::move(fileName), direction); - default: - if (mime == "text/x-vcalendar" || mime == "text/calendar") - return new BubbleCalEventEntity(std::move(filePath), std::move(fileName), direction); - else if (mime == "text/x-vcard" || - mime == "text/vcard" || - mime == "text/x-vcalendar") - return new BubbleContactEntity(std::move(filePath), std::move(fileName), direction); - else if (mime != "application/smil") - return new BubbleUnknownFileEntity(std::move(filePath), std::move(fileName), direction); - } - } - - return nullptr; + std::string filePath = msgMedia.getPath(); + + if (FileUtils::isExists(filePath)) { + + std::string mime = msgMedia.getMime(); + std::string fileName = msgMedia.getName(); + + if (mime.empty()) + mime = FileUtils::getMimeType(filePath); + + if (fileName.empty()) + fileName = FileUtils::getFileName(filePath); + + std::transform(mime.begin(), mime.end(), mime.begin(), ::tolower); + MsgMedia::Type msgMediaType = getMsgMediaTypeByMime(mime); + + switch (msgMediaType) { + case MsgMedia::TextType: + return createTextEntityFromFile(std::move(filePath), direction); + case MsgMedia::ImageType: + return new BubbleImageEntity(std::move(filePath), direction); + case MsgMedia::AudioType: + return createAudioEntity(std::move(filePath), std::move(fileName), direction); + case MsgMedia::VideoType: + return createVideoEntity(std::move(filePath), std::move(fileName), direction); + default: + if (mime == "text/x-vcalendar" || mime == "text/calendar") + return new BubbleCalEventEntity(std::move(filePath), std::move(fileName), direction); + else if (mime == "text/x-vcard" || + mime == "text/vcard" || + mime == "text/x-vcalendar") + return new BubbleContactEntity(std::move(filePath), std::move(fileName), direction); + else if (mime != "application/smil") + return new BubbleUnknownFileEntity(std::move(filePath), std::move(fileName), direction); + } + } + + return nullptr; } BubbleTextEntity *BubbleEntityFactory::createTextEntity(std::string text, Message::Direction direction) { - return text.empty() ? nullptr : new BubbleTextEntity(direction, std::move(text)); + return text.empty() ? nullptr : new BubbleTextEntity(direction, std::move(text)); } BubbleRetrieveEntity *BubbleEntityFactory::createRetrieveEntity(Message::Direction direction) { - return new BubbleRetrieveEntity(direction); + return new BubbleRetrieveEntity(direction); } BubbleNoContentEntity *BubbleEntityFactory::createNoContentEntity(Message::Direction direction) { - return new BubbleNoContentEntity(direction); + return new BubbleNoContentEntity(direction); } BubbleEntity *BubbleEntityFactory::createAudioEntity(std::string filePath, std::string fileName, Message::Direction direction) { - if (MediaUtils::hasAudio(filePath)) - return new BubbleAudioEntity(m_MediaPlayerProvider, std::move(filePath), std::move(fileName), direction); + if (MediaUtils::hasAudio(filePath)) + return new BubbleAudioEntity(m_MediaPlayerProvider, std::move(filePath), std::move(fileName), direction); - // File does not contain audio or broken: - return new BubbleUnknownFileEntity(std::move(filePath), std::move(fileName), direction); + // File does not contain audio or broken: + return new BubbleUnknownFileEntity(std::move(filePath), std::move(fileName), direction); } BubbleEntity *BubbleEntityFactory::createVideoEntity(std::string filePath, std::string fileName, Message::Direction direction) { - if (MediaUtils::hasVideo(filePath)) - return new BubbleVideoEntity(m_WorkingDir, std::move(filePath), direction); + if (MediaUtils::hasVideo(filePath)) + return new BubbleVideoEntity(m_WorkingDir, std::move(filePath), direction); - // Try to create Audio entity. - return createAudioEntity(std::move(filePath), std::move(fileName), direction); + // Try to create Audio entity. + return createAudioEntity(std::move(filePath), std::move(fileName), direction); } BubbleEntity *BubbleEntityFactory::createTextEntityFromFile(std::string filePath, Message::Direction direction) { - std::string text = FileUtils::readTextFile(filePath); - BubbleTextEntity *entity = createTextEntity(std::move(text), direction); - if (entity) - entity->setFilePath(std::move(filePath)); - return entity; + std::string text = FileUtils::readTextFile(filePath); + BubbleTextEntity *entity = createTextEntity(std::move(text), direction); + if (entity) + entity->setFilePath(std::move(filePath)); + return entity; } BubbleEntity *BubbleEntityFactory::createSubjectEntity(const std::string subject, Message::Direction direction) { - return subject.empty() ? nullptr : new BubbleSubjectEntity(std::move(subject), direction); + return subject.empty() ? nullptr : new BubbleSubjectEntity(std::move(subject), direction); } diff --git a/src/Conversation/Controller/src/BubbleSubjectEntity.cpp b/src/Conversation/Controller/src/BubbleSubjectEntity.cpp index 8a8e35b..4621c2b 100644 --- a/src/Conversation/Controller/src/BubbleSubjectEntity.cpp +++ b/src/Conversation/Controller/src/BubbleSubjectEntity.cpp @@ -20,8 +20,8 @@ using namespace Msg; BubbleSubjectEntity::BubbleSubjectEntity(const std::string subject, Message::Direction direction) - : BubbleEntity(SubjectItem, direction) - , m_Subject(std::move(subject)) + : BubbleEntity(SubjectItem, direction) + , m_Subject(std::move(subject)) { } @@ -31,7 +31,7 @@ BubbleSubjectEntity::~BubbleSubjectEntity() BubbleSubjectViewItem *BubbleSubjectEntity::createView(Evas_Object *parent) { - auto *item = new BubbleSubjectViewItem(*this, parent); - item->setText(m_Subject); - return item; + auto *item = new BubbleSubjectViewItem(*this, parent); + item->setText(m_Subject); + return item; } diff --git a/src/Conversation/Controller/src/BubbleVideoEntity.cpp b/src/Conversation/Controller/src/BubbleVideoEntity.cpp index 3c29006..81f9458 100644 --- a/src/Conversation/Controller/src/BubbleVideoEntity.cpp +++ b/src/Conversation/Controller/src/BubbleVideoEntity.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -21,23 +21,23 @@ using namespace Msg; BubbleVideoEntity::BubbleVideoEntity(WorkingDirRef workingDir, const std::string &filePath, Message::Direction direction) - : BubbleEntity(VideoItem, direction, filePath) - , m_WorkingDir(workingDir) + : BubbleEntity(VideoItem, direction, filePath) + , m_WorkingDir(workingDir) { - static const std::string thumbFileName = "thumbnail.jpeg"; - m_ImgPath = m_WorkingDir->genUniqueFilePath(thumbFileName); - if (!m_ImgPath.empty()) - MediaUtils::getVideoFrame(getFilePath(), m_ImgPath); + static const std::string thumbFileName = "thumbnail.jpeg"; + m_ImgPath = m_WorkingDir->genUniqueFilePath(thumbFileName); + if (!m_ImgPath.empty()) + MediaUtils::getVideoFrame(getFilePath(), m_ImgPath); } BubbleVideoEntity::~BubbleVideoEntity() { - m_WorkingDir->removeFile(m_ImgPath); + m_WorkingDir->removeFile(m_ImgPath); } BubbleVideoViewItem *BubbleVideoEntity::createView(Evas_Object *parent) { - auto *item = new BubbleVideoViewItem(*this, parent, m_ImgPath); - return item; + auto *item = new BubbleVideoViewItem(*this, parent, m_ImgPath); + return item; } diff --git a/src/Conversation/Controller/src/ConvFrame.cpp b/src/Conversation/Controller/src/ConvFrame.cpp index 0edb97f..bb78cab 100644 --- a/src/Conversation/Controller/src/ConvFrame.cpp +++ b/src/Conversation/Controller/src/ConvFrame.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -30,21 +30,21 @@ using namespace Msg; ConvFrame::ConvFrame(NaviFrameController &parent) - : FrameController(parent, ConvGroup) - , m_Mode(InitMode) - , m_ThreadId() - , m_pLayout(nullptr) - , m_pList(nullptr) - , m_pMoreOption(nullptr) - , m_pDeleteButton(nullptr) - , m_pSelectButton(nullptr) - , m_MoreOptionItemsInfo {} -{ - prepareWorkingDir(); - prepareLayout(); - prepareMoreOption(); - prepareList(); - setMode(NormalMode); + : FrameController(parent, ConvGroup) + , m_Mode(InitMode) + , m_ThreadId() + , m_pLayout(nullptr) + , m_pList(nullptr) + , m_pMoreOption(nullptr) + , m_pDeleteButton(nullptr) + , m_pSelectButton(nullptr) + , m_MoreOptionItemsInfo {} +{ + prepareWorkingDir(); + prepareLayout(); + prepareMoreOption(); + prepareList(); + setMode(NormalMode); } ConvFrame::~ConvFrame() @@ -53,328 +53,328 @@ ConvFrame::~ConvFrame() void ConvFrame::setMode(Mode mode) { - if (m_Mode == mode) - return; + if (m_Mode == mode) + return; - switch (mode) { - case NormalMode: - setNormalMode(true); - break; - case DeleteMode: - setDeleteMode(true); - break; - case InitMode: - default: - MSG_ASSERT(false, "Not supported mode"); - break; - } + switch (mode) { + case NormalMode: + setNormalMode(true); + break; + case DeleteMode: + setDeleteMode(true); + break; + case InitMode: + default: + MSG_ASSERT(false, "Not supported mode"); + break; + } } void ConvFrame::setNormalMode(bool value) { - MSG_LOG(""); - m_Mode = NormalMode; - m_pLayout->showMoreOption(true); - m_pLayout->showBottomButton(false); - if (m_pSelectButton) - m_pSelectButton->showButton(false); - m_pList->setDeleteMode(false); + MSG_LOG(""); + m_Mode = NormalMode; + m_pLayout->showMoreOption(true); + m_pLayout->showBottomButton(false); + if (m_pSelectButton) + m_pSelectButton->showButton(false); + m_pList->setDeleteMode(false); } void ConvFrame::setDeleteMode(bool value) { - MSG_LOG(""); - if (m_Mode != DeleteMode) { - prepareDeleteViews(); - m_Mode = DeleteMode; - m_pSelectButton->setText("0"); - m_pSelectButton->showButton(true); - m_pDeleteButton->disabled(true); - m_pLayout->showBottomButton(true); - m_pLayout->showMoreOption(false); - m_pList->setDeleteMode(true); - updateDeleteViews(); - } + MSG_LOG(""); + if (m_Mode != DeleteMode) { + prepareDeleteViews(); + m_Mode = DeleteMode; + m_pSelectButton->setText("0"); + m_pSelectButton->showButton(true); + m_pDeleteButton->disabled(true); + m_pLayout->showBottomButton(true); + m_pLayout->showMoreOption(false); + m_pList->setDeleteMode(true); + updateDeleteViews(); + } } void ConvFrame::execCmd(const AppControlComposeRef &cmd) { - // TODO: impl. + // TODO: impl. } void ConvFrame::execCmd(const AppControlDefaultRef &cmd) { - // TODO: impl. + // TODO: impl. } void ConvFrame::prepareWorkingDir() { - if (!m_WorkingDir) - m_WorkingDir = std::make_shared(); + if (!m_WorkingDir) + m_WorkingDir = std::make_shared(); } void ConvFrame::prepareLayout() { - if (!m_pLayout) { - m_pLayout = new DefaultLayout(getParent()); - m_pLayout->showSelectButton(true); - m_pLayout->addHwButtonEvent(EEXT_CALLBACK_BACK, makeCbFirst(&ConvFrame::onHwBackButtonPreessed), this); - } + if (!m_pLayout) { + m_pLayout = new DefaultLayout(getParent()); + m_pLayout->showSelectButton(true); + m_pLayout->addHwButtonEvent(EEXT_CALLBACK_BACK, makeCbFirst(&ConvFrame::onHwBackButtonPreessed), this); + } } void ConvFrame::prepareMoreOption() { - if (!m_pMoreOption) { - m_pMoreOption = new MoreOption(*m_pLayout); - m_pMoreOption->setDirection(EEXT_MORE_OPTION_DIRECTION_RIGHT); - m_pLayout->setMoreOption(*m_pMoreOption); - - // Prepare ItemsInfo: - m_MoreOptionItemsInfo[MorOptionReply] = - {nullptr, "WDS_MSG_OPT_REPLY_ABB", REPLY_MORE_ICON, makeCbLast(&ConvFrame::onReplyClicked)}; - m_MoreOptionItemsInfo[MorOptionCall] = - {nullptr, "WDS_MSG_OPT_CALL_ABB", CALL_MORE_ICON, makeCbLast(&ConvFrame::onCallClicked)}; - m_MoreOptionItemsInfo[MorOptionRecip] = - {nullptr, "WDS_MSG_OPT_RECIPIENTS_ABB", RECIP_MORE_ICON, makeCbLast(&ConvFrame::onRecipientsClicked)}; - m_MoreOptionItemsInfo[MorOptionBlock] = - {nullptr, "WDS_MSG_OPT_BLOCK_NUMBER_ABB", ADD_TO_SPAM_MORE_ICON, makeCbLast(&ConvFrame::onBlockNumberClicked)}; - m_MoreOptionItemsInfo[MorOptionUnblock] = - {nullptr, "WDS_MSG_OPT_UNBLOCK_NUMBER_ABB", REM_FROM_SPAM_MORE_ICON, makeCbLast(&ConvFrame::onUnblockNumberClicked)}; - m_MoreOptionItemsInfo[MorOptionDelete] = - {nullptr, "WDS_MSG_OPT_DELETE_ABB", DELETEG_MORE_ICON, makeCbLast(&ConvFrame::onDeleteClicked)}; - - prepedItem(MorOptionDelete); - prepedItem(MorOptionRecip); - } + if (!m_pMoreOption) { + m_pMoreOption = new MoreOption(*m_pLayout); + m_pMoreOption->setDirection(EEXT_MORE_OPTION_DIRECTION_RIGHT); + m_pLayout->setMoreOption(*m_pMoreOption); + + // Prepare ItemsInfo: + m_MoreOptionItemsInfo[MorOptionReply] = + {nullptr, "WDS_MSG_OPT_REPLY_ABB", REPLY_MORE_ICON, makeCbLast(&ConvFrame::onReplyClicked)}; + m_MoreOptionItemsInfo[MorOptionCall] = + {nullptr, "WDS_MSG_OPT_CALL_ABB", CALL_MORE_ICON, makeCbLast(&ConvFrame::onCallClicked)}; + m_MoreOptionItemsInfo[MorOptionRecip] = + {nullptr, "WDS_MSG_OPT_RECIPIENTS_ABB", RECIP_MORE_ICON, makeCbLast(&ConvFrame::onRecipientsClicked)}; + m_MoreOptionItemsInfo[MorOptionBlock] = + {nullptr, "WDS_MSG_OPT_BLOCK_NUMBER_ABB", ADD_TO_SPAM_MORE_ICON, makeCbLast(&ConvFrame::onBlockNumberClicked)}; + m_MoreOptionItemsInfo[MorOptionUnblock] = + {nullptr, "WDS_MSG_OPT_UNBLOCK_NUMBER_ABB", REM_FROM_SPAM_MORE_ICON, makeCbLast(&ConvFrame::onUnblockNumberClicked)}; + m_MoreOptionItemsInfo[MorOptionDelete] = + {nullptr, "WDS_MSG_OPT_DELETE_ABB", DELETEG_MORE_ICON, makeCbLast(&ConvFrame::onDeleteClicked)}; + + prepedItem(MorOptionDelete); + prepedItem(MorOptionRecip); + } } void ConvFrame::prepareDeleteViews() { - if (!m_pDeleteButton) { - m_pDeleteButton = new BottomButton(*m_pLayout); - m_pDeleteButton->setText(msgt("IDS_MSG_ACBUTTON_DELETE_ABB")); - View::addSmartCb(m_pDeleteButton->getInnerButton(), "clicked", makeCbFirst(&ConvFrame::onDelButtonClicked), this); - m_pLayout->setBottomButton(*m_pDeleteButton); - } + if (!m_pDeleteButton) { + m_pDeleteButton = new BottomButton(*m_pLayout); + m_pDeleteButton->setText(msgt("IDS_MSG_ACBUTTON_DELETE_ABB")); + View::addSmartCb(m_pDeleteButton->getInnerButton(), "clicked", makeCbFirst(&ConvFrame::onDelButtonClicked), this); + m_pLayout->setBottomButton(*m_pDeleteButton); + } - if (!m_pSelectButton) { - m_pSelectButton = new SelectButton(*m_pLayout); - View::addSmartCb(m_pSelectButton->getInnerButton(), "clicked", makeCbFirst(&ConvFrame::onSelectButtonClicked), this); - m_pLayout->setSelectButton(*m_pSelectButton); - } + if (!m_pSelectButton) { + m_pSelectButton = new SelectButton(*m_pLayout); + View::addSmartCb(m_pSelectButton->getInnerButton(), "clicked", makeCbFirst(&ConvFrame::onSelectButtonClicked), this); + m_pLayout->setSelectButton(*m_pSelectButton); + } } void ConvFrame::prepareList() { - if (!m_pList) { - m_pList = new ConvList(m_pLayout, m_WorkingDir); - m_pList->setListener(this); - m_pLayout->setContent(*m_pList); - } + if (!m_pList) { + m_pList = new ConvList(m_pLayout, m_WorkingDir); + m_pList->setListener(this); + m_pLayout->setContent(*m_pList); + } } void ConvFrame::prepedItem(MorOptionItemType itemType) { - MoreOptionItemInfo &info = m_MoreOptionItemsInfo[itemType]; - if (!info.item) - info.item = m_pMoreOption->prependItem(msgt(info.strId), info.icon, info.cb, this); + MoreOptionItemInfo &info = m_MoreOptionItemsInfo[itemType]; + if (!info.item) + info.item = m_pMoreOption->prependItem(msgt(info.strId), info.icon, info.cb, this); } void ConvFrame::removeItem(MorOptionItemType itemType) { - MoreOptionItemInfo &info = m_MoreOptionItemsInfo[itemType]; - if (info.item) { - m_pMoreOption->removeItem(info.item); - info.item = nullptr; - } + MoreOptionItemInfo &info = m_MoreOptionItemsInfo[itemType]; + if (info.item) { + m_pMoreOption->removeItem(info.item); + info.item = nullptr; + } } void ConvFrame::navigateToReicpList() { - auto *frame = new RecipListFrame(getParent()); - frame->setRecips({m_pList->getRecip()}); - getParent().push(*frame); + auto *frame = new RecipListFrame(getParent()); + frame->setRecips({m_pList->getRecip()}); + getParent().push(*frame); } void ConvFrame::setThreadId(ThreadId id) { - m_ThreadId = id; - m_pList->setThreadId(id); - m_pList->navigateToBottom(); - updateMoreOption(); + m_ThreadId = id; + m_pList->setThreadId(id); + m_pList->navigateToBottom(); + updateMoreOption(); } void ConvFrame::showSelectPopup() { - auto *ctx = new SelectCtxPopup; - unsigned checkedCount = m_pList->getCheckedItemsCount(); - unsigned checkableCount = m_pList->getCheckableItemsCount(); + auto *ctx = new SelectCtxPopup; + unsigned checkedCount = m_pList->getCheckedItemsCount(); + unsigned checkableCount = m_pList->getCheckableItemsCount(); - if (checkedCount < checkableCount) - ctx->appendTopItem(msgt("WDS_MSG_OPT_SELECT_ALL_ABB"), makeCbLast(&ConvFrame::onSelectAllButtonClicked), this); - if (checkedCount > 0) - ctx->appendBottomItem(msgt("WDS_MSG_OPT_DESELECT_ALL_ABB"), makeCbLast(&ConvFrame::onDeselectAllButtonClicked), this); + if (checkedCount < checkableCount) + ctx->appendTopItem(msgt("WDS_MSG_OPT_SELECT_ALL_ABB"), makeCbLast(&ConvFrame::onSelectAllButtonClicked), this); + if (checkedCount > 0) + ctx->appendBottomItem(msgt("WDS_MSG_OPT_DESELECT_ALL_ABB"), makeCbLast(&ConvFrame::onDeselectAllButtonClicked), this); - if (m_pSelectButton) - ctx->align(m_pSelectButton->getInnerButton()); + if (m_pSelectButton) + ctx->align(m_pSelectButton->getInnerButton()); - ctx->go(); + ctx->go(); } void ConvFrame::updateDeleteViews() { - if (m_Mode == DeleteMode) { - unsigned count = m_pList->getCheckedItemsCount(); - m_pSelectButton->setText(std::to_string(count)); - m_pDeleteButton->disabled(count == 0); - } + if (m_Mode == DeleteMode) { + unsigned count = m_pList->getCheckedItemsCount(); + m_pSelectButton->setText(std::to_string(count)); + m_pDeleteButton->disabled(count == 0); + } } void ConvFrame::reply() { - ConnectivityChecker &checker = getParent().getConnectivityChecker(); - if (checker.isFlightModeDisabled()) { - MsgInputSelector &inputSelector = getParent().getInputSelector(); - inputSelector.reset(); - inputSelector.setRecip(m_pList->getRecip()); - inputSelector.launch(); - } + ConnectivityChecker &checker = getParent().getConnectivityChecker(); + if (checker.isFlightModeDisabled()) { + MsgInputSelector &inputSelector = getParent().getInputSelector(); + inputSelector.reset(); + inputSelector.setRecip(m_pList->getRecip()); + inputSelector.launch(); + } } void ConvFrame::updateMoreOption() { - bool isValid = m_pList->getRecip().isValid(); - if (isValid) { - prepedItem(MorOptionCall); - prepedItem(MorOptionReply); + bool isValid = m_pList->getRecip().isValid(); + if (isValid) { + prepedItem(MorOptionCall); + prepedItem(MorOptionReply); - } else { - removeItem(MorOptionReply); - removeItem(MorOptionCall); - } + } else { + removeItem(MorOptionReply); + removeItem(MorOptionCall); + } } void ConvFrame::showNumberBlockUnblockPopup(bool isBlocked) { - const char *text = isBlocked ? "WDS_LOGS_TPOP_CALLS_MSGS_TO_GEAR_NUMBER_FROM_THIS_NUMBER_ARE_BLOCKED_ABB" - : "WDS_LOGS_TPOP_CALLS_MSGS_TO_GEAR_NUMBER_FROM_THIS_NUMBER_ARE_UNBLOCKED_ABB"; + const char *text = isBlocked ? "WDS_LOGS_TPOP_CALLS_MSGS_TO_GEAR_NUMBER_FROM_THIS_NUMBER_ARE_BLOCKED_ABB" + : "WDS_LOGS_TPOP_CALLS_MSGS_TO_GEAR_NUMBER_FROM_THIS_NUMBER_ARE_UNBLOCKED_ABB"; - ToastPopup::toast(msgt(text), nullptr); + ToastPopup::toast(msgt(text), nullptr); } void ConvFrame::onAttached(ViewItem &item) { - MSG_LOG(""); - FrameController::onAttached(item); - setContent(*m_pLayout); + MSG_LOG(""); + FrameController::onAttached(item); + setContent(*m_pLayout); } void ConvFrame::onHwBackButtonPreessed(Evas_Object *obj, void *event) { - MSG_LOG(""); - MSG_LOG(""); - if (m_Mode != NormalMode) - setMode(NormalMode); - else - pop(); + MSG_LOG(""); + MSG_LOG(""); + if (m_Mode != NormalMode) + setMode(NormalMode); + else + pop(); } void ConvFrame::onItemChecked(ConvListItem &item) { - MSG_LOG(""); - updateDeleteViews(); + MSG_LOG(""); + updateDeleteViews(); } void ConvFrame::onItemRequestDeleteMode(ConvListItem &listItem) { - MSG_LOG(""); - setMode(DeleteMode); + MSG_LOG(""); + setMode(DeleteMode); } void ConvFrame::onListChanged(ConvList &list) { - MSG_LOG(""); - if (m_pList->isEmpty()) - pop(); - else - updateDeleteViews(); + MSG_LOG(""); + if (m_pList->isEmpty()) + pop(); + else + updateDeleteViews(); } void ConvFrame::onReplyButtonClicked(ConvList &list) { - MSG_LOG(""); - reply(); + MSG_LOG(""); + reply(); } void ConvFrame::onDelButtonClicked(Evas_Object *obj, void *event) { - MSG_LOG(""); - if (m_pList->deleteCheckedItems()) { - auto *popup = new IconTextPopup; - popup->setIcon(IconTextPopup::CheckIcon); - popup->setText(msgt("WDS_ALM_TPOP_DELETED_ABB")); - popup->setTimeOut(); - popup->show(); - } - setMode(NormalMode); + MSG_LOG(""); + if (m_pList->deleteCheckedItems()) { + auto *popup = new IconTextPopup; + popup->setIcon(IconTextPopup::CheckIcon); + popup->setText(msgt("WDS_ALM_TPOP_DELETED_ABB")); + popup->setTimeOut(); + popup->show(); + } + setMode(NormalMode); } void ConvFrame::onSelectButtonClicked(Evas_Object *obj, void *event) { - MSG_LOG(""); - showSelectPopup(); + MSG_LOG(""); + showSelectPopup(); } void ConvFrame::onSelectAllButtonClicked(CtxPopupItem &item) { - MSG_LOG(""); - m_pList->checkAllItems(true); - updateDeleteViews(); + MSG_LOG(""); + m_pList->checkAllItems(true); + updateDeleteViews(); } void ConvFrame::onDeselectAllButtonClicked(CtxPopupItem &item) { - MSG_LOG(""); - m_pList->checkAllItems(false); - updateDeleteViews(); + MSG_LOG(""); + m_pList->checkAllItems(false); + updateDeleteViews(); } void ConvFrame::onReplyClicked(MoreOption &obj) { - MSG_LOG(""); - reply(); + MSG_LOG(""); + reply(); } void ConvFrame::onCallClicked(MoreOption &obj) { - MSG_LOG(""); - VoiceCall::launch(m_pList->getRecip().getAddress()); + MSG_LOG(""); + VoiceCall::launch(m_pList->getRecip().getAddress()); } void ConvFrame::onSendMyLocationClicked(MoreOption &obj) { - MSG_LOG(""); + MSG_LOG(""); } void ConvFrame::onRecipientsClicked(MoreOption &obj) { - MSG_LOG(""); - navigateToReicpList(); + MSG_LOG(""); + navigateToReicpList(); } void ConvFrame::onBlockNumberClicked(MoreOption &obj) { - MSG_LOG(""); - showNumberBlockUnblockPopup(true); + MSG_LOG(""); + showNumberBlockUnblockPopup(true); } void ConvFrame::onUnblockNumberClicked(MoreOption &obj) { - MSG_LOG(""); + MSG_LOG(""); } void ConvFrame::onDeleteClicked(MoreOption &obj) { - MSG_LOG(""); - setMode(DeleteMode); + MSG_LOG(""); + setMode(DeleteMode); } diff --git a/src/Conversation/Controller/src/ConvList.cpp b/src/Conversation/Controller/src/ConvList.cpp index 10c8cda..61e2e21 100644 --- a/src/Conversation/Controller/src/ConvList.cpp +++ b/src/Conversation/Controller/src/ConvList.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -32,368 +32,368 @@ using namespace Msg; ConvList::ConvList(DefaultLayout *parent, WorkingDirRef &workingDir) - : ListView(*parent, App::getInst().getWindow().getCircleSurface()) - , m_IsDeleteMode(false) - , m_pListener(nullptr) - , m_pBottomPadItem(nullptr) - , m_pReplyItem(nullptr) - , m_pItemAfterConv(nullptr) - , m_pTitleItem(nullptr) - , m_WorkingDir(workingDir) - , m_BubbleEntityFactory(m_WorkingDir) -{ - ListView::setListener(this); - getMsgStorage().addListener(*this); - App::getInst().getContactManager().addListener(*this); - App::getInst().getSysSettingsManager().addListener(*this); - ListView::setHomogeneous(false); - ListView::setMultiSelection(false); - ListView::enabledAlign(false); - ListView::setFocusAllow(false); + : ListView(*parent, App::getInst().getWindow().getCircleSurface()) + , m_IsDeleteMode(false) + , m_pListener(nullptr) + , m_pBottomPadItem(nullptr) + , m_pReplyItem(nullptr) + , m_pItemAfterConv(nullptr) + , m_pTitleItem(nullptr) + , m_WorkingDir(workingDir) + , m_BubbleEntityFactory(m_WorkingDir) +{ + ListView::setListener(this); + getMsgStorage().addListener(*this); + App::getInst().getContactManager().addListener(*this); + App::getInst().getSysSettingsManager().addListener(*this); + ListView::setHomogeneous(false); + ListView::setMultiSelection(false); + ListView::enabledAlign(false); + ListView::setFocusAllow(false); } ConvList::~ConvList() { - getMsgStorage().removeListener(*this); - App::getInst().getContactManager().removeListener(*this); - App::getInst().getSysSettingsManager().removeListener(*this); + getMsgStorage().removeListener(*this); + App::getInst().getContactManager().removeListener(*this); + App::getInst().getSysSettingsManager().removeListener(*this); } void ConvList::setDeleteMode(bool value) { - if (m_IsDeleteMode != value) { - m_IsDeleteMode = value; - ListView::setCheckMode(value); - ListView::checkAllItems(false, false); - } + if (m_IsDeleteMode != value) { + m_IsDeleteMode = value; + ListView::setCheckMode(value); + ListView::checkAllItems(false, false); + } } bool ConvList::isDeleteModeEnabled() const { - return m_IsDeleteMode; + return m_IsDeleteMode; } bool ConvList::deleteCheckedItems() { - bool res = false;; - MsgIdList idList; - auto items = getItems(); + bool res = false;; + MsgIdList idList; + auto items = getItems(); - for (auto *item : items) { - if (item->getCheckedState()) - idList.push_back(item->getMsgId()); - } - if (!idList.empty()) - res = getMsgStorage().deleteMessages(idList); + for (auto *item : items) { + if (item->getCheckedState()) + idList.push_back(item->getMsgId()); + } + if (!idList.empty()) + res = getMsgStorage().deleteMessages(idList); - return res; + return res; } void ConvList::setListener(IConvListListener *l) { - m_pListener = l; + m_pListener = l; } MsgStorage &ConvList::getMsgStorage() { - return App::getInst().getMsgEngine().getStorage(); + return App::getInst().getMsgEngine().getStorage(); } void ConvList::navigateToBottom() { - if (m_pItemAfterConv) - ListView::showItem(*m_pItemAfterConv, ELM_GENLIST_ITEM_SCROLLTO_BOTTOM); + if (m_pItemAfterConv) + ListView::showItem(*m_pItemAfterConv, ELM_GENLIST_ITEM_SCROLLTO_BOTTOM); } bool ConvList::isEmpty() const { - return getItemsCount() == 0; + return getItemsCount() == 0; } const Recipient &ConvList::getRecip() const { - return m_Recip; + return m_Recip; } void ConvList::updateTitle() { - m_pTitleItem->setTitle(m_Recip.getDispName()); - m_pTitleItem->update(); + m_pTitleItem->setTitle(m_Recip.getDispName()); + m_pTitleItem->update(); } void ConvList::updateLangInfo() { - // Update ConvListItem: - auto convItems = getItems(); - for (ConvListItem *item : convItems) - item->updateLangInfo(); + // Update ConvListItem: + auto convItems = getItems(); + for (ConvListItem *item : convItems) + item->updateLangInfo(); - // Update ConvDateLineListItem: - updateDateLineItems(false); + // Update ConvDateLineListItem: + updateDateLineItems(false); - // Update view: - ListView::updateRealizedItems(); + // Update view: + ListView::updateRealizedItems(); } void ConvList::updateDateLineItems(bool updateUi) { - m_DateLineItemSet.clear(); - auto items = getItems(); - for (ConvDateLineListItem *item : items) { - item->update(); - m_DateLineItemSet.insert(item->getDateTimeStr()); - } + m_DateLineItemSet.clear(); + auto items = getItems(); + for (ConvDateLineListItem *item : items) { + item->update(); + m_DateLineItemSet.insert(item->getDateTimeStr()); + } - if (updateUi) - ListView::updateRealizedItems(); + if (updateUi) + ListView::updateRealizedItems(); } void ConvList::clear() { - ListView::clear(); - m_ConvListItemMap.clear(); - m_DateLineItemSet.clear(); + ListView::clear(); + m_ConvListItemMap.clear(); + m_DateLineItemSet.clear(); } void ConvList::fillList() { - clear(); + clear(); - // Recipient name: - m_pTitleItem = new TitleListItem; - ListView::appendItem(*m_pTitleItem); + // Recipient name: + m_pTitleItem = new TitleListItem; + ListView::appendItem(*m_pTitleItem); - MsgConversationListRef convList = getMsgStorage().getConversationList(m_ThreadId); - int convListLen = convList->getLength(); - int reserveSize = (convListLen + 1) * 2; - m_ConvListItemMap.reserve(reserveSize); - m_DateLineItemSet.reserve(reserveSize); + MsgConversationListRef convList = getMsgStorage().getConversationList(m_ThreadId); + int convListLen = convList->getLength(); + int reserveSize = (convListLen + 1) * 2; + m_ConvListItemMap.reserve(reserveSize); + m_DateLineItemSet.reserve(reserveSize); - for (int i = 0; i < convListLen; ++i) { - MsgConversationItem &item = convList->at(i); - insertItem(item); - } + for (int i = 0; i < convListLen; ++i) { + MsgConversationItem &item = convList->at(i); + insertItem(item); + } - // Reply item: - if (m_Recip.isValid()) { - m_pReplyItem = new ConvReplyListItem; - ListView::appendItem(*m_pReplyItem); - } + // Reply item: + if (m_Recip.isValid()) { + m_pReplyItem = new ConvReplyListItem; + ListView::appendItem(*m_pReplyItem); + } - // Bottom padding: - m_pBottomPadItem = new PaddingListViewItem; - ListView::appendItem(*m_pBottomPadItem); + // Bottom padding: + m_pBottomPadItem = new PaddingListViewItem; + ListView::appendItem(*m_pBottomPadItem); - m_pItemAfterConv = m_pReplyItem ? (ListItem*)m_pReplyItem : (ListItem*)m_pBottomPadItem; + m_pItemAfterConv = m_pReplyItem ? (ListItem*)m_pReplyItem : (ListItem*)m_pBottomPadItem; - if (m_pListener) - m_pListener->onListChanged(*this); + if (m_pListener) + m_pListener->onListChanged(*this); } ConvListItem *ConvList::insertItem(const MsgConversationItem &item) { - auto *listItem = new ConvListItem(item, m_WorkingDir, m_BubbleEntityFactory); - insertItem(*listItem); - if (m_pListener) - m_pListener->onListChanged(*this); - return listItem; + auto *listItem = new ConvListItem(item, m_WorkingDir, m_BubbleEntityFactory); + insertItem(*listItem); + if (m_pListener) + m_pListener->onListChanged(*this); + return listItem; } ConvListItem *ConvList::getItem(MsgId msgId) const { - auto it = m_ConvListItemMap.find(msgId); - return it != m_ConvListItemMap.end() ? it->second : nullptr; + auto it = m_ConvListItemMap.find(msgId); + return it != m_ConvListItemMap.end() ? it->second : nullptr; } void ConvList::deleteItem(ConvListItem &item) { - delDateLineIfNeeded(item); - m_ConvListItemMap.erase(item.getMsgId()); - ListView::deleteItem(item); - if (m_pListener) - m_pListener->onListChanged(*this); + delDateLineIfNeeded(item); + m_ConvListItemMap.erase(item.getMsgId()); + ListView::deleteItem(item); + if (m_pListener) + m_pListener->onListChanged(*this); } bool ConvList::deleteItems(const MsgIdList &idList) { - bool res = false; - for (const MsgId &id: idList) { - ConvListItem *deleted = getItem(id); - if (deleted) { - res = true; - deleteItem(*deleted); - } - } + bool res = false; + for (const MsgId &id: idList) { + ConvListItem *deleted = getItem(id); + if (deleted) { + res = true; + deleteItem(*deleted); + } + } - return res; + return res; } void ConvList::insertItem(ConvListItem &item) { - addDateLineIfNeeded(item); - m_ConvListItemMap[item.getMsgId()] = &item; - if (m_pItemAfterConv) - ListView::insertBeforeItem(item, *m_pItemAfterConv); - else - ListView::appendItem(item); + addDateLineIfNeeded(item); + m_ConvListItemMap[item.getMsgId()] = &item; + if (m_pItemAfterConv) + ListView::insertBeforeItem(item, *m_pItemAfterConv); + else + ListView::appendItem(item); } void ConvList::demoteItem(ConvListItem &item) { - delDateLineIfNeeded(item); - addDateLineIfNeeded(item); - ListView::demoteItem(item); - if (m_pReplyItem) - ListView::demoteItem(*m_pReplyItem); - if (m_pBottomPadItem) - ListView::demoteItem(*m_pBottomPadItem); + delDateLineIfNeeded(item); + addDateLineIfNeeded(item); + ListView::demoteItem(item); + if (m_pReplyItem) + ListView::demoteItem(*m_pReplyItem); + if (m_pBottomPadItem) + ListView::demoteItem(*m_pBottomPadItem); } void ConvList::delDateLineIfNeeded(ConvListItem &item) { - auto *prev = dynamic_cast(getPrevItem(item)); - if (prev) { - auto *nextItem = ListView::getNextItem(item); - bool needDelDateLine = nextItem ? dynamic_cast(nextItem) == nullptr : true; - if (needDelDateLine) { - m_DateLineItemSet.erase(prev->getDateTimeStr()); - ListView::deleteItem(*prev); - } - } + auto *prev = dynamic_cast(getPrevItem(item)); + if (prev) { + auto *nextItem = ListView::getNextItem(item); + bool needDelDateLine = nextItem ? dynamic_cast(nextItem) == nullptr : true; + if (needDelDateLine) { + m_DateLineItemSet.erase(prev->getDateTimeStr()); + ListView::deleteItem(*prev); + } + } } void ConvList::addDateLineIfNeeded(ConvListItem &item) { - std::string dateStr = TimeUtils::makeBubbleDateLineString(item.getRawTime()); - auto it = m_DateLineItemSet.find(dateStr); - if (it == m_DateLineItemSet.end()) { - m_DateLineItemSet.insert(dateStr); - auto *dateLine = new ConvDateLineListItem(item.getRawTime(), std::move(dateStr)); - if (m_pItemAfterConv) - ListView::insertBeforeItem(*dateLine, *m_pItemAfterConv); - else - ListView::appendItem(*dateLine); - } + std::string dateStr = TimeUtils::makeBubbleDateLineString(item.getRawTime()); + auto it = m_DateLineItemSet.find(dateStr); + if (it == m_DateLineItemSet.end()) { + m_DateLineItemSet.insert(dateStr); + auto *dateLine = new ConvDateLineListItem(item.getRawTime(), std::move(dateStr)); + if (m_pItemAfterConv) + ListView::insertBeforeItem(*dateLine, *m_pItemAfterConv); + else + ListView::appendItem(*dateLine); + } } void ConvList::setThreadId(ThreadId id) { - if (m_ThreadId != id) { - m_ThreadId = id; - m_Recip = Recipient::getByThreadId(m_ThreadId); - fillList(); - updateTitle(); - markAsRead(); - } + if (m_ThreadId != id) { + m_ThreadId = id; + m_Recip = Recipient::getByThreadId(m_ThreadId); + fillList(); + updateTitle(); + markAsRead(); + } } void ConvList::markAsRead() { - if (m_ThreadId.isValid()) - getMsgStorage().setReadStatus(m_ThreadId); + if (m_ThreadId.isValid()) + getMsgStorage().setReadStatus(m_ThreadId); } void ConvList::resendMsg(ConvListItem &listItem) { - MSG_LOG(""); - MessageRef msg = getMsgStorage().getMessage(listItem.getMsgId()); - if (msg) - App::getInst().getMsgEngine().getTransport().sendMessage(msg); + MSG_LOG(""); + MessageRef msg = getMsgStorage().getMessage(listItem.getMsgId()); + if (msg) + App::getInst().getMsgEngine().getTransport().sendMessage(msg); } void ConvList::onListItemSelected(ListItem &listItem) { - MSG_LOG(""); - if (dynamic_cast(&listItem) && m_pListener) - m_pListener->onReplyButtonClicked(*this); + MSG_LOG(""); + if (dynamic_cast(&listItem) && m_pListener) + m_pListener->onReplyButtonClicked(*this); - if (auto *item = dynamic_cast(&listItem)) { - if (item->getStatusType() == ConvListViewItem::FailedStatus && !item->getActionEventFlag()) - resendMsg(*item); + if (auto *item = dynamic_cast(&listItem)) { + if (item->getStatusType() == ConvListViewItem::FailedStatus && !item->getActionEventFlag()) + resendMsg(*item); - item->setActionEventFlag(false); - } + item->setActionEventFlag(false); + } } void ConvList::onListItemLongPressed(ListItem &listItem) { - MSG_LOG(""); - if (m_pListener) { - auto *convItem = dynamic_cast(&listItem); - if (convItem) { - m_pListener->onItemRequestDeleteMode(*convItem); - if (isDeleteModeEnabled()) { - convItem->setCheckedState(true, true); - m_pListener->onItemChecked(*convItem); - } - } - } + MSG_LOG(""); + if (m_pListener) { + auto *convItem = dynamic_cast(&listItem); + if (convItem) { + m_pListener->onItemRequestDeleteMode(*convItem); + if (isDeleteModeEnabled()) { + convItem->setCheckedState(true, true); + m_pListener->onItemChecked(*convItem); + } + } + } } void ConvList::onListItemChecked(ListItem &listItem) { - MSG_LOG(""); - if (m_pListener) { - auto *convItem = dynamic_cast(&listItem); - if (convItem) - m_pListener->onItemChecked(*convItem); - } + MSG_LOG(""); + if (m_pListener) { + auto *convItem = dynamic_cast(&listItem); + if (convItem) + m_pListener->onItemChecked(*convItem); + } } void ConvList::onMsgStorageUpdate(const MsgIdList &msgIdList) { - MSG_LOG(""); - for (auto &itemId: msgIdList) { - ConvListItem *updated = getItem(itemId); - if (updated) { - time_t beforeTime = updated->getRawTime(); - updated->updateStatus(); - if (beforeTime != updated->getRawTime()) - demoteItem(*updated); - } - } + MSG_LOG(""); + for (auto &itemId: msgIdList) { + ConvListItem *updated = getItem(itemId); + if (updated) { + time_t beforeTime = updated->getRawTime(); + updated->updateStatus(); + if (beforeTime != updated->getRawTime()) + demoteItem(*updated); + } + } } void ConvList::onMsgStorageInsert(const MsgIdList &msgIdList) { - MSG_LOG(""); - ConvListItem *lastInsertedItem = nullptr; - for (MsgId msgId: msgIdList) { - if (getItem(msgId)) - continue; + MSG_LOG(""); + ConvListItem *lastInsertedItem = nullptr; + for (MsgId msgId: msgIdList) { + if (getItem(msgId)) + continue; - MessageRef msg = getMsgStorage().getMessage(msgId); - if (msg && msg->getThreadId() == m_ThreadId && msg->getMessageStorageType() != Message::MS_Sim) { - MsgConversationItemRef item = getMsgStorage().getConversationItem(msgId); - if (item) - lastInsertedItem = insertItem(*item); - markAsRead(); - } - } - if (lastInsertedItem) - ListView::showItem(*lastInsertedItem, ELM_GENLIST_ITEM_SCROLLTO_MIDDLE); + MessageRef msg = getMsgStorage().getMessage(msgId); + if (msg && msg->getThreadId() == m_ThreadId && msg->getMessageStorageType() != Message::MS_Sim) { + MsgConversationItemRef item = getMsgStorage().getConversationItem(msgId); + if (item) + lastInsertedItem = insertItem(*item); + markAsRead(); + } + } + if (lastInsertedItem) + ListView::showItem(*lastInsertedItem, ELM_GENLIST_ITEM_SCROLLTO_MIDDLE); } void ConvList::onMsgStorageDelete(const MsgIdList &msgIdList) { - MSG_LOG(""); - deleteItems(msgIdList); + MSG_LOG(""); + deleteItems(msgIdList); } void ConvList::onContactChanged() { - MSG_LOG(""); - m_Recip.updateContactInfo(); - updateTitle(); + MSG_LOG(""); + m_Recip.updateContactInfo(); + updateTitle(); } void ConvList::onTimeFormatChanged() { - MSG_LOG(""); + MSG_LOG(""); } void ConvList::onLanguageChanged() { - MSG_LOG(""); - updateLangInfo(); + MSG_LOG(""); + updateLangInfo(); } diff --git a/src/Conversation/Controller/src/ConvListItem.cpp b/src/Conversation/Controller/src/ConvListItem.cpp index a0e87c2..8790ba6 100644 --- a/src/Conversation/Controller/src/ConvListItem.cpp +++ b/src/Conversation/Controller/src/ConvListItem.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -36,20 +36,20 @@ using namespace Msg; ConvListItem::ConvListItem(const MsgConversationItem &item, - WorkingDirRef &workingDir, - BubbleEntityFactory &bubbleEntityFactory) - : ConvListViewItem(item.getDirection() == Message::MD_Sent ? Sent : Received) - , m_MsgId(item.getMsgId()) - , m_Time(item.getTime()) - , m_Direction(item.getDirection()) - , m_NetworkStatus(item.getNetworkStatus()) - , m_Type(item.getType()) - , m_WorkingDir(workingDir) - , m_BubbleEntityFactory(bubbleEntityFactory) - , m_ActionEventFlag(false) -{ - prepareContent(item); - updateViewStatus(); + WorkingDirRef &workingDir, + BubbleEntityFactory &bubbleEntityFactory) + : ConvListViewItem(item.getDirection() == Message::MD_Sent ? Sent : Received) + , m_MsgId(item.getMsgId()) + , m_Time(item.getTime()) + , m_Direction(item.getDirection()) + , m_NetworkStatus(item.getNetworkStatus()) + , m_Type(item.getType()) + , m_WorkingDir(workingDir) + , m_BubbleEntityFactory(bubbleEntityFactory) + , m_ActionEventFlag(false) +{ + prepareContent(item); + updateViewStatus(); } ConvListItem::~ConvListItem() @@ -58,151 +58,151 @@ ConvListItem::~ConvListItem() MsgId ConvListItem::getMsgId() const { - return m_MsgId; + return m_MsgId; } time_t ConvListItem::getRawTime() const { - return m_Time; + return m_Time; } void ConvListItem::updateViewStatus() { - switch (m_NetworkStatus) { - case Message::NS_Send_Fail: - setInfoStatus(ConvListViewItem::FailedStatus); - break; + switch (m_NetworkStatus) { + case Message::NS_Send_Fail: + setInfoStatus(ConvListViewItem::FailedStatus); + break; - case Message::NS_Sending: - case Message::NS_Send_Pending: - setInfoStatus(ConvListViewItem::ProgressStatus); - break; + case Message::NS_Sending: + case Message::NS_Send_Pending: + setInfoStatus(ConvListViewItem::ProgressStatus); + break; - case Message::NS_Retrieving: - case Message::NS_Retrieve_Success: - case Message::NS_Retrieve_Fail: - setInfoStatus(m_NetworkStatus == Message::NS_Retrieving ? ProgressStatus : NoneStatus); - break; + case Message::NS_Retrieving: + case Message::NS_Retrieve_Success: + case Message::NS_Retrieve_Fail: + setInfoStatus(m_NetworkStatus == Message::NS_Retrieving ? ProgressStatus : NoneStatus); + break; - default: - setInfoStatus(NoneStatus); - break; - } + default: + setInfoStatus(NoneStatus); + break; + } } void ConvListItem::updateStatus() { - MessageRef msg = App::getInst().getMsgEngine().getStorage().getMessage(m_MsgId); - if (msg) { - m_Time = msg->getTime(); - m_NetworkStatus = msg->getNetworkStatus(); - updateTime(); - updateViewStatus(); - } + MessageRef msg = App::getInst().getMsgEngine().getStorage().getMessage(m_MsgId); + if (msg) { + m_Time = msg->getTime(); + m_NetworkStatus = msg->getNetworkStatus(); + updateTime(); + updateViewStatus(); + } } void ConvListItem::updateTime() { - m_TimeStr.clear(); + m_TimeStr.clear(); } void ConvListItem::updateLangInfo() { - updateTime(); + updateTime(); } void ConvListItem::setActionEventFlag(bool isAction) { - m_ActionEventFlag = isAction; + m_ActionEventFlag = isAction; } bool ConvListItem::getActionEventFlag() const { - return m_ActionEventFlag; + return m_ActionEventFlag; } void ConvListItem::showMobileDataOffPopup() { - ToastPopup::toast(msgt("WDS_MSG_TPOP_UNABLE_TO_RETRIEVE_MESSAGE_MOBILE_DATA_OFF_ABB"), nullptr); + ToastPopup::toast(msgt("WDS_MSG_TPOP_UNABLE_TO_RETRIEVE_MESSAGE_MOBILE_DATA_OFF_ABB"), nullptr); } void ConvListItem::showFailedToRetrievePopup() { - auto *popup = new IconTextPopup; - popup->setText(msgt("WDS_WNOTI_TPOP_FAILED")); - popup->setIcon(IconTextPopup::FailedIcon); - popup->setTimeOut(); - popup->show(); + auto *popup = new IconTextPopup; + popup->setText(msgt("WDS_WNOTI_TPOP_FAILED")); + popup->setIcon(IconTextPopup::FailedIcon); + popup->setTimeOut(); + popup->show(); } void ConvListItem::showRetrieveMmsPopup() { - auto *popup = new StandardPopup(StandardPopup::buttons2Style); - popup->setText(msgt("WDS_MSG_POP_RETRIEVE_MULTIMEDIA_MESSAGE_Q")); - popup->addLeftButton(CANCEL_BUTTON_POPUP, makeCbLast(&ConvListItem::onCancelButtonClicked), this); - popup->addRightButton(OK_BUTTON_POPUP, makeCbLast(&ConvListItem::onRetrieveButtonClicked), this); - popup->show(); + auto *popup = new StandardPopup(StandardPopup::buttons2Style); + popup->setText(msgt("WDS_MSG_POP_RETRIEVE_MULTIMEDIA_MESSAGE_Q")); + popup->addLeftButton(CANCEL_BUTTON_POPUP, makeCbLast(&ConvListItem::onCancelButtonClicked), this); + popup->addRightButton(OK_BUTTON_POPUP, makeCbLast(&ConvListItem::onRetrieveButtonClicked), this); + popup->show(); } void ConvListItem::prepareContent(const MsgConversationItem &item) { - m_BubbleEntityList = m_BubbleEntityFactory.create(item); + m_BubbleEntityList = m_BubbleEntityFactory.create(item); } void ConvListItem::onCancelButtonClicked(Popup &popup) { - MSG_LOG(""); - popup.destroy(); + MSG_LOG(""); + popup.destroy(); } void ConvListItem::onRetrieveButtonClicked(Popup &popup) { - MSG_LOG(""); + MSG_LOG(""); } Evas_Object *ConvListItem::getBubbleContent() { - if (m_BubbleEntityList.empty()) - return nullptr; + if (m_BubbleEntityList.empty()) + return nullptr; - auto *bubble = new BubbleItemContainer(*getOwner()); - for (BubbleEntityRef entity : m_BubbleEntityList) { - BubbleViewItem *item = entity->createView(*bubble); - if (item) { - bubble->append(*item, entity->getDirection()); - item->setListener(this); - } - } - bubble->go(); - bubble->show(); - return *bubble; + auto *bubble = new BubbleItemContainer(*getOwner()); + for (BubbleEntityRef entity : m_BubbleEntityList) { + BubbleViewItem *item = entity->createView(*bubble); + if (item) { + bubble->append(*item, entity->getDirection()); + item->setListener(this); + } + } + bubble->go(); + bubble->show(); + return *bubble; } std::string ConvListItem::getTime() { - if (m_TimeStr.empty()) - m_TimeStr = TimeUtils::makeBubbleTimeString(m_Time); - return m_TimeStr; + if (m_TimeStr.empty()) + m_TimeStr = TimeUtils::makeBubbleTimeString(m_Time); + return m_TimeStr; } std::string ConvListItem::getMsgType() { - return MsgUtils::isMms(m_Type) ? (std::string)msg("WDS_MSG_SBODY_MMS_ABB") : ""; + return MsgUtils::isMms(m_Type) ? (std::string)msg("WDS_MSG_SBODY_MMS_ABB") : ""; } void ConvListItem::onAction(BubbleViewItem &item) { - MSG_LOG(""); - if (auto *audio = dynamic_cast(&item.getEntity())) { - audio->clickHandler(); - setActionEventFlag(); - } else { - std::string filePath = item.getEntity().getFilePath(); - if (!filePath.empty()) { - setActionEventFlag(); - m_FileViewer.launchWithCopy(filePath); - } - } + MSG_LOG(""); + if (auto *audio = dynamic_cast(&item.getEntity())) { + audio->clickHandler(); + setActionEventFlag(); + } else { + std::string filePath = item.getEntity().getFilePath(); + if (!filePath.empty()) { + setActionEventFlag(); + m_FileViewer.launchWithCopy(filePath); + } + } } diff --git a/src/Conversation/Controller/src/RecipListFrame.cpp b/src/Conversation/Controller/src/RecipListFrame.cpp index 1aea6d4..39cf6ff 100644 --- a/src/Conversation/Controller/src/RecipListFrame.cpp +++ b/src/Conversation/Controller/src/RecipListFrame.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -26,11 +26,11 @@ using namespace Msg; RecipListFrame::RecipListFrame(NaviFrameController &parent) - : FrameController(parent, ConvGroup) - , m_pList(nullptr) - , m_pBottomPadItem(nullptr) + : FrameController(parent, ConvGroup) + , m_pList(nullptr) + , m_pBottomPadItem(nullptr) { - prepeareList(); + prepeareList(); } RecipListFrame::~RecipListFrame() @@ -39,56 +39,56 @@ RecipListFrame::~RecipListFrame() void RecipListFrame::setRecips(std::list recips) { - for (auto &&recip: recips) { - auto *item = new RecipListItem; - item->setRecipient(std::move(recip)); - m_pList->insertBeforeItem(*item, *m_pBottomPadItem); - } + for (auto &&recip: recips) { + auto *item = new RecipListItem; + item->setRecipient(std::move(recip)); + m_pList->insertBeforeItem(*item, *m_pBottomPadItem); + } } void RecipListFrame::fillList() { - // Title: - auto title = new TitleListItem; - title->setTitle(msgt("WDS_MSG_OPT_RECIPIENTS_ABB")); - m_pList->appendItem(*title); + // Title: + auto title = new TitleListItem; + title->setTitle(msgt("WDS_MSG_OPT_RECIPIENTS_ABB")); + m_pList->appendItem(*title); - // Bottom padding: - m_pBottomPadItem = new PaddingListViewItem; - m_pList->appendItem(*m_pBottomPadItem); + // Bottom padding: + m_pBottomPadItem = new PaddingListViewItem; + m_pList->appendItem(*m_pBottomPadItem); } void RecipListFrame::onAttached(ViewItem &item) { - FrameController::onAttached(item); - setContent(*m_pList); + FrameController::onAttached(item); + setContent(*m_pList); } void RecipListFrame::prepeareList() { - if (!m_pList) { - m_pList = new ListView(getParent(), App::getInst().getWindow().getCircleSurface()); - m_pList->setHomogeneous(false); - m_pList->setListener(this); - fillList(); - } + if (!m_pList) { + m_pList = new ListView(getParent(), App::getInst().getWindow().getCircleSurface()); + m_pList->setHomogeneous(false); + m_pList->setListener(this); + fillList(); + } } void RecipListFrame::onListItemSelected(ListItem &listItem) { - MSG_LOG(""); - auto *recipItem = dynamic_cast(&listItem); - if (recipItem && recipItem->getRecipient().isValid()) { - m_ContactViewer.launch(recipItem->getRecipient().getAddress()); - } + MSG_LOG(""); + auto *recipItem = dynamic_cast(&listItem); + if (recipItem && recipItem->getRecipient().isValid()) { + m_ContactViewer.launch(recipItem->getRecipient().getAddress()); + } } void RecipListFrame::onContactChanged() { - MSG_LOG(""); - auto items = m_pList->getItems(); - for (RecipListItem *item : items) { - item->updateContactInfo(); - } - m_pList->updateRealizedItems(); + MSG_LOG(""); + auto items = m_pList->getItems(); + for (RecipListItem *item : items) { + item->updateContactInfo(); + } + m_pList->updateRealizedItems(); } diff --git a/src/Conversation/View/inc/BubbleAudioViewItem.h b/src/Conversation/View/inc/BubbleAudioViewItem.h index d88a526..84a4636 100644 --- a/src/Conversation/View/inc/BubbleAudioViewItem.h +++ b/src/Conversation/View/inc/BubbleAudioViewItem.h @@ -20,29 +20,29 @@ #include "BubbleViewItem.h" namespace Msg { - class BubbleAudioViewItem - : public BubbleViewItem { + class BubbleAudioViewItem + : public BubbleViewItem { - public: - enum State { - PlayState, - PauseState - }; + public: + enum State { + PlayState, + PauseState + }; - public: - BubbleAudioViewItem(Evas_Object *parent, BubbleEntity &entity); - virtual ~BubbleAudioViewItem(); + public: + BubbleAudioViewItem(Evas_Object *parent, BubbleEntity &entity); + virtual ~BubbleAudioViewItem(); - void setMainText(const std::string &text); - void setTimeText(const std::string &text); - void setProgress(double progress); - void setState(State state); + void setMainText(const std::string &text); + void setTimeText(const std::string &text); + void setProgress(double progress); + void setState(State state); - void calculate() override; + void calculate() override; - private: - Evas_Object *m_pItemLayout; - }; + private: + Evas_Object *m_pItemLayout; + }; } #endif /* BubbleAudioViewItem_h_ */ diff --git a/src/Conversation/View/inc/BubbleIconTextLayoutItem.h b/src/Conversation/View/inc/BubbleIconTextLayoutItem.h index f5cd7d8..d31913d 100644 --- a/src/Conversation/View/inc/BubbleIconTextLayoutItem.h +++ b/src/Conversation/View/inc/BubbleIconTextLayoutItem.h @@ -20,22 +20,22 @@ #include "BubbleViewItem.h" namespace Msg { - class BubbleIconTextLayoutItem - : public BubbleViewItem { - public: - BubbleIconTextLayoutItem(Evas_Object *parent, BubbleEntity &entity); - virtual ~BubbleIconTextLayoutItem(); + class BubbleIconTextLayoutItem + : public BubbleViewItem { + public: + BubbleIconTextLayoutItem(Evas_Object *parent, BubbleEntity &entity); + virtual ~BubbleIconTextLayoutItem(); - void setIcon(Evas_Object *icon); - void setMainText(const std::string &text); - void calculate() override; + void setIcon(Evas_Object *icon); + void setMainText(const std::string &text); + void calculate() override; - static Evas_Object *createIcon(Evas_Object *parent, const std::string &edjFileName); - Evas_Object *createIcon(const std::string &edjFileName) const; + static Evas_Object *createIcon(Evas_Object *parent, const std::string &edjFileName); + Evas_Object *createIcon(const std::string &edjFileName) const; - private: - Evas_Object *m_pIconTextLayout; - }; + private: + Evas_Object *m_pIconTextLayout; + }; } #endif /* BubbleIconTextLayoutItem_h_ */ diff --git a/src/Conversation/View/inc/BubbleImageViewItem.h b/src/Conversation/View/inc/BubbleImageViewItem.h index 2b4a0c9..4e161c6 100644 --- a/src/Conversation/View/inc/BubbleImageViewItem.h +++ b/src/Conversation/View/inc/BubbleImageViewItem.h @@ -20,14 +20,14 @@ #include "BubbleViewItem.h" namespace Msg { - class BubbleImageViewItem - : public BubbleViewItem { - public: - BubbleImageViewItem(BubbleEntity &entity, Evas_Object *parent, const std::string &imagePath); - virtual ~BubbleImageViewItem(); + class BubbleImageViewItem + : public BubbleViewItem { + public: + BubbleImageViewItem(BubbleEntity &entity, Evas_Object *parent, const std::string &imagePath); + virtual ~BubbleImageViewItem(); - static Evas_Object *createImage(Evas_Object *parent, const std::string &path); - }; + static Evas_Object *createImage(Evas_Object *parent, const std::string &path); + }; } #endif /* BubbleImageViewItem_h_ */ diff --git a/src/Conversation/View/inc/BubbleInfoTextViewItem.h b/src/Conversation/View/inc/BubbleInfoTextViewItem.h index 998c99f..8201515 100644 --- a/src/Conversation/View/inc/BubbleInfoTextViewItem.h +++ b/src/Conversation/View/inc/BubbleInfoTextViewItem.h @@ -24,24 +24,24 @@ static const std::string textColor = "#b3b3b3"; static const int textSize = 28; namespace Msg { - class BubbleInfoTextViewItem - : public BubbleViewItem { - public: - BubbleInfoTextViewItem(BubbleEntity &entity, Evas_Object *parent, const std::string &text); - virtual ~BubbleInfoTextViewItem(); - }; + class BubbleInfoTextViewItem + : public BubbleViewItem { + public: + BubbleInfoTextViewItem(BubbleEntity &entity, Evas_Object *parent, const std::string &text); + virtual ~BubbleInfoTextViewItem(); + }; - inline BubbleInfoTextViewItem::BubbleInfoTextViewItem(BubbleEntity &entity, Evas_Object *parent, const std::string &text) - : BubbleViewItem(parent, entity) - { - Evas_Object *label = BubbleTextViewItem::createText(*this, TextDecorator::make(msg(text), textSize, textColor)); - elm_label_wrap_width_set(label, maxWidth); - setContent(label); - } + inline BubbleInfoTextViewItem::BubbleInfoTextViewItem(BubbleEntity &entity, Evas_Object *parent, const std::string &text) + : BubbleViewItem(parent, entity) + { + Evas_Object *label = BubbleTextViewItem::createText(*this, TextDecorator::make(msg(text), textSize, textColor)); + elm_label_wrap_width_set(label, maxWidth); + setContent(label); + } - inline BubbleInfoTextViewItem::~BubbleInfoTextViewItem() - { - } + inline BubbleInfoTextViewItem::~BubbleInfoTextViewItem() + { + } } #endif /* BubbleNoContentViewItem_h_ */ diff --git a/src/Conversation/View/inc/BubbleItemContainer.h b/src/Conversation/View/inc/BubbleItemContainer.h index 163b338..cc9b85c 100644 --- a/src/Conversation/View/inc/BubbleItemContainer.h +++ b/src/Conversation/View/inc/BubbleItemContainer.h @@ -21,15 +21,15 @@ #include "BubbleViewItem.h" namespace Msg { - class BubbleItemContainer - : public View { - public: - BubbleItemContainer(Evas_Object *parent); - virtual ~BubbleItemContainer(); + class BubbleItemContainer + : public View { + public: + BubbleItemContainer(Evas_Object *parent); + virtual ~BubbleItemContainer(); - void append(BubbleViewItem &item, Message::Direction direction); - void go(); - }; + void append(BubbleViewItem &item, Message::Direction direction); + void go(); + }; } #endif /* BubbleItemContainer_h_ */ diff --git a/src/Conversation/View/inc/BubbleSubjectViewItem.h b/src/Conversation/View/inc/BubbleSubjectViewItem.h index e4d3726..5a61b6a 100644 --- a/src/Conversation/View/inc/BubbleSubjectViewItem.h +++ b/src/Conversation/View/inc/BubbleSubjectViewItem.h @@ -20,19 +20,19 @@ #include "BubbleViewItem.h" namespace Msg { - class BubbleSubjectViewItem - : public BubbleViewItem { - public: - BubbleSubjectViewItem(BubbleEntity &entity, Evas_Object *parent); - virtual ~BubbleSubjectViewItem(); + class BubbleSubjectViewItem + : public BubbleViewItem { + public: + BubbleSubjectViewItem(BubbleEntity &entity, Evas_Object *parent); + virtual ~BubbleSubjectViewItem(); - void calculate() override; + void calculate() override; - void setText(const std::string &text); + void setText(const std::string &text); - private: - Evas_Object *m_pTextLayout; - }; + private: + Evas_Object *m_pTextLayout; + }; } #endif /* BubbleSubjectViewItem_h_ */ diff --git a/src/Conversation/View/inc/BubbleTextViewItem.h b/src/Conversation/View/inc/BubbleTextViewItem.h index 047a6ec..92537cc 100644 --- a/src/Conversation/View/inc/BubbleTextViewItem.h +++ b/src/Conversation/View/inc/BubbleTextViewItem.h @@ -20,14 +20,14 @@ #include "BubbleViewItem.h" namespace Msg { - class BubbleTextViewItem - : public BubbleViewItem { - public: - BubbleTextViewItem(BubbleEntity &entity, Evas_Object *parent, const std::string &text); - virtual ~BubbleTextViewItem(); + class BubbleTextViewItem + : public BubbleViewItem { + public: + BubbleTextViewItem(BubbleEntity &entity, Evas_Object *parent, const std::string &text); + virtual ~BubbleTextViewItem(); - static Evas_Object *createText(Evas_Object *parent, const std::string &text); - }; + static Evas_Object *createText(Evas_Object *parent, const std::string &text); + }; } #endif /* BubbleTextViewItem_h_ */ diff --git a/src/Conversation/View/inc/BubbleVideoViewItem.h b/src/Conversation/View/inc/BubbleVideoViewItem.h index 2ddecb7..5f0cdde 100644 --- a/src/Conversation/View/inc/BubbleVideoViewItem.h +++ b/src/Conversation/View/inc/BubbleVideoViewItem.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -21,40 +21,40 @@ #include "BubbleImageViewItem.h" namespace Msg { - class BubbleVideoViewItem - : public BubbleViewItem { - public: - BubbleVideoViewItem(BubbleEntity &entity, Evas_Object *parent, const std::string &imagePath); - virtual ~BubbleVideoViewItem(); - - void calculate() override; - - private: - Evas_Object *m_pVideoLayout; - }; - - inline BubbleVideoViewItem::BubbleVideoViewItem(BubbleEntity &entity, Evas_Object *parent, const std::string &imagePath) - : BubbleViewItem(parent, entity) - , m_pVideoLayout(nullptr) - { - m_pVideoLayout = addLayout(parent, CONV_LIST_BUBBLE_EDJ_PATH, "conv/list/video_item"); - Evas_Object *image = BubbleImageViewItem::createImage(m_pVideoLayout, imagePath); - View::setContent(m_pVideoLayout, image, "content"); - setContent(m_pVideoLayout); - - getAtspi().setReadingInfo(ELM_ACCESSIBLE_READING_INFO_TYPE_NAME); - getAtspi().setName(msg("WDS_ACCS_TBOPT_ATTACHED_VIDEO")); - } - - inline BubbleVideoViewItem::~BubbleVideoViewItem() - { - } - - inline void BubbleVideoViewItem::calculate() - { - evas_object_smart_calculate(m_pVideoLayout); - BubbleViewItem::calculate(); - } + class BubbleVideoViewItem + : public BubbleViewItem { + public: + BubbleVideoViewItem(BubbleEntity &entity, Evas_Object *parent, const std::string &imagePath); + virtual ~BubbleVideoViewItem(); + + void calculate() override; + + private: + Evas_Object *m_pVideoLayout; + }; + + inline BubbleVideoViewItem::BubbleVideoViewItem(BubbleEntity &entity, Evas_Object *parent, const std::string &imagePath) + : BubbleViewItem(parent, entity) + , m_pVideoLayout(nullptr) + { + m_pVideoLayout = addLayout(parent, CONV_LIST_BUBBLE_EDJ_PATH, "conv/list/video_item"); + Evas_Object *image = BubbleImageViewItem::createImage(m_pVideoLayout, imagePath); + View::setContent(m_pVideoLayout, image, "content"); + setContent(m_pVideoLayout); + + getAtspi().setReadingInfo(ELM_ACCESSIBLE_READING_INFO_TYPE_NAME); + getAtspi().setName(msg("WDS_ACCS_TBOPT_ATTACHED_VIDEO")); + } + + inline BubbleVideoViewItem::~BubbleVideoViewItem() + { + } + + inline void BubbleVideoViewItem::calculate() + { + evas_object_smart_calculate(m_pVideoLayout); + BubbleViewItem::calculate(); + } } #endif /* BubbleVideoViewItem_h_ */ diff --git a/src/Conversation/View/inc/BubbleViewItem.h b/src/Conversation/View/inc/BubbleViewItem.h index cf94a68..c7af0c4 100644 --- a/src/Conversation/View/inc/BubbleViewItem.h +++ b/src/Conversation/View/inc/BubbleViewItem.h @@ -21,44 +21,44 @@ #include namespace Msg { - class IBubbleViewItemListener; - class BubbleEntity; + class IBubbleViewItemListener; + class BubbleEntity; - class BubbleViewItem - : public View { - public: - static const int maxWidth = 240; + class BubbleViewItem + : public View { + public: + static const int maxWidth = 240; - BubbleViewItem(Evas_Object *parent, BubbleEntity &entity, bool addGestureLayer = true); - virtual ~BubbleViewItem(); + BubbleViewItem(Evas_Object *parent, BubbleEntity &entity, bool addGestureLayer = true); + virtual ~BubbleViewItem(); - virtual void calculate(); - void setListener(IBubbleViewItemListener *l); - BubbleEntity &getEntity(); + virtual void calculate(); + void setListener(IBubbleViewItemListener *l); + BubbleEntity &getEntity(); - void setContent(Evas_Object *obj); - Evas_Object *getContent() const; + void setContent(Evas_Object *obj); + Evas_Object *getContent() const; - Atspi getAtspi() const; + Atspi getAtspi() const; - protected: - void emitActionEvent(); - void attachGestureTapLayer(Evas_Object *parent, Evas_Object *obj); + protected: + void emitActionEvent(); + void attachGestureTapLayer(Evas_Object *parent, Evas_Object *obj); - private: - Evas_Object *createGestureRect(Evas_Object *parent); - Eina_Bool onScreenReaderClicked(Evas_Object *obj, Elm_Access_Action_Info *action_info); + private: + Evas_Object *createGestureRect(Evas_Object *parent); + Eina_Bool onScreenReaderClicked(Evas_Object *obj, Elm_Access_Action_Info *action_info); - private: - BubbleEntity &m_Entity; - IBubbleViewItemListener *m_pListener; - }; + private: + BubbleEntity &m_Entity; + IBubbleViewItemListener *m_pListener; + }; - class IBubbleViewItemListener { - public: - virtual ~IBubbleViewItemListener() {}; - virtual void onAction(BubbleViewItem &item) {}; // Tap or Click - }; + class IBubbleViewItemListener { + public: + virtual ~IBubbleViewItemListener() {}; + virtual void onAction(BubbleViewItem &item) {}; // Tap or Click + }; } #endif /* BubbleViewItem_h_ */ diff --git a/src/Conversation/View/inc/ConvDateLineListItem.h b/src/Conversation/View/inc/ConvDateLineListItem.h index 4b83bbe..3a318b4 100644 --- a/src/Conversation/View/inc/ConvDateLineListItem.h +++ b/src/Conversation/View/inc/ConvDateLineListItem.h @@ -20,23 +20,23 @@ #include "ListItem.h" namespace Msg { - class ConvDateLineListItem - : public ListItem { - public: - ConvDateLineListItem(time_t dateTime); - ConvDateLineListItem(time_t dateTime, std::string dateTimeStr); - virtual ~ConvDateLineListItem(); + class ConvDateLineListItem + : public ListItem { + public: + ConvDateLineListItem(time_t dateTime); + ConvDateLineListItem(time_t dateTime, std::string dateTimeStr); + virtual ~ConvDateLineListItem(); - void update(); - const std::string &getDateTimeStr() const; + void update(); + const std::string &getDateTimeStr() const; - private: - virtual std::string getText(ListItem &item, const char *part); + private: + virtual std::string getText(ListItem &item, const char *part); - private: - time_t m_DateTime; - std::string m_DateTimeStr; - }; + private: + time_t m_DateTime; + std::string m_DateTimeStr; + }; } #endif /* ConvDateLineListItem_h_ */ diff --git a/src/Conversation/View/inc/ConvListViewItem.h b/src/Conversation/View/inc/ConvListViewItem.h index 4025af1..5e96350 100644 --- a/src/Conversation/View/inc/ConvListViewItem.h +++ b/src/Conversation/View/inc/ConvListViewItem.h @@ -20,52 +20,52 @@ #include "ListItem.h" namespace Msg { - class ConvListViewItem - : public ListItem { - public: - enum ConvItemType { - Sent, - Received, - }; + class ConvListViewItem + : public ListItem { + public: + enum ConvItemType { + Sent, + Received, + }; - enum InfoStatusType { - NoneStatus, - ProgressStatus, - FailedStatus - }; + enum InfoStatusType { + NoneStatus, + ProgressStatus, + FailedStatus + }; - ConvListViewItem(ConvItemType type); - virtual ~ConvListViewItem(); + ConvListViewItem(ConvItemType type); + virtual ~ConvListViewItem(); - void setCheckedState(bool state, bool updateUi) override; - void setInfoStatus(InfoStatusType statusType); - InfoStatusType getStatusType() const; + void setCheckedState(bool state, bool updateUi) override; + void setInfoStatus(InfoStatusType statusType); + InfoStatusType getStatusType() const; - protected: - virtual Evas_Object *getBubbleContent() = 0; - virtual std::string getTime() = 0; - virtual std::string getMsgType() = 0; + protected: + virtual Evas_Object *getBubbleContent() = 0; + virtual std::string getTime() = 0; + virtual std::string getMsgType() = 0; - protected: - void updateContent(); + protected: + void updateContent(); - private: - std::string getText(ListItem &item, const char *part) override; - Evas_Object *getContent(ListItem &item, const char *part) override; - bool isCheckable() const override; - void onRealized(ListItem &item) override; - void onUnrealized(ListItem &item) override; + private: + std::string getText(ListItem &item, const char *part) override; + Evas_Object *getContent(ListItem &item, const char *part) override; + bool isCheckable() const override; + void onRealized(ListItem &item) override; + void onUnrealized(ListItem &item) override; - Evas_Object *createProgress(); - Evas_Object *createFailedButton(); - void updateItemType(ConvItemType type); - void updateContentBlocker(); - void updateSelectedState(bool state); + Evas_Object *createProgress(); + Evas_Object *createFailedButton(); + void updateItemType(ConvItemType type); + void updateContentBlocker(); + void updateSelectedState(bool state); - private: - ConvItemType m_Type; - InfoStatusType m_Status; - }; + private: + ConvItemType m_Type; + InfoStatusType m_Status; + }; } #endif /* ConvListViewItem_H_ */ diff --git a/src/Conversation/View/inc/ConvReplyListItem.h b/src/Conversation/View/inc/ConvReplyListItem.h index 5e04889..c2aa6db 100644 --- a/src/Conversation/View/inc/ConvReplyListItem.h +++ b/src/Conversation/View/inc/ConvReplyListItem.h @@ -20,22 +20,22 @@ #include "ListItem.h" namespace Msg { - class ConvReplyListItem - : public ListItem { - public: - ConvReplyListItem(); - virtual ~ConvReplyListItem(); + class ConvReplyListItem + : public ListItem { + public: + ConvReplyListItem(); + virtual ~ConvReplyListItem(); - protected: - void onAttached(ViewItem &item) override; + protected: + void onAttached(ViewItem &item) override; - private: - std::string getReplayText() const; - std::string getText(ListItem &item, const char *part) override; - Evas_Object *getContent(ListItem &item, const char *part) override; + private: + std::string getReplayText() const; + std::string getText(ListItem &item, const char *part) override; + Evas_Object *getContent(ListItem &item, const char *part) override; - Evas_Object *getReplyButton(); - }; + Evas_Object *getReplyButton(); + }; } #endif /* ConReplyListItem_h_ */ diff --git a/src/Conversation/View/inc/RecipListViewItem.h b/src/Conversation/View/inc/RecipListViewItem.h index 814b6b3..82c0674 100644 --- a/src/Conversation/View/inc/RecipListViewItem.h +++ b/src/Conversation/View/inc/RecipListViewItem.h @@ -20,32 +20,32 @@ #include "ListItem.h" namespace Msg { - class RecipListViewItem - : public ListItem { - public: - RecipListViewItem(); - virtual ~RecipListViewItem(); - - protected: - virtual std::string getRecipText() = 0; - - private: - std::string getText(ListItem &item, const char *part) override; - }; - - inline RecipListViewItem::RecipListViewItem() - : ListItem(ListItemStyle::create("1text")) - { - } - - inline RecipListViewItem::~RecipListViewItem(){}; - - inline std::string RecipListViewItem::getText(ListItem &item, const char *part) - { - if (!strcmp(part, "elm.text")) - return getRecipText(); - return ""; - } + class RecipListViewItem + : public ListItem { + public: + RecipListViewItem(); + virtual ~RecipListViewItem(); + + protected: + virtual std::string getRecipText() = 0; + + private: + std::string getText(ListItem &item, const char *part) override; + }; + + inline RecipListViewItem::RecipListViewItem() + : ListItem(ListItemStyle::create("1text")) + { + } + + inline RecipListViewItem::~RecipListViewItem(){}; + + inline std::string RecipListViewItem::getText(ListItem &item, const char *part) + { + if (!strcmp(part, "elm.text")) + return getRecipText(); + return ""; + } } #endif /* RecipListViewItem_h_ */ diff --git a/src/Conversation/View/src/BubbleAudioViewItem.cpp b/src/Conversation/View/src/BubbleAudioViewItem.cpp index 3f886ce..0efde1f 100644 --- a/src/Conversation/View/src/BubbleAudioViewItem.cpp +++ b/src/Conversation/View/src/BubbleAudioViewItem.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -22,17 +22,17 @@ using namespace Msg; BubbleAudioViewItem::BubbleAudioViewItem(Evas_Object *parent, BubbleEntity &entity) - : BubbleViewItem(parent, entity) - , m_pItemLayout(nullptr) + : BubbleViewItem(parent, entity) + , m_pItemLayout(nullptr) { - m_pItemLayout = addLayout(getEo(), CONV_LIST_BUBBLE_EDJ_PATH, "conv/list/audio_item"); - setMirrored(m_pItemLayout, false); - setContent(m_pItemLayout); + m_pItemLayout = addLayout(getEo(), CONV_LIST_BUBBLE_EDJ_PATH, "conv/list/audio_item"); + setMirrored(m_pItemLayout, false); + setContent(m_pItemLayout); - getAtspi().setReadingInfo(ELM_ACCESSIBLE_READING_INFO_TYPE_NAME); - getAtspi().setName(msg("IDS_MSG_BODY_ATTACHED_AUDIO")); + getAtspi().setReadingInfo(ELM_ACCESSIBLE_READING_INFO_TYPE_NAME); + getAtspi().setName(msg("IDS_MSG_BODY_ATTACHED_AUDIO")); - setMirrored(false); + setMirrored(false); } BubbleAudioViewItem::~BubbleAudioViewItem() @@ -41,27 +41,27 @@ BubbleAudioViewItem::~BubbleAudioViewItem() void BubbleAudioViewItem::setMainText(const std::string &text) { - elm_object_part_text_set(m_pItemLayout, "text.filename", text.c_str()); + elm_object_part_text_set(m_pItemLayout, "text.filename", text.c_str()); } void BubbleAudioViewItem::setTimeText(const std::string &text) { - elm_object_part_text_set(m_pItemLayout, "text.time", text.c_str()); + elm_object_part_text_set(m_pItemLayout, "text.time", text.c_str()); } void BubbleAudioViewItem::setProgress(const double progress) { - edje_object_part_drag_value_set(elm_layout_edje_get(m_pItemLayout), "rect.progress", progress, 0.0); + edje_object_part_drag_value_set(elm_layout_edje_get(m_pItemLayout), "rect.progress", progress, 0.0); } void BubbleAudioViewItem::setState(State state) { - const char *sig = state == PlayState ? "sound,play" : "sound,pause"; - emitSignal(m_pItemLayout, sig, ""); + const char *sig = state == PlayState ? "sound,play" : "sound,pause"; + emitSignal(m_pItemLayout, sig, ""); } void BubbleAudioViewItem::calculate() { - evas_object_smart_calculate(m_pItemLayout); - BubbleViewItem::calculate(); + evas_object_smart_calculate(m_pItemLayout); + BubbleViewItem::calculate(); } diff --git a/src/Conversation/View/src/BubbleIconTextLayoutItem.cpp b/src/Conversation/View/src/BubbleIconTextLayoutItem.cpp index 18e71b7..db50b11 100644 --- a/src/Conversation/View/src/BubbleIconTextLayoutItem.cpp +++ b/src/Conversation/View/src/BubbleIconTextLayoutItem.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -22,11 +22,11 @@ using namespace Msg; BubbleIconTextLayoutItem::BubbleIconTextLayoutItem(Evas_Object *parent, BubbleEntity &entity) - : BubbleViewItem(parent, entity) - , m_pIconTextLayout(nullptr) + : BubbleViewItem(parent, entity) + , m_pIconTextLayout(nullptr) { - m_pIconTextLayout = addLayout(getEo(), CONV_LIST_BUBBLE_EDJ_PATH, "conv/list/1icon_1text"); - setContent(m_pIconTextLayout); + m_pIconTextLayout = addLayout(getEo(), CONV_LIST_BUBBLE_EDJ_PATH, "conv/list/1icon_1text"); + setContent(m_pIconTextLayout); } BubbleIconTextLayoutItem::~BubbleIconTextLayoutItem() @@ -35,34 +35,34 @@ BubbleIconTextLayoutItem::~BubbleIconTextLayoutItem() void BubbleIconTextLayoutItem::setIcon(Evas_Object *icon) { - elm_object_part_content_set(m_pIconTextLayout, "icon", icon); + elm_object_part_content_set(m_pIconTextLayout, "icon", icon); } void BubbleIconTextLayoutItem::setMainText(const std::string &text) { - elm_object_part_text_set(m_pIconTextLayout, "main.text", text.c_str()); + elm_object_part_text_set(m_pIconTextLayout, "main.text", text.c_str()); - getAtspi().setReadingInfo(ELM_ACCESSIBLE_READING_INFO_TYPE_NAME); - getAtspi().setName(text); + getAtspi().setReadingInfo(ELM_ACCESSIBLE_READING_INFO_TYPE_NAME); + getAtspi().setName(text); } Evas_Object *BubbleIconTextLayoutItem::createIcon(Evas_Object *parent, const std::string &edjFileName) { - Evas_Object *icon = elm_icon_add(parent); - std::string resPath = PathUtils::getResourcePath(IMAGES_EDJ_PATH); - elm_image_file_set(icon, resPath.c_str(), edjFileName.c_str()); - evas_object_color_set(icon, 0, 0, 0, 255); - evas_object_show(icon); - return icon; + Evas_Object *icon = elm_icon_add(parent); + std::string resPath = PathUtils::getResourcePath(IMAGES_EDJ_PATH); + elm_image_file_set(icon, resPath.c_str(), edjFileName.c_str()); + evas_object_color_set(icon, 0, 0, 0, 255); + evas_object_show(icon); + return icon; } Evas_Object *BubbleIconTextLayoutItem::createIcon(const std::string &edjFileName) const { - return createIcon(*this, edjFileName); + return createIcon(*this, edjFileName); } void BubbleIconTextLayoutItem::calculate() { - evas_object_smart_calculate(m_pIconTextLayout); - BubbleViewItem::calculate(); + evas_object_smart_calculate(m_pIconTextLayout); + BubbleViewItem::calculate(); } diff --git a/src/Conversation/View/src/BubbleImageViewItem.cpp b/src/Conversation/View/src/BubbleImageViewItem.cpp index 9aac6c4..3e0e1da 100644 --- a/src/Conversation/View/src/BubbleImageViewItem.cpp +++ b/src/Conversation/View/src/BubbleImageViewItem.cpp @@ -21,12 +21,12 @@ using namespace Msg; BubbleImageViewItem::BubbleImageViewItem(BubbleEntity &entity, Evas_Object *parent, const std::string &imagePath) - : BubbleViewItem(parent, entity) + : BubbleViewItem(parent, entity) { - Evas_Object *img = createImage(parent, imagePath); - setContent(img); - getAtspi().setName(msg("WDS_ACCS_TBOPT_ATTACHED_IMAGE")); - getAtspi().setReadingInfo(ELM_ACCESSIBLE_READING_INFO_TYPE_NAME); + Evas_Object *img = createImage(parent, imagePath); + setContent(img); + getAtspi().setName(msg("WDS_ACCS_TBOPT_ATTACHED_IMAGE")); + getAtspi().setReadingInfo(ELM_ACCESSIBLE_READING_INFO_TYPE_NAME); } BubbleImageViewItem::~BubbleImageViewItem() @@ -35,21 +35,21 @@ BubbleImageViewItem::~BubbleImageViewItem() Evas_Object *BubbleImageViewItem::createImage(Evas_Object *parent, const std::string &path) { - int imageWidth = 0; - int imageHeight = 0; - - Evas_Object *image = elm_image_add(parent); - elm_image_prescale_set(image, maxWidth); - elm_image_aspect_fixed_set(image, true); - elm_image_file_set(image, path.c_str(), nullptr); - elm_image_object_size_get(image, &imageWidth, &imageHeight); - - double scale = maxWidth / (double)imageWidth; - imageWidth *= scale; - imageHeight *= scale; - - evas_object_size_hint_min_set(image, imageWidth, imageHeight); - evas_object_size_hint_align_set(image, 1.0, EVAS_HINT_FILL); - evas_object_show(image); - return image; + int imageWidth = 0; + int imageHeight = 0; + + Evas_Object *image = elm_image_add(parent); + elm_image_prescale_set(image, maxWidth); + elm_image_aspect_fixed_set(image, true); + elm_image_file_set(image, path.c_str(), nullptr); + elm_image_object_size_get(image, &imageWidth, &imageHeight); + + double scale = maxWidth / (double)imageWidth; + imageWidth *= scale; + imageHeight *= scale; + + evas_object_size_hint_min_set(image, imageWidth, imageHeight); + evas_object_size_hint_align_set(image, 1.0, EVAS_HINT_FILL); + evas_object_show(image); + return image; } diff --git a/src/Conversation/View/src/BubbleItemContainer.cpp b/src/Conversation/View/src/BubbleItemContainer.cpp index af9edc7..a68835d 100644 --- a/src/Conversation/View/src/BubbleItemContainer.cpp +++ b/src/Conversation/View/src/BubbleItemContainer.cpp @@ -22,19 +22,19 @@ using namespace Msg; namespace { - const int verticalBoxPads = 12; - const int horizontalBoxPads = 0; + const int verticalBoxPads = 12; + const int horizontalBoxPads = 0; } BubbleItemContainer::BubbleItemContainer(Evas_Object *parent) { - Evas_Object *box = elm_box_add(parent); - elm_box_homogeneous_set(box, false); - elm_box_horizontal_set(box, false); - elm_box_padding_set(box, ELM_SCALE_SIZE(horizontalBoxPads), ELM_SCALE_SIZE(verticalBoxPads)); - setEo(box); - expand(); - show(); + Evas_Object *box = elm_box_add(parent); + elm_box_homogeneous_set(box, false); + elm_box_horizontal_set(box, false); + elm_box_padding_set(box, ELM_SCALE_SIZE(horizontalBoxPads), ELM_SCALE_SIZE(verticalBoxPads)); + setEo(box); + expand(); + show(); } BubbleItemContainer::~BubbleItemContainer() @@ -43,13 +43,13 @@ BubbleItemContainer::~BubbleItemContainer() void BubbleItemContainer::append(BubbleViewItem &item, Message::Direction direction) { - evas_object_size_hint_align_set(item, 0.0, EVAS_HINT_FILL); - item.calculate(); - item.show(); - elm_box_pack_end(getEo(), item); + evas_object_size_hint_align_set(item, 0.0, EVAS_HINT_FILL); + item.calculate(); + item.show(); + elm_box_pack_end(getEo(), item); } void BubbleItemContainer::go() { - elm_box_recalculate(getEo()); + elm_box_recalculate(getEo()); } diff --git a/src/Conversation/View/src/BubbleSubjectViewItem.cpp b/src/Conversation/View/src/BubbleSubjectViewItem.cpp index 296bb1d..257df36 100644 --- a/src/Conversation/View/src/BubbleSubjectViewItem.cpp +++ b/src/Conversation/View/src/BubbleSubjectViewItem.cpp @@ -23,12 +23,12 @@ using namespace Msg; BubbleSubjectViewItem::BubbleSubjectViewItem(BubbleEntity &entity, Evas_Object *parent) - : BubbleViewItem(parent, entity, false) - , m_pTextLayout(nullptr) + : BubbleViewItem(parent, entity, false) + , m_pTextLayout(nullptr) { - m_pTextLayout = addLayout(getEo(), CONV_LIST_BUBBLE_EDJ_PATH, "conv/list/bubble_subject_item"); - setContent(m_pTextLayout); - getAtspi().canHighlight(false); + m_pTextLayout = addLayout(getEo(), CONV_LIST_BUBBLE_EDJ_PATH, "conv/list/bubble_subject_item"); + setContent(m_pTextLayout); + getAtspi().canHighlight(false); } BubbleSubjectViewItem::~BubbleSubjectViewItem() @@ -37,12 +37,12 @@ BubbleSubjectViewItem::~BubbleSubjectViewItem() void BubbleSubjectViewItem::setText(const std::string &text) { - View::setContent(m_pTextLayout, BubbleTextViewItem::createText(m_pTextLayout, text), "text.swl"); + View::setContent(m_pTextLayout, BubbleTextViewItem::createText(m_pTextLayout, text), "text.swl"); } void BubbleSubjectViewItem::calculate() { - evas_object_smart_calculate(m_pTextLayout); - BubbleViewItem::calculate(); + evas_object_smart_calculate(m_pTextLayout); + BubbleViewItem::calculate(); } diff --git a/src/Conversation/View/src/BubbleTextViewItem.cpp b/src/Conversation/View/src/BubbleTextViewItem.cpp index d2f07cb..2b586d8 100644 --- a/src/Conversation/View/src/BubbleTextViewItem.cpp +++ b/src/Conversation/View/src/BubbleTextViewItem.cpp @@ -24,10 +24,10 @@ using namespace Msg; const std::string textColorBlack = "#000"; BubbleTextViewItem::BubbleTextViewItem(BubbleEntity &entity, Evas_Object *parent, const std::string &text) - : BubbleViewItem(parent, entity, false) + : BubbleViewItem(parent, entity, false) { - setContent(createText(*this, text)); - getAtspi().canHighlight(false); + setContent(createText(*this, text)); + getAtspi().canHighlight(false); } BubbleTextViewItem::~BubbleTextViewItem() @@ -36,31 +36,31 @@ BubbleTextViewItem::~BubbleTextViewItem() Evas_Object *BubbleTextViewItem::createText(Evas_Object *parent, const std::string &text) { - if (text.empty()) - return nullptr; + if (text.empty()) + return nullptr; - std::string resText = TextDecorator::make(text, textColorBlack); + std::string resText = TextDecorator::make(text, textColorBlack); - Evas_Object *label = elm_label_add(parent); - elm_object_style_set(label, "conv_bubble"); + Evas_Object *label = elm_label_add(parent); + elm_object_style_set(label, "conv_bubble"); - elm_label_line_wrap_set(label, ELM_WRAP_MIXED); - elm_object_part_text_set(label, nullptr, resText.c_str()); - evas_object_show(label); + elm_label_line_wrap_set(label, ELM_WRAP_MIXED); + elm_object_part_text_set(label, nullptr, resText.c_str()); + evas_object_show(label); - Atspi ao = Atspi(label); - ao.setName(text); - ao.setReadingInfo(ELM_ACCESSIBLE_READING_INFO_TYPE_NAME); + Atspi ao = Atspi(label); + ao.setName(text); + ao.setReadingInfo(ELM_ACCESSIBLE_READING_INFO_TYPE_NAME); - Evas_Object *edjeLabel = elm_layout_edje_get(label); - const Evas_Object *textBlock = edje_object_part_object_get(edjeLabel, "elm.text"); + Evas_Object *edjeLabel = elm_layout_edje_get(label); + const Evas_Object *textBlock = edje_object_part_object_get(edjeLabel, "elm.text"); - Evas_Coord ww = 0; - Evas_Coord hh = 0; + Evas_Coord ww = 0; + Evas_Coord hh = 0; - evas_object_textblock_size_native_get(textBlock, &ww, &hh); - int wrapWidth = ww > maxWidth ? maxWidth : ww; - elm_label_wrap_width_set(label, wrapWidth); + evas_object_textblock_size_native_get(textBlock, &ww, &hh); + int wrapWidth = ww > maxWidth ? maxWidth : ww; + elm_label_wrap_width_set(label, wrapWidth); - return label; + return label; } diff --git a/src/Conversation/View/src/BubbleViewItem.cpp b/src/Conversation/View/src/BubbleViewItem.cpp index 40bfa98..94f9667 100644 --- a/src/Conversation/View/src/BubbleViewItem.cpp +++ b/src/Conversation/View/src/BubbleViewItem.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -21,17 +21,17 @@ using namespace Msg; BubbleViewItem::BubbleViewItem(Evas_Object *parent, BubbleEntity &entity, bool addGestureLayer) - : m_Entity(entity) - , m_pListener(nullptr) + : m_Entity(entity) + , m_pListener(nullptr) { - setEo(addLayout(parent, CONV_LIST_BUBBLE_EDJ_PATH, "conv/list/bubble_item_bg")); - if (addGestureLayer) - View::setContent(createGestureRect(getEo()), "swl.gesture"); - evas_object_size_hint_align_set(getEo(), 1.0, EVAS_HINT_FILL); - - Atspi ao = registerAccessObj(parent); - ao.canHighlight(true); - ao.setActionCb(ELM_ACCESS_ACTION_ACTIVATE, makeCbFirst(&BubbleViewItem::onScreenReaderClicked), this); + setEo(addLayout(parent, CONV_LIST_BUBBLE_EDJ_PATH, "conv/list/bubble_item_bg")); + if (addGestureLayer) + View::setContent(createGestureRect(getEo()), "swl.gesture"); + evas_object_size_hint_align_set(getEo(), 1.0, EVAS_HINT_FILL); + + Atspi ao = registerAccessObj(parent); + ao.canHighlight(true); + ao.setActionCb(ELM_ACCESS_ACTION_ACTIVATE, makeCbFirst(&BubbleViewItem::onScreenReaderClicked), this); } BubbleViewItem::~BubbleViewItem() @@ -40,74 +40,74 @@ BubbleViewItem::~BubbleViewItem() Atspi BubbleViewItem::getAtspi() const { - return getAccessObj(); + return getAccessObj(); } void BubbleViewItem::setListener(IBubbleViewItemListener *l) { - m_pListener = l; + m_pListener = l; } BubbleEntity &BubbleViewItem::getEntity() { - return m_Entity; + return m_Entity; } void BubbleViewItem::setContent(Evas_Object *obj) { - View::setContent(obj, "content"); + View::setContent(obj, "content"); } Evas_Object *BubbleViewItem::getContent() const { - return View::getContent("content"); + return View::getContent("content"); } void BubbleViewItem::attachGestureTapLayer(Evas_Object *parent, Evas_Object *obj) { - const int tapFingerSize = 12; - - Evas_Object *layer = elm_gesture_layer_add(parent); - evas_object_show(layer); - elm_gesture_layer_attach(layer, obj); - elm_gesture_layer_tap_finger_size_set(layer, ELM_SCALE_SIZE(tapFingerSize)); - - elm_gesture_layer_cb_add( - layer, - ELM_GESTURE_N_TAPS, - ELM_GESTURE_STATE_END, - [](void *data, void *event_info)->Evas_Event_Flags - { - auto *self = static_cast(data); - if (self) - self->emitActionEvent(); - return EVAS_EVENT_FLAG_NONE; - }, - this); + const int tapFingerSize = 12; + + Evas_Object *layer = elm_gesture_layer_add(parent); + evas_object_show(layer); + elm_gesture_layer_attach(layer, obj); + elm_gesture_layer_tap_finger_size_set(layer, ELM_SCALE_SIZE(tapFingerSize)); + + elm_gesture_layer_cb_add( + layer, + ELM_GESTURE_N_TAPS, + ELM_GESTURE_STATE_END, + [](void *data, void *event_info)->Evas_Event_Flags + { + auto *self = static_cast(data); + if (self) + self->emitActionEvent(); + return EVAS_EVENT_FLAG_NONE; + }, + this); } Evas_Object *BubbleViewItem::createGestureRect(Evas_Object *parent) { - Evas *e = evas_object_rectangle_add(evas_object_evas_get(parent)); - Evas_Object *rect = evas_object_rectangle_add(e); - evas_object_color_set(rect, 0, 0, 0, 0); - attachGestureTapLayer(parent, rect); - return rect; + Evas *e = evas_object_rectangle_add(evas_object_evas_get(parent)); + Evas_Object *rect = evas_object_rectangle_add(e); + evas_object_color_set(rect, 0, 0, 0, 0); + attachGestureTapLayer(parent, rect); + return rect; } void BubbleViewItem::calculate() { - evas_object_smart_calculate(getEo()); + evas_object_smart_calculate(getEo()); } void BubbleViewItem::emitActionEvent() { - if (m_pListener) - m_pListener->onAction(*this); + if (m_pListener) + m_pListener->onAction(*this); } Eina_Bool BubbleViewItem::onScreenReaderClicked(Evas_Object *obj, Elm_Access_Action_Info *action_info) { - emitActionEvent(); - return true; + emitActionEvent(); + return true; } diff --git a/src/Conversation/View/src/ConvDateLineListItem.cpp b/src/Conversation/View/src/ConvDateLineListItem.cpp index e78c3a4..6a06f43 100644 --- a/src/Conversation/View/src/ConvDateLineListItem.cpp +++ b/src/Conversation/View/src/ConvDateLineListItem.cpp @@ -21,20 +21,20 @@ using namespace Msg; namespace { - const char *datePart = "elm.text"; + const char *datePart = "elm.text"; } ConvDateLineListItem::ConvDateLineListItem(time_t dateTime) - : ListItem(ListItemStyle::create("dateline")) - , m_DateTime(dateTime) + : ListItem(ListItemStyle::create("dateline")) + , m_DateTime(dateTime) { - update(); + update(); } ConvDateLineListItem::ConvDateLineListItem(time_t dateTime, std::string dateTimeStr) - : ListItem(ListItemStyle::create("dateline")) - , m_DateTime(dateTime) - , m_DateTimeStr(std::move(dateTimeStr)) + : ListItem(ListItemStyle::create("dateline")) + , m_DateTime(dateTime) + , m_DateTimeStr(std::move(dateTimeStr)) { } @@ -44,18 +44,18 @@ ConvDateLineListItem::~ConvDateLineListItem() void ConvDateLineListItem::update() { - m_DateTimeStr = TimeUtils::makeBubbleDateLineString(m_DateTime); + m_DateTimeStr = TimeUtils::makeBubbleDateLineString(m_DateTime); } const std::string &ConvDateLineListItem::getDateTimeStr() const { - return m_DateTimeStr; + return m_DateTimeStr; } std::string ConvDateLineListItem::getText(ListItem &item, const char *part) { - if (!strcmp(part, datePart)) - return m_DateTimeStr; + if (!strcmp(part, datePart)) + return m_DateTimeStr; - return ""; + return ""; } diff --git a/src/Conversation/View/src/ConvListViewItem.cpp b/src/Conversation/View/src/ConvListViewItem.cpp index 6dc5ad2..dd7c2cd 100644 --- a/src/Conversation/View/src/ConvListViewItem.cpp +++ b/src/Conversation/View/src/ConvListViewItem.cpp @@ -20,23 +20,23 @@ using namespace Msg; namespace { - ListItemStyleRef sentStyle = ListItemStyle::create("sentbubble"); - ListItemStyleRef receiveStyle = ListItemStyle::create("receivebubble"); + ListItemStyleRef sentStyle = ListItemStyle::create("sentbubble"); + ListItemStyleRef receiveStyle = ListItemStyle::create("receivebubble"); - const char *bubbleContentPart = "bubble.content"; - const char *timeTextPart = "info.time"; - const char *msgType = "msg.type"; - const char *infoStatus = "info.status"; + const char *bubbleContentPart = "bubble.content"; + const char *timeTextPart = "info.time"; + const char *msgType = "msg.type"; + const char *infoStatus = "info.status"; - double messageLoadingSize = 29.0; + double messageLoadingSize = 29.0; } ConvListViewItem::ConvListViewItem(ConvItemType type) - : ListItem() - , m_Type(type) - , m_Status(NoneStatus) + : ListItem() + , m_Type(type) + , m_Status(NoneStatus) { - updateItemType(type); + updateItemType(type); } ConvListViewItem::~ConvListViewItem() @@ -45,121 +45,121 @@ ConvListViewItem::~ConvListViewItem() void ConvListViewItem::setCheckedState(bool state, bool updateUi) { - updateContentBlocker(); - updateSelectedState(state); + updateContentBlocker(); + updateSelectedState(state); } void ConvListViewItem::setInfoStatus(InfoStatusType statusType) { - if (statusType == m_Status) - return; + if (statusType == m_Status) + return; - m_Status = statusType; + m_Status = statusType; - if (getElmObjItem()) { - updateFields(infoStatus, ELM_GENLIST_ITEM_FIELD_CONTENT); - updateFields(timeTextPart, ELM_GENLIST_ITEM_FIELD_TEXT); - updateFields(msgType, ELM_GENLIST_ITEM_FIELD_TEXT); - } + if (getElmObjItem()) { + updateFields(infoStatus, ELM_GENLIST_ITEM_FIELD_CONTENT); + updateFields(timeTextPart, ELM_GENLIST_ITEM_FIELD_TEXT); + updateFields(msgType, ELM_GENLIST_ITEM_FIELD_TEXT); + } } ConvListViewItem::InfoStatusType ConvListViewItem::getStatusType() const { - return m_Status; + return m_Status; } std::string ConvListViewItem::getText(ListItem &item, const char *part) { - if (m_Status == NoneStatus || m_Type == Received) { - if (!strcmp(part, timeTextPart)) - return getTime(); - else if (!strcmp(part, msgType)) - return getMsgType(); - } + if (m_Status == NoneStatus || m_Type == Received) { + if (!strcmp(part, timeTextPart)) + return getTime(); + else if (!strcmp(part, msgType)) + return getMsgType(); + } - return ""; + return ""; } bool ConvListViewItem::isCheckable() const { - return true; + return true; } Evas_Object *ConvListViewItem::getContent(ListItem &item, const char *part) { - if (!strcmp(part, bubbleContentPart)) { - return getBubbleContent(); - } else if (!strcmp(part, infoStatus)) { - if (m_Type == Sent) { - if (m_Status == ProgressStatus) - return createProgress(); - if (m_Status == FailedStatus) - return createFailedButton(); - } - } + if (!strcmp(part, bubbleContentPart)) { + return getBubbleContent(); + } else if (!strcmp(part, infoStatus)) { + if (m_Type == Sent) { + if (m_Status == ProgressStatus) + return createProgress(); + if (m_Status == FailedStatus) + return createFailedButton(); + } + } - return nullptr; + return nullptr; } Evas_Object *ConvListViewItem::createProgress() { - Evas_Object *progressbar = elm_progressbar_add(*getOwner()); - elm_object_style_set(progressbar, "process_small"); - evas_object_smart_calculate(progressbar); - int w = 0; - int h = 0; - evas_object_size_hint_min_get(progressbar, &w, &h); - int max = std::max(w, h); - if (max != 0) - elm_object_scale_set(progressbar, messageLoadingSize / max); - evas_object_show(progressbar); - elm_progressbar_pulse(progressbar, EINA_TRUE); - Atspi(progressbar).canHighlight(false); - return progressbar; + Evas_Object *progressbar = elm_progressbar_add(*getOwner()); + elm_object_style_set(progressbar, "process_small"); + evas_object_smart_calculate(progressbar); + int w = 0; + int h = 0; + evas_object_size_hint_min_get(progressbar, &w, &h); + int max = std::max(w, h); + if (max != 0) + elm_object_scale_set(progressbar, messageLoadingSize / max); + evas_object_show(progressbar); + elm_progressbar_pulse(progressbar, EINA_TRUE); + Atspi(progressbar).canHighlight(false); + return progressbar; } Evas_Object *ConvListViewItem::createFailedButton() { - return View::addLayout(*getOwner(), ICONS_EDJ_PATH, "conv/fail_icon"); + return View::addLayout(*getOwner(), ICONS_EDJ_PATH, "conv/fail_icon"); } void ConvListViewItem::updateContent() { - updateFields(bubbleContentPart, ELM_GENLIST_ITEM_FIELD_CONTENT); + updateFields(bubbleContentPart, ELM_GENLIST_ITEM_FIELD_CONTENT); } void ConvListViewItem::updateItemType(ConvItemType type) { - m_Type = type; - switch (type) { - case Sent: - setStyle(sentStyle); - break; - case Received: - setStyle(receiveStyle); - break; - default: - break; - } + m_Type = type; + switch (type) { + case Sent: + setStyle(sentStyle); + break; + case Received: + setStyle(receiveStyle); + break; + default: + break; + } } void ConvListViewItem::updateContentBlocker() { - const char *sig = getOwner()->getCheckMode() ? "block_event" : "unblock_event"; - emitSignal(sig, ""); + const char *sig = getOwner()->getCheckMode() ? "block_event" : "unblock_event"; + emitSignal(sig, ""); } void ConvListViewItem::updateSelectedState(bool state) { - const char *sig = state ? "show_selected" : "hide_selected"; - ListItem::setCheckedState(state, false); - emitSignal(sig, ""); + const char *sig = state ? "show_selected" : "hide_selected"; + ListItem::setCheckedState(state, false); + emitSignal(sig, ""); } void ConvListViewItem::onRealized(ListItem &item) { - // Update CheckedState - setCheckedState(getCheckedState(), true); + // Update CheckedState + setCheckedState(getCheckedState(), true); } void ConvListViewItem::onUnrealized(ListItem &item) diff --git a/src/Conversation/View/src/ConvReplyListItem.cpp b/src/Conversation/View/src/ConvReplyListItem.cpp index 0f459a9..ce72923 100644 --- a/src/Conversation/View/src/ConvReplyListItem.cpp +++ b/src/Conversation/View/src/ConvReplyListItem.cpp @@ -20,12 +20,12 @@ using namespace Msg; namespace { - const char *replyText = "reply.text"; - const char *replyContent = "swallow.reply"; + const char *replyText = "reply.text"; + const char *replyContent = "swallow.reply"; } ConvReplyListItem::ConvReplyListItem() - : ListItem(ListItemStyle::create("reply")) + : ListItem(ListItemStyle::create("reply")) { } @@ -35,38 +35,38 @@ ConvReplyListItem::~ConvReplyListItem() std::string ConvReplyListItem::getReplayText() const { - return msg("WDS_MSG_OPT_REPLY_ABB"); + return msg("WDS_MSG_OPT_REPLY_ABB"); } std::string ConvReplyListItem::getText(ListItem &item, const char *part) { - if (!strcmp(part, replyText)) - return getReplayText(); + if (!strcmp(part, replyText)) + return getReplayText(); - return ""; + return ""; } Evas_Object *ConvReplyListItem::getContent(ListItem &item, const char *part) { - if (!strcmp(part, replyContent)) - return getReplyButton(); + if (!strcmp(part, replyContent)) + return getReplyButton(); - return nullptr; + return nullptr; } Evas_Object *ConvReplyListItem::getReplyButton() { - Evas_Object *btn = View::addIconButton(*getOwner(), "conv/reply_icon"); + Evas_Object *btn = View::addIconButton(*getOwner(), "conv/reply_icon"); - Atspi AoBtn = Atspi(btn); - AoBtn.setName(getReplayText()); - AoBtn.setRole(ELM_ATSPI_ROLE_PUSH_BUTTON); - AoBtn.setReadingInfo((Elm_Accessible_Reading_Info_Type)(ELM_ACCESSIBLE_READING_INFO_TYPE_NAME | ELM_ACCESSIBLE_READING_INFO_TYPE_ROLE)); + Atspi AoBtn = Atspi(btn); + AoBtn.setName(getReplayText()); + AoBtn.setRole(ELM_ATSPI_ROLE_PUSH_BUTTON); + AoBtn.setReadingInfo((Elm_Accessible_Reading_Info_Type)(ELM_ACCESSIBLE_READING_INFO_TYPE_NAME | ELM_ACCESSIBLE_READING_INFO_TYPE_ROLE)); - return btn; + return btn; } void ConvReplyListItem::onAttached(ViewItem &item) { - getAtspi().canHighlight(false); + getAtspi().canHighlight(false); } diff --git a/src/MainApp/MainApp.cpp b/src/MainApp/MainApp.cpp index 7cdbd63..c16f177 100644 --- a/src/MainApp/MainApp.cpp +++ b/src/MainApp/MainApp.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -30,84 +30,84 @@ MainApp::~MainApp() int MainApp::start(int argc, char *argv[]) { - ui_app_lifecycle_callback_s cbs = {}; - - cbs.app_control = [](app_control_h app_control, void *user_data) - { - static_cast(user_data)->onAppControl(app_control); - }; - - cbs.create = [](void *user_data)->bool - { - return static_cast(user_data)->onAppCreate(); - }; - - cbs.pause = [](void *user_data) - { - static_cast(user_data)->onAppPause(); - }; - - cbs.resume = [](void *user_data) - { - static_cast(user_data)->onAppResume(); - }; - - cbs.terminate = [](void *user_data) - { - static_cast(user_data)->onAppTerminate(); - }; - - app_event_handler_h handlers[3] = {}; - ui_app_add_event_handler(&handlers[0], APP_EVENT_LOW_BATTERY, makeCbLast(&MainApp::onLowBattery), this); - ui_app_add_event_handler(&handlers[1], APP_EVENT_LANGUAGE_CHANGED, makeCbLast(&MainApp::onLanguageChanged), this); - ui_app_add_event_handler(&handlers[2], APP_EVENT_REGION_FORMAT_CHANGED, makeCbLast(&MainApp::onRegionChanged), this); - - return ui_app_main(argc, argv, &cbs, this); + ui_app_lifecycle_callback_s cbs = {}; + + cbs.app_control = [](app_control_h app_control, void *user_data) + { + static_cast(user_data)->onAppControl(app_control); + }; + + cbs.create = [](void *user_data)->bool + { + return static_cast(user_data)->onAppCreate(); + }; + + cbs.pause = [](void *user_data) + { + static_cast(user_data)->onAppPause(); + }; + + cbs.resume = [](void *user_data) + { + static_cast(user_data)->onAppResume(); + }; + + cbs.terminate = [](void *user_data) + { + static_cast(user_data)->onAppTerminate(); + }; + + app_event_handler_h handlers[3] = {}; + ui_app_add_event_handler(&handlers[0], APP_EVENT_LOW_BATTERY, makeCbLast(&MainApp::onLowBattery), this); + ui_app_add_event_handler(&handlers[1], APP_EVENT_LANGUAGE_CHANGED, makeCbLast(&MainApp::onLanguageChanged), this); + ui_app_add_event_handler(&handlers[2], APP_EVENT_REGION_FORMAT_CHANGED, makeCbLast(&MainApp::onRegionChanged), this); + + return ui_app_main(argc, argv, &cbs, this); } void MainApp::terminate() { - ui_app_exit(); + ui_app_exit(); } bool MainApp::onAppCreate() { - TRACE; + TRACE; - std::string localePath(PathUtils::getLocalePath()); - if (!localePath.empty()) - bindtextdomain(PROJECT_NAME, localePath.c_str()); + std::string localePath(PathUtils::getLocalePath()); + if (!localePath.empty()) + bindtextdomain(PROJECT_NAME, localePath.c_str()); - elm_app_base_scale_set(1.3); - elm_config_accel_preference_set("3d"); - updateCharacterOrientation(); + elm_app_base_scale_set(1.3); + elm_config_accel_preference_set("3d"); + updateCharacterOrientation(); - return App::onCreate(); + return App::onCreate(); } void MainApp::onAppTerminate() { - App::onTerminate(); + App::onTerminate(); } void MainApp::onAppPause() { - App::onPause(); + App::onPause(); } void MainApp::onAppResume() { - App::onResume(); + App::onResume(); } void MainApp::onAppControl(app_control_h app_control) { - App::onAppControl(app_control); + App::onAppControl(app_control); } void MainApp::onLanguageChanged(app_event_info_h appEvent) { - App::onLanguageChanged(appEvent); + App::onLanguageChanged(appEvent); } void MainApp::onLowBattery(app_event_info_h appEvent) diff --git a/src/MainApp/MainApp.h b/src/MainApp/MainApp.h index d128de3..c83a360 100644 --- a/src/MainApp/MainApp.h +++ b/src/MainApp/MainApp.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -25,31 +25,31 @@ namespace Msg { - class StandardWindow; - class NaviFrameController; - - class MainApp - : public App - { - public: - MainApp(); - virtual ~MainApp(); - - int start(int argc, char *argv[]); - - private: - void terminate() override; - - // App cbs: - bool onAppCreate(); - void onAppTerminate(); - void onAppPause(); - void onAppResume(); - void onAppControl(app_control_h app_control); - void onLanguageChanged(app_event_info_h appEvent); - void onLowBattery(app_event_info_h appEvent); - void onRegionChanged(app_event_info_h appEvent); - }; + class StandardWindow; + class NaviFrameController; + + class MainApp + : public App + { + public: + MainApp(); + virtual ~MainApp(); + + int start(int argc, char *argv[]); + + private: + void terminate() override; + + // App cbs: + bool onAppCreate(); + void onAppTerminate(); + void onAppPause(); + void onAppResume(); + void onAppControl(app_control_h app_control); + void onLanguageChanged(app_event_info_h appEvent); + void onLowBattery(app_event_info_h appEvent); + void onRegionChanged(app_event_info_h appEvent); + }; } #endif /* MainApp_h_ */ diff --git a/src/MainApp/main.cpp b/src/MainApp/main.cpp index bbc237b..2b91065 100644 --- a/src/MainApp/main.cpp +++ b/src/MainApp/main.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -24,9 +24,9 @@ using namespace Msg; EXPORT_API int main(int argc, char *argv[]) { - std::cout << "Message start" << std::endl; // Test for entrance to the main function (use stdout) - TRACE; - MainApp app; - int ret = app.start(argc, argv); - return ret; + std::cout << "Message start" << std::endl; // Test for entrance to the main function (use stdout) + TRACE; + MainApp app; + int ret = app.start(argc, argv); + return ret; } diff --git a/src/MsgThread/Controller/inc/MsgThreadFrame.h b/src/MsgThread/Controller/inc/MsgThreadFrame.h index c8913fd..3aec75a 100644 --- a/src/MsgThread/Controller/inc/MsgThreadFrame.h +++ b/src/MsgThread/Controller/inc/MsgThreadFrame.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -24,82 +24,82 @@ namespace Msg { - class DefaultLayout; - class BottomButton; - class SelectButton; - class MoreOption; - class CtxPopup; - class SelectCtxPopup; - - class MsgThreadFrame - : public FrameController - , private IThreadListListener { - - public: - MsgThreadFrame(NaviFrameController &parent); - virtual ~MsgThreadFrame(); - - private: - enum Mode { - InitMode, - NormalMode, - DeleteMode - }; - - private: - void prepareThreadList(); - void prepareMainLayout(); - void prepareMoreOption(); - void prepareDeleteViews(); - void updateDeleteViews(); - - void setMode(Mode mode); - void setDeleteMode(); - void setNormalMode(); - - void showSelectPopup(); - void showDelPopup(); - void hideSelectPopup(); - void navigateToConvFrame(ThreadId id); - void composeMsg(); - - private: - // NaviFrameItem: - void onAttached(ViewItem &item) override; - - // Hw buttons: - void onHwBackButtonPreessed(Evas_Object *obj, void *event); - - // Delete mode cb: - void onDelButtonClicked(Evas_Object *obj, void *event); - void onSelectButtonClicked(Evas_Object *obj, void *event); - void onSelectAllButtonClicked(CtxPopupItem &item); - void onDeselectAllButtonClicked(CtxPopupItem &item); - void onSelectPopupDel(Evas *e, Evas_Object *obj, void *event_info); - - // More option: - void onNewMessageClicked(MoreOption &obj); - void onDeleteClicked(MoreOption &obj); - void onSettingsClicked(MoreOption &obj); - - // IThreadListListener: - void onItemSelected(ThreadId id) override; - void onItemRequestDeleteMode(ThreadListItem &item) override; - void onChanged(ThreadList &list) override; - void onItemChecked(ThreadListItem &item) override; - void onComposeButtonClicked(ThreadList &list) override; - void onContactsButtonClicked(ThreadList &list) override; - - private: - DefaultLayout *m_pLayout; - MoreOption *m_pMoreOption; - BottomButton *m_pDeleteButton; - SelectButton *m_pSelectButton; - ThreadList *m_pThreadList; - ContactViewer m_ContactViewer; - SelectCtxPopup *m_pSelectPopup; - Mode m_Mode; - }; + class DefaultLayout; + class BottomButton; + class SelectButton; + class MoreOption; + class CtxPopup; + class SelectCtxPopup; + + class MsgThreadFrame + : public FrameController + , private IThreadListListener { + + public: + MsgThreadFrame(NaviFrameController &parent); + virtual ~MsgThreadFrame(); + + private: + enum Mode { + InitMode, + NormalMode, + DeleteMode + }; + + private: + void prepareThreadList(); + void prepareMainLayout(); + void prepareMoreOption(); + void prepareDeleteViews(); + void updateDeleteViews(); + + void setMode(Mode mode); + void setDeleteMode(); + void setNormalMode(); + + void showSelectPopup(); + void showDelPopup(); + void hideSelectPopup(); + void navigateToConvFrame(ThreadId id); + void composeMsg(); + + private: + // NaviFrameItem: + void onAttached(ViewItem &item) override; + + // Hw buttons: + void onHwBackButtonPreessed(Evas_Object *obj, void *event); + + // Delete mode cb: + void onDelButtonClicked(Evas_Object *obj, void *event); + void onSelectButtonClicked(Evas_Object *obj, void *event); + void onSelectAllButtonClicked(CtxPopupItem &item); + void onDeselectAllButtonClicked(CtxPopupItem &item); + void onSelectPopupDel(Evas *e, Evas_Object *obj, void *event_info); + + // More option: + void onNewMessageClicked(MoreOption &obj); + void onDeleteClicked(MoreOption &obj); + void onSettingsClicked(MoreOption &obj); + + // IThreadListListener: + void onItemSelected(ThreadId id) override; + void onItemRequestDeleteMode(ThreadListItem &item) override; + void onChanged(ThreadList &list) override; + void onItemChecked(ThreadListItem &item) override; + void onComposeButtonClicked(ThreadList &list) override; + void onContactsButtonClicked(ThreadList &list) override; + + private: + DefaultLayout *m_pLayout; + MoreOption *m_pMoreOption; + BottomButton *m_pDeleteButton; + SelectButton *m_pSelectButton; + ThreadList *m_pThreadList; + ContactViewer m_ContactViewer; + SelectCtxPopup *m_pSelectPopup; + Mode m_Mode; + }; } #endif /* ThreadFrame_h_ */ diff --git a/src/MsgThread/Controller/inc/ThreadList.h b/src/MsgThread/Controller/inc/ThreadList.h index 7681624..c49254b 100644 --- a/src/MsgThread/Controller/inc/ThreadList.h +++ b/src/MsgThread/Controller/inc/ThreadList.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -30,86 +30,86 @@ #include namespace Msg { - class IThreadListListener; - class ThreadListItem; - class App; - - class ThreadList - : public ListView - , private IMsgStorageListener - , private IListViewListener - , private IContactManagerListener - , private ISystemSettingsManager - , private IThreadComposeListViewItemListener { - - public: - ThreadList(DefaultLayout &parent); - virtual ~ThreadList(); - - void setListener(IThreadListListener *l); - void setDeleteMode(bool value); - bool isDeleteModeEnabled() const; - bool deleteCheckedItems(); - bool isEmpty() const; - - private: - // IMsgStorageListener: - void onMsgStorageThreadUpdate(const ThreadId &threadId) override; - void onMsgStorageThreadInsert(const ThreadId &threadId) override; - void onMsgStorageThreadDelete(const ThreadId &threadId) override; - - // IContactManagerListener: - void onContactChanged() override; - - // IListViewListener: - void onListItemSelected(ListItem &listItem) override; - void onListItemChecked(ListItem &listItem) override; - void onListItemLongPressed(ListItem &listItem) override; - - // ISystemSettingsManager: - void onTimeFormatChanged() override; - void onLanguageChanged() override; - - // IThreadComposeListViewItemListener: - void onComposeButtonClicked() override; - void onContactsButtonClicked() override; - - private: - void checkHandler(ThreadListItem &item); - void fillList(); - void deleteItems(); - void updateItems(const MsgIdList &idList); - void updateLangInfo(); - void updateItem(ThreadListItem &item); - void showNoContent(bool value); - void insertItem(ThreadId id); - void deleteItem(ThreadId id); - void navigateTo(ThreadListItem &item); - ThreadListItem *getItem(ThreadId id) const; - bool isAllThreadListItemChecked() const; - std::set getThreadIdSet(const MsgIdList &idList); - static int cmpFunc(const ListItem &item1, const ListItem &item2); - - private: - IThreadListListener *m_pListener; - App &m_App; - bool m_DeleteMode; - ThreadComposeListViewItem *m_ComposeItem; - PaddingListViewItem *m_pTopPadItem; - PaddingListViewItem *m_pBottomPadItem; - NoContentListViewItem *m_pNoContentItem; - }; - - class IThreadListListener { - public: - virtual ~IThreadListListener() {} - virtual void onItemSelected(ThreadId id) {}; - virtual void onItemRequestDeleteMode(ThreadListItem &item) {}; - virtual void onChanged(ThreadList &list) {} - virtual void onItemChecked(ThreadListItem &item) {} - virtual void onComposeButtonClicked(ThreadList &list) {}; - virtual void onContactsButtonClicked(ThreadList &list) {}; - }; + class IThreadListListener; + class ThreadListItem; + class App; + + class ThreadList + : public ListView + , private IMsgStorageListener + , private IListViewListener + , private IContactManagerListener + , private ISystemSettingsManager + , private IThreadComposeListViewItemListener { + + public: + ThreadList(DefaultLayout &parent); + virtual ~ThreadList(); + + void setListener(IThreadListListener *l); + void setDeleteMode(bool value); + bool isDeleteModeEnabled() const; + bool deleteCheckedItems(); + bool isEmpty() const; + + private: + // IMsgStorageListener: + void onMsgStorageThreadUpdate(const ThreadId &threadId) override; + void onMsgStorageThreadInsert(const ThreadId &threadId) override; + void onMsgStorageThreadDelete(const ThreadId &threadId) override; + + // IContactManagerListener: + void onContactChanged() override; + + // IListViewListener: + void onListItemSelected(ListItem &listItem) override; + void onListItemChecked(ListItem &listItem) override; + void onListItemLongPressed(ListItem &listItem) override; + + // ISystemSettingsManager: + void onTimeFormatChanged() override; + void onLanguageChanged() override; + + // IThreadComposeListViewItemListener: + void onComposeButtonClicked() override; + void onContactsButtonClicked() override; + + private: + void checkHandler(ThreadListItem &item); + void fillList(); + void deleteItems(); + void updateItems(const MsgIdList &idList); + void updateLangInfo(); + void updateItem(ThreadListItem &item); + void showNoContent(bool value); + void insertItem(ThreadId id); + void deleteItem(ThreadId id); + void navigateTo(ThreadListItem &item); + ThreadListItem *getItem(ThreadId id) const; + bool isAllThreadListItemChecked() const; + std::set getThreadIdSet(const MsgIdList &idList); + static int cmpFunc(const ListItem &item1, const ListItem &item2); + + private: + IThreadListListener *m_pListener; + App &m_App; + bool m_DeleteMode; + ThreadComposeListViewItem *m_ComposeItem; + PaddingListViewItem *m_pTopPadItem; + PaddingListViewItem *m_pBottomPadItem; + NoContentListViewItem *m_pNoContentItem; + }; + + class IThreadListListener { + public: + virtual ~IThreadListListener() {} + virtual void onItemSelected(ThreadId id) {}; + virtual void onItemRequestDeleteMode(ThreadListItem &item) {}; + virtual void onChanged(ThreadList &list) {} + virtual void onItemChecked(ThreadListItem &item) {} + virtual void onComposeButtonClicked(ThreadList &list) {}; + virtual void onContactsButtonClicked(ThreadList &list) {}; + }; } #endif // ThreadList_h_ diff --git a/src/MsgThread/Controller/inc/ThreadListItem.h b/src/MsgThread/Controller/inc/ThreadListItem.h index 84a9734..271915b 100644 --- a/src/MsgThread/Controller/inc/ThreadListItem.h +++ b/src/MsgThread/Controller/inc/ThreadListItem.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -22,46 +22,46 @@ #include "ThreadListViewItem.h" namespace Msg { - class ThreadListItem - : public ThreadListViewItem { - public: - ThreadListItem(const MsgThreadItem &threadItem); - virtual ~ThreadListItem(); + class ThreadListItem + : public ThreadListViewItem { + public: + ThreadListItem(const MsgThreadItem &threadItem); + virtual ~ThreadListItem(); - ThreadId getThreadId() const; - using ThreadListViewItem::update; - void update(const MsgThreadItem &threadItem); - time_t getRawTime() const; - void updateTime(); - void updateContactInfo(); - void updateLangInfo(); + ThreadId getThreadId() const; + using ThreadListViewItem::update; + void update(const MsgThreadItem &threadItem); + time_t getRawTime() const; + void updateTime(); + void updateContactInfo(); + void updateLangInfo(); - protected: - void updateName(); - void updateName(const MsgAddressList &addressList); - void updateName(const MsgAddress &address, int addressesCount); - void updateName(const ContactAddress &address, int addressesCount); - void updateName(const std::string &address, int addressesCount); - void updateTime(time_t time); - void updateMessage(const MsgThreadItem &threadItem); - void updateMessage(const std::string &msg); + protected: + void updateName(); + void updateName(const MsgAddressList &addressList); + void updateName(const MsgAddress &address, int addressesCount); + void updateName(const ContactAddress &address, int addressesCount); + void updateName(const std::string &address, int addressesCount); + void updateTime(time_t time); + void updateMessage(const MsgThreadItem &threadItem); + void updateMessage(const std::string &msg); - private: - // ThreadListViewItem: - std::string getName() override; - std::string getMessage() override; - std::string getTime() override; - std::string getUnreadCount() override; + private: + // ThreadListViewItem: + std::string getName() override; + std::string getMessage() override; + std::string getTime() override; + std::string getUnreadCount() override; - private: - ThreadId m_ThreadId; - MsgAddressListRef m_AddressList; - std::string m_UnreadCount; - std::string m_Name; - std::string m_Message; - std::string m_Time; - time_t m_RawTime; - }; + private: + ThreadId m_ThreadId; + MsgAddressListRef m_AddressList; + std::string m_UnreadCount; + std::string m_Name; + std::string m_Message; + std::string m_Time; + time_t m_RawTime; + }; } #endif // ThreadListItem_h_ diff --git a/src/MsgThread/Controller/src/MsgThreadFrame.cpp b/src/MsgThread/Controller/src/MsgThreadFrame.cpp index 09aca47..18cfc33 100644 --- a/src/MsgThread/Controller/src/MsgThreadFrame.cpp +++ b/src/MsgThread/Controller/src/MsgThreadFrame.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -37,286 +37,286 @@ using namespace Msg; MsgThreadFrame::MsgThreadFrame(NaviFrameController &parent) - : FrameController(parent, MsgThreadGroup) - , m_pLayout(nullptr) - , m_pMoreOption(nullptr) - , m_pDeleteButton(nullptr) - , m_pSelectButton(nullptr) - , m_pThreadList(nullptr) - , m_pSelectPopup(nullptr) - , m_Mode(InitMode) + : FrameController(parent, MsgThreadGroup) + , m_pLayout(nullptr) + , m_pMoreOption(nullptr) + , m_pDeleteButton(nullptr) + , m_pSelectButton(nullptr) + , m_pThreadList(nullptr) + , m_pSelectPopup(nullptr) + , m_Mode(InitMode) { - MSG_LOG(""); - prepareMainLayout(); - prepareMoreOption(); - prepareThreadList(); - setMode(NormalMode); + MSG_LOG(""); + prepareMainLayout(); + prepareMoreOption(); + prepareThreadList(); + setMode(NormalMode); } MsgThreadFrame::~MsgThreadFrame() { - MSG_LOG(""); - hideSelectPopup(); + MSG_LOG(""); + hideSelectPopup(); } void MsgThreadFrame::setMode(Mode mode) { - if (m_Mode == mode) - return; - - switch (mode) { - case NormalMode: - setNormalMode(); - break; - case DeleteMode: - setDeleteMode(); - break; - case InitMode: - default: - MSG_ASSERT(false, "Not supported mode"); - break; - } + if (m_Mode == mode) + return; + + switch (mode) { + case NormalMode: + setNormalMode(); + break; + case DeleteMode: + setDeleteMode(); + break; + case InitMode: + default: + MSG_ASSERT(false, "Not supported mode"); + break; + } } void MsgThreadFrame::setNormalMode() { - MSG_LOG(""); - m_Mode = NormalMode; - hideSelectPopup(); - m_pLayout->showMoreOption(true); - m_pLayout->showBottomButton(false); - if (m_pSelectButton) - m_pSelectButton->showButton(false); - m_pThreadList->setDeleteMode(false); + MSG_LOG(""); + m_Mode = NormalMode; + hideSelectPopup(); + m_pLayout->showMoreOption(true); + m_pLayout->showBottomButton(false); + if (m_pSelectButton) + m_pSelectButton->showButton(false); + m_pThreadList->setDeleteMode(false); } void MsgThreadFrame::setDeleteMode() { - MSG_LOG(""); - if (m_Mode != DeleteMode && - m_pThreadList->getItemsCount() != 0) { - prepareDeleteViews(); - m_Mode = DeleteMode; - m_pSelectButton->setText("0"); - m_pSelectButton->showButton(true); - m_pDeleteButton->disabled(true); - m_pLayout->showBottomButton(true); - m_pLayout->showMoreOption(false); - m_pThreadList->setDeleteMode(true); - } + MSG_LOG(""); + if (m_Mode != DeleteMode && + m_pThreadList->getItemsCount() != 0) { + prepareDeleteViews(); + m_Mode = DeleteMode; + m_pSelectButton->setText("0"); + m_pSelectButton->showButton(true); + m_pDeleteButton->disabled(true); + m_pLayout->showBottomButton(true); + m_pLayout->showMoreOption(false); + m_pThreadList->setDeleteMode(true); + } } void MsgThreadFrame::prepareThreadList() { - if (!m_pThreadList) { - m_pThreadList = new ThreadList(*m_pLayout); - m_pThreadList->setListener(this); - m_pLayout->setContent(*m_pThreadList); - m_pLayout->showContent(true); - } + if (!m_pThreadList) { + m_pThreadList = new ThreadList(*m_pLayout); + m_pThreadList->setListener(this); + m_pLayout->setContent(*m_pThreadList); + m_pLayout->showContent(true); + } } void MsgThreadFrame::prepareMainLayout() { - if (!m_pLayout) { - m_pLayout = new DefaultLayout(getParent()); - m_pLayout->addHwButtonEvent(EEXT_CALLBACK_BACK, makeCbFirst(&MsgThreadFrame::onHwBackButtonPreessed), this); - m_pLayout->showSelectButton(true); - } + if (!m_pLayout) { + m_pLayout = new DefaultLayout(getParent()); + m_pLayout->addHwButtonEvent(EEXT_CALLBACK_BACK, makeCbFirst(&MsgThreadFrame::onHwBackButtonPreessed), this); + m_pLayout->showSelectButton(true); + } } void MsgThreadFrame::prepareMoreOption() { - if (!m_pMoreOption) { - m_pMoreOption = new MoreOption(*m_pLayout); - m_pMoreOption->setDirection(EEXT_MORE_OPTION_DIRECTION_RIGHT); - m_pMoreOption->appendItem(msgt("WDS_MSG_OPT_NEW_MESSAGE_ABB"), NEW_MSG_MORE_ICON, makeCbLast(&MsgThreadFrame::onNewMessageClicked), this); - m_pMoreOption->appendItem(msgt("WDS_MSG_OPT_DELETE_ABB"), DELETEG_MORE_ICON, makeCbLast(&MsgThreadFrame::onDeleteClicked), this); - m_pMoreOption->appendItem("Settings", nullptr, makeCbLast(&MsgThreadFrame::onSettingsClicked), this); // TODO: only for test - m_pLayout->setMoreOption(*m_pMoreOption); - } + if (!m_pMoreOption) { + m_pMoreOption = new MoreOption(*m_pLayout); + m_pMoreOption->setDirection(EEXT_MORE_OPTION_DIRECTION_RIGHT); + m_pMoreOption->appendItem(msgt("WDS_MSG_OPT_NEW_MESSAGE_ABB"), NEW_MSG_MORE_ICON, makeCbLast(&MsgThreadFrame::onNewMessageClicked), this); + m_pMoreOption->appendItem(msgt("WDS_MSG_OPT_DELETE_ABB"), DELETEG_MORE_ICON, makeCbLast(&MsgThreadFrame::onDeleteClicked), this); + m_pMoreOption->appendItem("Settings", nullptr, makeCbLast(&MsgThreadFrame::onSettingsClicked), this); // TODO: only for test + m_pLayout->setMoreOption(*m_pMoreOption); + } } void MsgThreadFrame::prepareDeleteViews() { - if (!m_pDeleteButton) { - m_pDeleteButton = new BottomButton(*m_pLayout); - m_pDeleteButton->setText(msgt("IDS_MSG_ACBUTTON_DELETE_ABB")); - View::addSmartCb(m_pDeleteButton->getInnerButton(), "clicked", makeCbFirst(&MsgThreadFrame::onDelButtonClicked), this); - m_pLayout->setBottomButton(*m_pDeleteButton); - } - - if (!m_pSelectButton) { - m_pSelectButton = new SelectButton(*m_pLayout); - View::addSmartCb(m_pSelectButton->getInnerButton(), "clicked", makeCbFirst(&MsgThreadFrame::onSelectButtonClicked), this); - m_pLayout->setSelectButton(*m_pSelectButton); - } + if (!m_pDeleteButton) { + m_pDeleteButton = new BottomButton(*m_pLayout); + m_pDeleteButton->setText(msgt("IDS_MSG_ACBUTTON_DELETE_ABB")); + View::addSmartCb(m_pDeleteButton->getInnerButton(), "clicked", makeCbFirst(&MsgThreadFrame::onDelButtonClicked), this); + m_pLayout->setBottomButton(*m_pDeleteButton); + } + + if (!m_pSelectButton) { + m_pSelectButton = new SelectButton(*m_pLayout); + View::addSmartCb(m_pSelectButton->getInnerButton(), "clicked", makeCbFirst(&MsgThreadFrame::onSelectButtonClicked), this); + m_pLayout->setSelectButton(*m_pSelectButton); + } } void MsgThreadFrame::updateDeleteViews() { - if (m_Mode == DeleteMode) { - if (m_pThreadList->isEmpty()) { - setMode(NormalMode); - } else { - int count = m_pThreadList->getCheckedItemsCount(); - m_pSelectButton->setText(std::to_string(count)); - m_pDeleteButton->disabled(count <= 0); - } - } + if (m_Mode == DeleteMode) { + if (m_pThreadList->isEmpty()) { + setMode(NormalMode); + } else { + int count = m_pThreadList->getCheckedItemsCount(); + m_pSelectButton->setText(std::to_string(count)); + m_pDeleteButton->disabled(count <= 0); + } + } } void MsgThreadFrame::showSelectPopup() { - hideSelectPopup(); - m_pSelectPopup = new SelectCtxPopup; - m_pSelectPopup->addEventCb(EVAS_CALLBACK_DEL, makeCbFirst(&MsgThreadFrame::onSelectPopupDel), this); + hideSelectPopup(); + m_pSelectPopup = new SelectCtxPopup; + m_pSelectPopup->addEventCb(EVAS_CALLBACK_DEL, makeCbFirst(&MsgThreadFrame::onSelectPopupDel), this); - int checkedCount = m_pThreadList->getCheckedItemsCount(); - int checkableCount = m_pThreadList->getCheckableItemsCount(); + int checkedCount = m_pThreadList->getCheckedItemsCount(); + int checkableCount = m_pThreadList->getCheckableItemsCount(); - if (checkedCount < checkableCount) - m_pSelectPopup->appendTopItem(msgt("WDS_MSG_OPT_SELECT_ALL_ABB"), makeCbLast(&MsgThreadFrame::onSelectAllButtonClicked), this); - if (checkedCount > 0) - m_pSelectPopup->appendBottomItem(msgt("WDS_MSG_OPT_DESELECT_ALL_ABB"), makeCbLast(&MsgThreadFrame::onDeselectAllButtonClicked), this); + if (checkedCount < checkableCount) + m_pSelectPopup->appendTopItem(msgt("WDS_MSG_OPT_SELECT_ALL_ABB"), makeCbLast(&MsgThreadFrame::onSelectAllButtonClicked), this); + if (checkedCount > 0) + m_pSelectPopup->appendBottomItem(msgt("WDS_MSG_OPT_DESELECT_ALL_ABB"), makeCbLast(&MsgThreadFrame::onDeselectAllButtonClicked), this); - if (m_pSelectButton) - m_pSelectPopup->align(m_pSelectButton->getInnerButton()); + if (m_pSelectButton) + m_pSelectPopup->align(m_pSelectButton->getInnerButton()); - m_pSelectPopup->go(); + m_pSelectPopup->go(); } void MsgThreadFrame::hideSelectPopup() { - if (m_pSelectPopup) - m_pSelectPopup->destroy(); + if (m_pSelectPopup) + m_pSelectPopup->destroy(); } void MsgThreadFrame::showDelPopup() { - auto *popup = new IconTextPopup; - popup->setIcon(IconTextPopup::CheckIcon); - popup->setText(msgt("WDS_ALM_TPOP_DELETED_ABB")); - popup->setTimeOut(); - popup->show(); + auto *popup = new IconTextPopup; + popup->setIcon(IconTextPopup::CheckIcon); + popup->setText(msgt("WDS_ALM_TPOP_DELETED_ABB")); + popup->setTimeOut(); + popup->show(); } void MsgThreadFrame::navigateToConvFrame(ThreadId id) { - auto *frame = new ConvFrame(getParent()); - frame->setThreadId(id); - getParent().push(*frame); + auto *frame = new ConvFrame(getParent()); + frame->setThreadId(id); + getParent().push(*frame); } void MsgThreadFrame::composeMsg() { - if (getParent().getConnectivityChecker().isFlightModeDisabled()) { - auto *frame = new RecipFrame(getParent()); - getParent().push(*frame); - } + if (getParent().getConnectivityChecker().isFlightModeDisabled()) { + auto *frame = new RecipFrame(getParent()); + getParent().push(*frame); + } } void MsgThreadFrame::onAttached(ViewItem &item) { - MSG_LOG(""); - FrameController::onAttached(item); - setContent(*m_pLayout); + MSG_LOG(""); + FrameController::onAttached(item); + setContent(*m_pLayout); } void MsgThreadFrame::onHwBackButtonPreessed(Evas_Object *obj, void *event_info) { - MSG_LOG(""); - if (m_Mode != NormalMode) - setMode(NormalMode); - else - pop(); + MSG_LOG(""); + if (m_Mode != NormalMode) + setMode(NormalMode); + else + pop(); } void MsgThreadFrame::onDelButtonClicked(Evas_Object *obj, void *event) { - MSG_LOG(""); - if (m_pThreadList->deleteCheckedItems()) - showDelPopup(); - setNormalMode(); + MSG_LOG(""); + if (m_pThreadList->deleteCheckedItems()) + showDelPopup(); + setNormalMode(); } void MsgThreadFrame::onSelectButtonClicked(Evas_Object *obj, void *event) { - MSG_LOG(""); - showSelectPopup(); + MSG_LOG(""); + showSelectPopup(); } void MsgThreadFrame::onSelectAllButtonClicked(CtxPopupItem &item) { - MSG_LOG(""); - m_pThreadList->checkAllItems(true); - updateDeleteViews(); + MSG_LOG(""); + m_pThreadList->checkAllItems(true); + updateDeleteViews(); } void MsgThreadFrame::onDeselectAllButtonClicked(CtxPopupItem &item) { - MSG_LOG(""); - m_pThreadList->checkAllItems(false); - updateDeleteViews(); + MSG_LOG(""); + m_pThreadList->checkAllItems(false); + updateDeleteViews(); } void MsgThreadFrame::onNewMessageClicked(MoreOption &obj) { - MSG_LOG(""); - composeMsg(); + MSG_LOG(""); + composeMsg(); } void MsgThreadFrame::onDeleteClicked(MoreOption &obj) { - MSG_LOG(""); - setMode(DeleteMode); + MSG_LOG(""); + setMode(DeleteMode); } void MsgThreadFrame::onSettingsClicked(MoreOption &obj) { - MSG_LOG(""); - getParent().push(*new SettingsFrame(getParent())); + MSG_LOG(""); + getParent().push(*new SettingsFrame(getParent())); } void MsgThreadFrame::onItemSelected(ThreadId id) { - MSG_LOG(""); - if (id.isValid()) - navigateToConvFrame(id); + MSG_LOG(""); + if (id.isValid()) + navigateToConvFrame(id); } void MsgThreadFrame::onItemRequestDeleteMode(ThreadListItem &listItem) { - MSG_LOG(""); - setMode(DeleteMode); + MSG_LOG(""); + setMode(DeleteMode); } void MsgThreadFrame::onChanged(ThreadList &list) { - MSG_LOG(""); - updateDeleteViews(); + MSG_LOG(""); + updateDeleteViews(); } void MsgThreadFrame::onItemChecked(ThreadListItem &item) { - MSG_LOG(""); - updateDeleteViews(); + MSG_LOG(""); + updateDeleteViews(); } void MsgThreadFrame::onComposeButtonClicked(ThreadList &list) { - MSG_LOG(""); - composeMsg(); + MSG_LOG(""); + composeMsg(); } void MsgThreadFrame::onContactsButtonClicked(ThreadList &list) { - MSG_LOG(""); - m_ContactViewer.launch(); + MSG_LOG(""); + m_ContactViewer.launch(); } void MsgThreadFrame::onSelectPopupDel(Evas *e, Evas_Object *obj, void *event_info) { - MSG_LOG(""); - m_pSelectPopup = nullptr; + MSG_LOG(""); + m_pSelectPopup = nullptr; } diff --git a/src/MsgThread/Controller/src/ThreadList.cpp b/src/MsgThread/Controller/src/ThreadList.cpp index 48a3c95..971a54d 100644 --- a/src/MsgThread/Controller/src/ThreadList.cpp +++ b/src/MsgThread/Controller/src/ThreadList.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -28,375 +28,375 @@ using namespace Msg; namespace { - bool isThreadItem(const ListItem &item) - { - return dynamic_cast(&item) != nullptr; - } + bool isThreadItem(const ListItem &item) + { + return dynamic_cast(&item) != nullptr; + } } ThreadList::ThreadList(DefaultLayout &parent) - : ListView(parent, App::getInst().getWindow().getCircleSurface()) - , m_pListener(nullptr) - , m_App(App::getInst()) - , m_DeleteMode(false) - , m_ComposeItem(nullptr) - , m_pTopPadItem(nullptr) - , m_pBottomPadItem(nullptr) - , m_pNoContentItem(nullptr) -{ - ListView::setListener(this); - ListView::setHomogeneous(false); - ListView::setMultiSelection(false); - ListView::setCmpFunc(cmpFunc); - - m_App.getMsgEngine().getStorage().addListener(*this); - m_App.getContactManager().addListener(*this); - m_App.getSysSettingsManager().addListener(*this); - fillList(); + : ListView(parent, App::getInst().getWindow().getCircleSurface()) + , m_pListener(nullptr) + , m_App(App::getInst()) + , m_DeleteMode(false) + , m_ComposeItem(nullptr) + , m_pTopPadItem(nullptr) + , m_pBottomPadItem(nullptr) + , m_pNoContentItem(nullptr) +{ + ListView::setListener(this); + ListView::setHomogeneous(false); + ListView::setMultiSelection(false); + ListView::setCmpFunc(cmpFunc); + + m_App.getMsgEngine().getStorage().addListener(*this); + m_App.getContactManager().addListener(*this); + m_App.getSysSettingsManager().addListener(*this); + fillList(); } ThreadList::~ThreadList() { - m_App.getMsgEngine().getStorage().removeListener(*this); - m_App.getContactManager().removeListener(*this); - m_App.getSysSettingsManager().removeListener(*this); + m_App.getMsgEngine().getStorage().removeListener(*this); + m_App.getContactManager().removeListener(*this); + m_App.getSysSettingsManager().removeListener(*this); } void ThreadList::setListener(IThreadListListener *l) { - m_pListener = l; + m_pListener = l; } void ThreadList::setDeleteMode(bool value) { - if (m_DeleteMode != value) { - m_DeleteMode = value; - setCheckMode(value); - checkAllItems(false, true); - if (m_ComposeItem) - m_ComposeItem->disabled(value); - } + if (m_DeleteMode != value) { + m_DeleteMode = value; + setCheckMode(value); + checkAllItems(false, true); + if (m_ComposeItem) + m_ComposeItem->disabled(value); + } } bool ThreadList::isDeleteModeEnabled() const { - return m_DeleteMode; + return m_DeleteMode; } bool ThreadList::deleteCheckedItems() { - bool res = false; - auto items = getItems(); - for (ThreadListItem *it : items) { - if (it->getCheckedState()) - res |= m_App.getMsgEngine().getStorage().deleteThread(it->getThreadId()); - } - return res; + bool res = false; + auto items = getItems(); + for (ThreadListItem *it : items) { + if (it->getCheckedState()) + res |= m_App.getMsgEngine().getStorage().deleteThread(it->getThreadId()); + } + return res; } bool ThreadList::isEmpty() const { - return !hasItem(); + return !hasItem(); } bool ThreadList::isAllThreadListItemChecked() const { - // Simple impl. but not fast: - auto items = getItems(); - for (ThreadListItem *item : items) { - if (!item->getCheckedState()) - return false; - } - return true; + // Simple impl. but not fast: + auto items = getItems(); + for (ThreadListItem *item : items) { + if (!item->getCheckedState()) + return false; + } + return true; } void ThreadList::checkHandler(ThreadListItem &item) { - ThreadId threadId = item.getThreadId(); - MSG_LOG("Checked (id : state) = ", threadId, ":", item.getCheckedState()); - if (m_pListener) - m_pListener->onItemChecked(item); + ThreadId threadId = item.getThreadId(); + MSG_LOG("Checked (id : state) = ", threadId, ":", item.getCheckedState()); + if (m_pListener) + m_pListener->onItemChecked(item); } int ThreadList::cmpFunc(const ListItem &item1, const ListItem &item2) { - bool isTh1 = isThreadItem(item1); - bool isTh2 = isThreadItem(item2); // New inserted item + bool isTh1 = isThreadItem(item1); + bool isTh2 = isThreadItem(item2); // New inserted item - if (!isTh1 && !isTh2) - return 0; + if (!isTh1 && !isTh2) + return 0; - if (isTh2 && !isTh1) { - auto *self = static_cast(item1.getOwner()); - return self->m_pBottomPadItem->isSame(item1) ? 1 : -1; - } + if (isTh2 && !isTh1) { + auto *self = static_cast(item1.getOwner()); + return self->m_pBottomPadItem->isSame(item1) ? 1 : -1; + } - auto &threadItem1 = static_cast(item1); - auto &threadItem2 = static_cast(item2); - return threadItem2.getRawTime() - threadItem1.getRawTime(); + auto &threadItem1 = static_cast(item1); + auto &threadItem2 = static_cast(item2); + return threadItem2.getRawTime() - threadItem1.getRawTime(); } void ThreadList::insertItem(ThreadId id) { - MsgThreadItemRef threadItem = m_App.getMsgEngine().getStorage().getThread(id); - if (threadItem) { - auto newItem = new ThreadListItem(*threadItem); - if (ListView::sortedInsertItem(*newItem)) { - navigateTo(*newItem); - showNoContent(false); - if (m_pListener) - m_pListener->onChanged(*this); - } - } + MsgThreadItemRef threadItem = m_App.getMsgEngine().getStorage().getThread(id); + if (threadItem) { + auto newItem = new ThreadListItem(*threadItem); + if (ListView::sortedInsertItem(*newItem)) { + navigateTo(*newItem); + showNoContent(false); + if (m_pListener) + m_pListener->onChanged(*this); + } + } } void ThreadList::deleteItem(ThreadId id) { - auto* thread = getItem(id); - if (thread) { - ListView::deleteItem(*thread); - unsigned count = getItemsCount(); - if (count == 0) - showNoContent(true); - if (m_pListener) - m_pListener->onChanged(*this); - } + auto* thread = getItem(id); + if (thread) { + ListView::deleteItem(*thread); + unsigned count = getItemsCount(); + if (count == 0) + showNoContent(true); + if (m_pListener) + m_pListener->onChanged(*this); + } } ThreadListItem *ThreadList::getItem(ThreadId id) const { - auto items = ListView::getItems(); - for (ThreadListItem *item : items) { - if (item->getThreadId() == id) - return item; - } - return nullptr; + auto items = ListView::getItems(); + for (ThreadListItem *item : items) { + if (item->getThreadId() == id) + return item; + } + return nullptr; } void ThreadList::fillList() { - // Top padding: - m_pTopPadItem = new PaddingListViewItem; - ListView::appendItem(*m_pTopPadItem); + // Top padding: + m_pTopPadItem = new PaddingListViewItem; + ListView::appendItem(*m_pTopPadItem); - // Compose Item: - m_ComposeItem = new ThreadComposeListViewItem; - m_ComposeItem->setListener(this); - ListView::appendItem(*m_ComposeItem); + // Compose Item: + m_ComposeItem = new ThreadComposeListViewItem; + m_ComposeItem->setListener(this); + ListView::appendItem(*m_ComposeItem); - // Group item: - auto *lineListItem = new LineListViewItem("WDS_MSG_HEADER_MESSAGES_ABB"); - ListView::appendItem(*lineListItem); + // Group item: + auto *lineListItem = new LineListViewItem("WDS_MSG_HEADER_MESSAGES_ABB"); + ListView::appendItem(*lineListItem); - Atspi ao = Atspi(*lineListItem); - ao.setName(msg("WDS_MSG_HEADER_MESSAGES_ABB")); - ao.setRole(ELM_ATSPI_ROLE_HEADER); - ao.setReadingInfo((Elm_Accessible_Reading_Info_Type)(ELM_ACCESSIBLE_READING_INFO_TYPE_NAME | ELM_ACCESSIBLE_READING_INFO_TYPE_ROLE)); + Atspi ao = Atspi(*lineListItem); + ao.setName(msg("WDS_MSG_HEADER_MESSAGES_ABB")); + ao.setRole(ELM_ATSPI_ROLE_HEADER); + ao.setReadingInfo((Elm_Accessible_Reading_Info_Type)(ELM_ACCESSIBLE_READING_INFO_TYPE_NAME | ELM_ACCESSIBLE_READING_INFO_TYPE_ROLE)); - // Thread list: - MsgThreadListRef msgThreadList = m_App.getMsgEngine().getStorage().getThreadList(); - int threadCount = 0; - if (msgThreadList) { - threadCount = msgThreadList->getLength(); + // Thread list: + MsgThreadListRef msgThreadList = m_App.getMsgEngine().getStorage().getThreadList(); + int threadCount = 0; + if (msgThreadList) { + threadCount = msgThreadList->getLength(); - for (int i = 0; i < threadCount; ++i) { - const MsgThreadItem &msgThreadItem = msgThreadList->at(i); - ListView::appendItem(*new ThreadListItem(msgThreadItem)); - } - } + for (int i = 0; i < threadCount; ++i) { + const MsgThreadItem &msgThreadItem = msgThreadList->at(i); + ListView::appendItem(*new ThreadListItem(msgThreadItem)); + } + } - // Bottom padding: - m_pBottomPadItem = new PaddingListViewItem; - ListView::appendItem(*m_pBottomPadItem); + // Bottom padding: + m_pBottomPadItem = new PaddingListViewItem; + ListView::appendItem(*m_pBottomPadItem); - // No Content: - if (threadCount == 0) - showNoContent(true); + // No Content: + if (threadCount == 0) + showNoContent(true); } void ThreadList::deleteItems() { - MsgThreadListRef msgThreadList = m_App.getMsgEngine().getStorage().getThreadList(); - if (!msgThreadList) - return; + MsgThreadListRef msgThreadList = m_App.getMsgEngine().getStorage().getThreadList(); + if (!msgThreadList) + return; - std::set threadIdSet; - int length = msgThreadList->getLength(); - for (int i = 0; i < length; ++i) { - const MsgThreadItem &msgThreadItem = msgThreadList->at(i); - threadIdSet.insert(msgThreadItem.getId()); - } + std::set threadIdSet; + int length = msgThreadList->getLength(); + for (int i = 0; i < length; ++i) { + const MsgThreadItem &msgThreadItem = msgThreadList->at(i); + threadIdSet.insert(msgThreadItem.getId()); + } - auto items = ListView::getItems(); + auto items = ListView::getItems(); - for (ThreadListItem *item : items) { - if (threadIdSet.count(item->getThreadId()) == 0) - ListView::deleteItem(*item); - } + for (ThreadListItem *item : items) { + if (threadIdSet.count(item->getThreadId()) == 0) + ListView::deleteItem(*item); + } } void ThreadList::navigateTo(ThreadListItem &item) { - ListView::showItem(item, ELM_GENLIST_ITEM_SCROLLTO_MIDDLE); + ListView::showItem(item, ELM_GENLIST_ITEM_SCROLLTO_MIDDLE); } void ThreadList::updateItems(const MsgIdList &idList) { - auto threadIdSet = getThreadIdSet(idList); - auto threadItems = getItems(); + auto threadIdSet = getThreadIdSet(idList); + auto threadItems = getItems(); - for (ThreadListItem *item: threadItems) { - if (threadIdSet.count(item->getThreadId())) - updateItem(*item); - } + for (ThreadListItem *item: threadItems) { + if (threadIdSet.count(item->getThreadId())) + updateItem(*item); + } } void ThreadList::updateLangInfo() { - auto items = getItems(); - for (ThreadListItem *item: items) { - item->updateLangInfo(); - } - updateRealizedItems(); + auto items = getItems(); + for (ThreadListItem *item: items) { + item->updateLangInfo(); + } + updateRealizedItems(); } void ThreadList::showNoContent(bool value) { - if (value) { - if (!m_pNoContentItem) { - m_pNoContentItem = new NoContentListViewItem; - m_pNoContentItem->setText("WDS_MSG_NPBODY_NO_MESSAGES_ABB"); - insertBeforeItem(*m_pNoContentItem, *m_pBottomPadItem); - } - } else if (m_pNoContentItem){ - m_pNoContentItem->destroy(); - m_pNoContentItem = nullptr; - } + if (value) { + if (!m_pNoContentItem) { + m_pNoContentItem = new NoContentListViewItem; + m_pNoContentItem->setText("WDS_MSG_NPBODY_NO_MESSAGES_ABB"); + insertBeforeItem(*m_pNoContentItem, *m_pBottomPadItem); + } + } else if (m_pNoContentItem){ + m_pNoContentItem->destroy(); + m_pNoContentItem = nullptr; + } } void ThreadList::updateItem(ThreadListItem &item) { - MsgThreadItemRef msgThread = m_App.getMsgEngine().getStorage().getThread(item.getThreadId()); - if (!msgThread) { - MSG_LOG_ERROR("msgThread is null"); - return; - } - - auto *next = findNextItem(item); - auto *prev = findPrevItem(item); - time_t threadTime = msgThread->getTime(); - - if ((next && threadTime < next->getRawTime()) || - (prev && threadTime > prev->getRawTime())) { - auto newItem = new ThreadListItem(*msgThread); - newItem->setCheckedState(item.getCheckedState(), false); - item.destroy(); - ListView::sortedInsertItem(*newItem); - navigateTo(*newItem); - } else { - item.update(*msgThread); // Model - item.update(); // UI - navigateTo(item); - } + MsgThreadItemRef msgThread = m_App.getMsgEngine().getStorage().getThread(item.getThreadId()); + if (!msgThread) { + MSG_LOG_ERROR("msgThread is null"); + return; + } + + auto *next = findNextItem(item); + auto *prev = findPrevItem(item); + time_t threadTime = msgThread->getTime(); + + if ((next && threadTime < next->getRawTime()) || + (prev && threadTime > prev->getRawTime())) { + auto newItem = new ThreadListItem(*msgThread); + newItem->setCheckedState(item.getCheckedState(), false); + item.destroy(); + ListView::sortedInsertItem(*newItem); + navigateTo(*newItem); + } else { + item.update(*msgThread); // Model + item.update(); // UI + navigateTo(item); + } } std::set ThreadList::getThreadIdSet(const MsgIdList &idList) { - std::set res; - for (MsgId msgId : idList) { - ThreadId threadId = m_App.getMsgEngine().getStorage().getThreadId(msgId); - if (threadId.isValid()) - res.insert(threadId); - } - return res; + std::set res; + for (MsgId msgId : idList) { + ThreadId threadId = m_App.getMsgEngine().getStorage().getThreadId(msgId); + if (threadId.isValid()) + res.insert(threadId); + } + return res; } void ThreadList::onListItemSelected(ListItem &listItem) { - MSG_LOG(""); - auto *it = dynamic_cast(&listItem); - if (it && m_pListener) - m_pListener->onItemSelected(it->getThreadId()); + MSG_LOG(""); + auto *it = dynamic_cast(&listItem); + if (it && m_pListener) + m_pListener->onItemSelected(it->getThreadId()); } void ThreadList::onListItemChecked(ListItem &listItem) { - MSG_LOG(""); - if (auto *it = dynamic_cast(&listItem)) - checkHandler(*it); + MSG_LOG(""); + if (auto *it = dynamic_cast(&listItem)) + checkHandler(*it); } void ThreadList::onListItemLongPressed(ListItem &listItem) { - MSG_LOG(""); - if (m_pListener) { - if (auto *it = dynamic_cast(&listItem)) { - m_pListener->onItemRequestDeleteMode(*it); - if (isDeleteModeEnabled()) { - it->setCheckedState(true, true); - checkHandler(*it); - } - } - } + MSG_LOG(""); + if (m_pListener) { + if (auto *it = dynamic_cast(&listItem)) { + m_pListener->onItemRequestDeleteMode(*it); + if (isDeleteModeEnabled()) { + it->setCheckedState(true, true); + checkHandler(*it); + } + } + } } void ThreadList::onMsgStorageThreadUpdate(const ThreadId &threadId) { - MSG_LOG(""); - auto* item = getItem(threadId); - if (item) - updateItem(*item); + MSG_LOG(""); + auto* item = getItem(threadId); + if (item) + updateItem(*item); } void ThreadList::onMsgStorageThreadInsert(const ThreadId &threadId) { - MSG_LOG(""); - insertItem(threadId); + MSG_LOG(""); + insertItem(threadId); } void ThreadList::onMsgStorageThreadDelete(const ThreadId &threadId) { - MSG_LOG(""); - deleteItem(threadId); + MSG_LOG(""); + deleteItem(threadId); } void ThreadList::onContactChanged() { - MSG_LOG(""); - auto items = getItems(); - for (ThreadListItem *item: items) { - item->updateContactInfo(); - } - ListView:: updateRealizedItems(); + MSG_LOG(""); + auto items = getItems(); + for (ThreadListItem *item: items) { + item->updateContactInfo(); + } + ListView:: updateRealizedItems(); } void ThreadList::onTimeFormatChanged() { - MSG_LOG(""); - auto items = ListView::getItems(); - for (ThreadListItem *item : items) { - item->updateTime(); - } - ListView::updateRealizedItems(); + MSG_LOG(""); + auto items = ListView::getItems(); + for (ThreadListItem *item : items) { + item->updateTime(); + } + ListView::updateRealizedItems(); } void ThreadList::onLanguageChanged() { - MSG_LOG(""); - updateLangInfo(); + MSG_LOG(""); + updateLangInfo(); } void ThreadList::onComposeButtonClicked() { - MSG_LOG(""); - if (m_pListener) - m_pListener->onComposeButtonClicked(*this); + MSG_LOG(""); + if (m_pListener) + m_pListener->onComposeButtonClicked(*this); } void ThreadList::onContactsButtonClicked() { - MSG_LOG(""); - if (m_pListener) - m_pListener->onContactsButtonClicked(*this); + MSG_LOG(""); + if (m_pListener) + m_pListener->onContactsButtonClicked(*this); } diff --git a/src/MsgThread/Controller/src/ThreadListItem.cpp b/src/MsgThread/Controller/src/ThreadListItem.cpp index 1a9bbd7..e55a552 100644 --- a/src/MsgThread/Controller/src/ThreadListItem.cpp +++ b/src/MsgThread/Controller/src/ThreadListItem.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -28,11 +28,11 @@ using namespace Msg; ThreadListItem::ThreadListItem(const MsgThreadItem &threadItem) - : ThreadListViewItem() - , m_ThreadId() - , m_RawTime() + : ThreadListViewItem() + , m_ThreadId() + , m_RawTime() { - update(threadItem); + update(threadItem); } ThreadListItem::~ThreadListItem() @@ -41,143 +41,143 @@ ThreadListItem::~ThreadListItem() void ThreadListItem::update(const MsgThreadItem &threadItem) { - m_ThreadId = threadItem.getId(); - m_AddressList = App::getInst().getMsgEngine().getStorage().getAddressList(m_ThreadId); - State state = NormalState; - - MsgConversationListRef convList = App::getInst().getMsgEngine().getStorage().getConversationList(m_ThreadId); - if (convList && convList->getLength() > 0) { - MsgConversationItem &item = convList->at(convList->getLength() - 1); - - Message::NetworkStatus status = item.getNetworkStatus(); - if (status == Message::NS_Sending) { - state = StatusState; - } else if (status == Message::NS_Send_Fail) { - state = StatusState; - } else if (item.isDraft()) { - state = StatusState; - } else if (!item.isRead()) { - int count = threadItem.getUnreadCount(); - if (count > 0) { - state = IconState; - m_UnreadCount = std::to_string(count); - } - } - } - - setState(state, false); - updateMessage(threadItem); - updateName(); - updateTime(threadItem.getTime()); + m_ThreadId = threadItem.getId(); + m_AddressList = App::getInst().getMsgEngine().getStorage().getAddressList(m_ThreadId); + State state = NormalState; + + MsgConversationListRef convList = App::getInst().getMsgEngine().getStorage().getConversationList(m_ThreadId); + if (convList && convList->getLength() > 0) { + MsgConversationItem &item = convList->at(convList->getLength() - 1); + + Message::NetworkStatus status = item.getNetworkStatus(); + if (status == Message::NS_Sending) { + state = StatusState; + } else if (status == Message::NS_Send_Fail) { + state = StatusState; + } else if (item.isDraft()) { + state = StatusState; + } else if (!item.isRead()) { + int count = threadItem.getUnreadCount(); + if (count > 0) { + state = IconState; + m_UnreadCount = std::to_string(count); + } + } + } + + setState(state, false); + updateMessage(threadItem); + updateName(); + updateTime(threadItem.getTime()); } void ThreadListItem::updateMessage(const MsgThreadItem &threadItem) { - updateMessage(threadItem.getLastMessage()); + updateMessage(threadItem.getLastMessage()); } void ThreadListItem::updateMessage(const std::string &msg) { - m_Message = msg; + m_Message = msg; } void ThreadListItem::updateName() { - if (m_AddressList) - updateName(*m_AddressList); + if (m_AddressList) + updateName(*m_AddressList); } void ThreadListItem::updateName(const MsgAddressList &addressList) { - int countContact = addressList.getLength(); - if (countContact <= 0) { - MSG_LOG_WARN("Msg address list is empty"); - return; - } + int countContact = addressList.getLength(); + if (countContact <= 0) { + MSG_LOG_WARN("Msg address list is empty"); + return; + } - const MsgAddress &addr = addressList[0]; + const MsgAddress &addr = addressList[0]; - if (countContact > 1) { - updateName(addr, countContact); - } else if (countContact == 1) { - updateName(addr, countContact); - } + if (countContact > 1) { + updateName(addr, countContact); + } else if (countContact == 1) { + updateName(addr, countContact); + } } void ThreadListItem::updateName(const MsgAddress &address, int addressesCount) { - ContactAddressRef contactAddress = App::getInst().getContactManager().getContactAddress(address.getAddress()); - if (contactAddress) - updateName(*contactAddress, addressesCount); - else - updateName(address.getAddress(), addressesCount); + ContactAddressRef contactAddress = App::getInst().getContactManager().getContactAddress(address.getAddress()); + if (contactAddress) + updateName(*contactAddress, addressesCount); + else + updateName(address.getAddress(), addressesCount); } void ThreadListItem::updateName(const ContactAddress &address, int addressesCount) { - std::string dispName = address.getDispName(); - if (dispName.empty()) - dispName = address.getAddress(); - updateName(dispName, addressesCount); + std::string dispName = address.getDispName(); + if (dispName.empty()) + dispName = address.getAddress(); + updateName(dispName, addressesCount); } void ThreadListItem::updateName(const std::string &address, int addressesCount) { - m_Name = address; - --addressesCount; - if (addressesCount > 0) - m_Name += " +" + std::to_string(addressesCount); + m_Name = address; + --addressesCount; + if (addressesCount > 0) + m_Name += " +" + std::to_string(addressesCount); } void ThreadListItem::updateTime(time_t time) { - m_RawTime = time; - updateTime(); + m_RawTime = time; + updateTime(); } void ThreadListItem::updateTime() { - m_Time.clear(); + m_Time.clear(); } void ThreadListItem::updateContactInfo() { - updateName(); + updateName(); } void ThreadListItem::updateLangInfo() { - updateTime(); + updateTime(); } std::string ThreadListItem::getName() { - return m_Name; + return m_Name; } std::string ThreadListItem::getMessage() { - return m_Message; + return m_Message; } std::string ThreadListItem::getTime() { - if (m_Time.empty()) - m_Time = TimeUtils::makeThreadTimeString(m_RawTime); - return m_Time; + if (m_Time.empty()) + m_Time = TimeUtils::makeThreadTimeString(m_RawTime); + return m_Time; } time_t ThreadListItem::getRawTime() const { - return m_RawTime; + return m_RawTime; } ThreadId ThreadListItem::getThreadId() const { - return m_ThreadId; + return m_ThreadId; } std::string ThreadListItem::getUnreadCount() { - return m_UnreadCount; + return m_UnreadCount; } diff --git a/src/MsgThread/View/inc/NoContentListViewItem.h b/src/MsgThread/View/inc/NoContentListViewItem.h index 5af06eb..0f647f2 100644 --- a/src/MsgThread/View/inc/NoContentListViewItem.h +++ b/src/MsgThread/View/inc/NoContentListViewItem.h @@ -21,45 +21,45 @@ #include "LangUtils.h" namespace Msg { - class NoContentListViewItem - : public ListItem { - public: - NoContentListViewItem(); + class NoContentListViewItem + : public ListItem { + public: + NoContentListViewItem(); - void setText(std::string text); + void setText(std::string text); - protected: - void onAttached(ViewItem &item) override; + protected: + void onAttached(ViewItem &item) override; - private: - std::string getText(ListItem &item, const char *part) override; + private: + std::string getText(ListItem &item, const char *part) override; - private: - std::string m_Text; - }; + private: + std::string m_Text; + }; - inline NoContentListViewItem::NoContentListViewItem() - : ListItem(ListItemStyle::create("item_noncontents")) - { - } + inline NoContentListViewItem::NoContentListViewItem() + : ListItem(ListItemStyle::create("item_noncontents")) + { + } - inline void NoContentListViewItem::setText(std::string text) - { - m_Text = std::move(text); - } + inline void NoContentListViewItem::setText(std::string text) + { + m_Text = std::move(text); + } - inline std::string NoContentListViewItem::getText(ListItem &item, const char *part) - { - if (!strcmp(part, "elm.text")) - return (std::string)msg(m_Text.c_str()); + inline std::string NoContentListViewItem::getText(ListItem &item, const char *part) + { + if (!strcmp(part, "elm.text")) + return (std::string)msg(m_Text.c_str()); - return ""; - } + return ""; + } - inline void NoContentListViewItem::onAttached(ViewItem &item) - { - setSelectable(false); - } + inline void NoContentListViewItem::onAttached(ViewItem &item) + { + setSelectable(false); + } } #endif // NoContentListViewItem_h_ diff --git a/src/MsgThread/View/inc/ThreadComposeListViewItem.h b/src/MsgThread/View/inc/ThreadComposeListViewItem.h index 40f5e9b..ca74fd2 100644 --- a/src/MsgThread/View/inc/ThreadComposeListViewItem.h +++ b/src/MsgThread/View/inc/ThreadComposeListViewItem.h @@ -22,38 +22,38 @@ namespace Msg { - class IThreadComposeListViewItemListener; + class IThreadComposeListViewItemListener; - class ThreadComposeListViewItem - : public ListItem { + class ThreadComposeListViewItem + : public ListItem { - public: - ThreadComposeListViewItem(); - virtual ~ThreadComposeListViewItem(); + public: + ThreadComposeListViewItem(); + virtual ~ThreadComposeListViewItem(); - void setListener(IThreadComposeListViewItemListener *l); + void setListener(IThreadComposeListViewItemListener *l); - protected: - void onAttached(ViewItem &item) override; + protected: + void onAttached(ViewItem &item) override; - private: - Evas_Object *getComposeButton(); - Evas_Object *getContactsButton(); + private: + Evas_Object *getComposeButton(); + Evas_Object *getContactsButton(); - Evas_Object *makeButton(const std::string& iconName); - Evas_Object *getContent(ListItem &item, const char *part) override; - void makeAtspiButton(Evas_Object *btn, const std::string& text); + Evas_Object *makeButton(const std::string& iconName); + Evas_Object *getContent(ListItem &item, const char *part) override; + void makeAtspiButton(Evas_Object *btn, const std::string& text); - private: - IThreadComposeListViewItemListener *m_pListener; - }; + private: + IThreadComposeListViewItemListener *m_pListener; + }; - class IThreadComposeListViewItemListener { - public: - virtual ~IThreadComposeListViewItemListener() {}; - virtual void onComposeButtonClicked() {}; - virtual void onContactsButtonClicked() {}; - }; + class IThreadComposeListViewItemListener { + public: + virtual ~IThreadComposeListViewItemListener() {}; + virtual void onComposeButtonClicked() {}; + virtual void onContactsButtonClicked() {}; + }; } #endif // ThreadComposeListViewItem_h_ diff --git a/src/MsgThread/View/inc/ThreadListViewItem.h b/src/MsgThread/View/inc/ThreadListViewItem.h index 5a31361..dca6256 100644 --- a/src/MsgThread/View/inc/ThreadListViewItem.h +++ b/src/MsgThread/View/inc/ThreadListViewItem.h @@ -21,42 +21,42 @@ #include namespace Msg { - class ThreadListViewItem - : public ListItem { - public: - enum State { - NormalState, - IconState, - StatusState - }; - - public: - ThreadListViewItem(); - virtual ~ThreadListViewItem(); - - void setState(State state, bool updateUi); - State getState() const; - - protected: - virtual std::string getName() = 0; - virtual std::string getMessage() = 0; - virtual std::string getTime() = 0; - virtual std::string getUnreadCount() = 0; - - using ListItem::getState; - Evas_Object *makeUnreadIcon(const std::string &text) const; - - void onAttached(ViewItem &item) override; - - private: - std::string getText(ListItem &item, const char *part) override; - Evas_Object *getContent(ListItem &item, const char *part) override; - const char *getCheckPart(ListItem &item) override; - bool isCheckable() const override; - - private: - State m_State; - }; + class ThreadListViewItem + : public ListItem { + public: + enum State { + NormalState, + IconState, + StatusState + }; + + public: + ThreadListViewItem(); + virtual ~ThreadListViewItem(); + + void setState(State state, bool updateUi); + State getState() const; + + protected: + virtual std::string getName() = 0; + virtual std::string getMessage() = 0; + virtual std::string getTime() = 0; + virtual std::string getUnreadCount() = 0; + + using ListItem::getState; + Evas_Object *makeUnreadIcon(const std::string &text) const; + + void onAttached(ViewItem &item) override; + + private: + std::string getText(ListItem &item, const char *part) override; + Evas_Object *getContent(ListItem &item, const char *part) override; + const char *getCheckPart(ListItem &item) override; + bool isCheckable() const override; + + private: + State m_State; + }; } #endif // ThreadListViewItem_h_ diff --git a/src/MsgThread/View/src/ThreadComposeListViewItem.cpp b/src/MsgThread/View/src/ThreadComposeListViewItem.cpp index 708ce7b..827b1fa 100644 --- a/src/MsgThread/View/src/ThreadComposeListViewItem.cpp +++ b/src/MsgThread/View/src/ThreadComposeListViewItem.cpp @@ -24,13 +24,13 @@ using namespace Msg; namespace { - const char *iconComposePart = "elm.left"; - const char *iconContactsPart = "elm.right"; + const char *iconComposePart = "elm.left"; + const char *iconContactsPart = "elm.right"; } ThreadComposeListViewItem::ThreadComposeListViewItem() - : ListItem(ListItemStyle::create("compose_threadlist_item")) - , m_pListener(nullptr) + : ListItem(ListItemStyle::create("compose_threadlist_item")) + , m_pListener(nullptr) { } @@ -40,74 +40,74 @@ ThreadComposeListViewItem::~ThreadComposeListViewItem() Evas_Object *ThreadComposeListViewItem::getContent(ListItem &item, const char *part) { - Evas_Object *content = nullptr; + Evas_Object *content = nullptr; - if (!strcmp(part, iconComposePart)) - content = getComposeButton(); - else if (!strcmp(part, iconContactsPart)) - content = getContactsButton(); + if (!strcmp(part, iconComposePart)) + content = getComposeButton(); + else if (!strcmp(part, iconContactsPart)) + content = getContactsButton(); - return content; + return content; } void ThreadComposeListViewItem::onAttached(ViewItem &item) { - setSelectable(false); - getAtspi().canHighlight(false); + setSelectable(false); + getAtspi().canHighlight(false); } Evas_Object *ThreadComposeListViewItem::getComposeButton() { - Evas_Object *btn = makeButton("thread/compose_icon"); - evas_object_smart_callback_add( - btn, "clicked", - [](void *data, Evas_Object *obj, void *event) - { - auto *self = static_cast(data); - if (self && self->m_pListener) - self->m_pListener->onComposeButtonClicked(); - }, - this); - - makeAtspiButton(btn, msg("WDS_MSG_OPT_NEW_MESSAGE_ABB")); - - return btn; + Evas_Object *btn = makeButton("thread/compose_icon"); + evas_object_smart_callback_add( + btn, "clicked", + [](void *data, Evas_Object *obj, void *event) + { + auto *self = static_cast(data); + if (self && self->m_pListener) + self->m_pListener->onComposeButtonClicked(); + }, + this); + + makeAtspiButton(btn, msg("WDS_MSG_OPT_NEW_MESSAGE_ABB")); + + return btn; } Evas_Object *ThreadComposeListViewItem::getContactsButton() { - Evas_Object *btn = makeButton("thread/contacts_icon"); - evas_object_smart_callback_add( - btn, "clicked", - [](void *data, Evas_Object *obj, void *event) - { - auto *self = static_cast(data); - if (self && self->m_pListener) - self->m_pListener->onContactsButtonClicked(); - }, - this); - - makeAtspiButton(btn, msg("IDS_PB_BODY_CONTACTS_ABB")); - - return btn; + Evas_Object *btn = makeButton("thread/contacts_icon"); + evas_object_smart_callback_add( + btn, "clicked", + [](void *data, Evas_Object *obj, void *event) + { + auto *self = static_cast(data); + if (self && self->m_pListener) + self->m_pListener->onContactsButtonClicked(); + }, + this); + + makeAtspiButton(btn, msg("IDS_PB_BODY_CONTACTS_ABB")); + + return btn; } Evas_Object *ThreadComposeListViewItem::makeButton(const std::string& iconName) { - Evas_Object *button = View::addIconButton(*getOwner(), iconName); - return button; + Evas_Object *button = View::addIconButton(*getOwner(), iconName); + return button; } void ThreadComposeListViewItem::makeAtspiButton(Evas_Object *btn, const std::string& text) { - Atspi ao = Atspi(btn); - ao.setName(text); - ao.setRole(ELM_ATSPI_ROLE_PUSH_BUTTON); - ao.setReadingInfo((Elm_Accessible_Reading_Info_Type)(ELM_ACCESSIBLE_READING_INFO_TYPE_NAME | ELM_ACCESSIBLE_READING_INFO_TYPE_ROLE)); + Atspi ao = Atspi(btn); + ao.setName(text); + ao.setRole(ELM_ATSPI_ROLE_PUSH_BUTTON); + ao.setReadingInfo((Elm_Accessible_Reading_Info_Type)(ELM_ACCESSIBLE_READING_INFO_TYPE_NAME | ELM_ACCESSIBLE_READING_INFO_TYPE_ROLE)); } void ThreadComposeListViewItem::setListener(IThreadComposeListViewItemListener *l) { - m_pListener = l; + m_pListener = l; } diff --git a/src/MsgThread/View/src/ThreadListViewItem.cpp b/src/MsgThread/View/src/ThreadListViewItem.cpp index 6edbdb4..a800365 100644 --- a/src/MsgThread/View/src/ThreadListViewItem.cpp +++ b/src/MsgThread/View/src/ThreadListViewItem.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -27,18 +27,18 @@ using namespace Msg; namespace { - const char *namePart = "elm.text.sliding"; - const char *namePartMask = "elm.text"; - const char *messagePart = "elm.text.1"; - const char *timePart = "elm.text.2"; - const char *checkBoxPart = "elm.swallow.center_check"; - const char *iconPart = "elm.icon"; - const char *iconPaddingPart = "elm.icon2"; + const char *namePart = "elm.text.sliding"; + const char *namePartMask = "elm.text"; + const char *messagePart = "elm.text.1"; + const char *timePart = "elm.text.2"; + const char *checkBoxPart = "elm.swallow.center_check"; + const char *iconPart = "elm.icon"; + const char *iconPaddingPart = "elm.icon2"; } ThreadListViewItem::ThreadListViewItem() - : ListItem(ListItemStyle::create("preview_msg_list_item"), ELM_GENLIST_ITEM_NONE) - , m_State(NormalState) + : ListItem(ListItemStyle::create("preview_msg_list_item"), ELM_GENLIST_ITEM_NONE) + , m_State(NormalState) { } @@ -48,74 +48,74 @@ ThreadListViewItem::~ThreadListViewItem() std::string ThreadListViewItem::getText(ListItem &item, const char *part) { - if (!strcmp(part, messagePart)) { - return getMessage(); - } else if (!strcmp(part, namePart) || !strcmp(part, namePartMask)) { - return getName(); - } else if (!strcmp(part, timePart)) { - return getTime(); - } - - return ""; + if (!strcmp(part, messagePart)) { + return getMessage(); + } else if (!strcmp(part, namePart) || !strcmp(part, namePartMask)) { + return getName(); + } else if (!strcmp(part, timePart)) { + return getTime(); + } + + return ""; } Evas_Object *ThreadListViewItem::getContent(ListItem &item, const char *part) { - Evas_Object *content = nullptr; + Evas_Object *content = nullptr; - if (m_State == IconState && (!strcmp(part, iconPart) || !strcmp(part, iconPaddingPart))) - content = makeUnreadIcon(getUnreadCount()); + if (m_State == IconState && (!strcmp(part, iconPart) || !strcmp(part, iconPaddingPart))) + content = makeUnreadIcon(getUnreadCount()); - return content; + return content; } const char *ThreadListViewItem::getCheckPart(ListItem &item) { - return checkBoxPart; + return checkBoxPart; } bool ThreadListViewItem::isCheckable() const { - return true; + return true; } void ThreadListViewItem::setState(State state, bool updateUi) { - m_State = state; - if (updateUi) - updateFields(iconPart, ELM_GENLIST_ITEM_FIELD_CONTENT); + m_State = state; + if (updateUi) + updateFields(iconPart, ELM_GENLIST_ITEM_FIELD_CONTENT); } ThreadListViewItem::State ThreadListViewItem::getState() const { - return m_State; + return m_State; } Evas_Object *ThreadListViewItem::makeUnreadIcon(const std::string &text) const { - if (text.empty()) - return nullptr; - Evas_Object *icon = View::addLayout(*getOwner(), ICONS_EDJ_PATH, "badge"); - elm_object_part_text_set(icon, "elm.text.count", text.c_str()); - evas_object_show(icon); - return icon; + if (text.empty()) + return nullptr; + Evas_Object *icon = View::addLayout(*getOwner(), ICONS_EDJ_PATH, "badge"); + elm_object_part_text_set(icon, "elm.text.count", text.c_str()); + evas_object_show(icon); + return icon; } void ThreadListViewItem::onAttached(ViewItem &item) { - getAtspi().setName(getName()); - std::string subText = " "; - int unreadCount = atoi(getUnreadCount().c_str()); + getAtspi().setName(getName()); + std::string subText = " "; + int unreadCount = atoi(getUnreadCount().c_str()); - if (unreadCount > 0) { - subText += msgArgs("IDS_TTS_BODY_PD_UNREAD_MESSAGES", unreadCount); - subText += " "; - } + if (unreadCount > 0) { + subText += msgArgs("IDS_TTS_BODY_PD_UNREAD_MESSAGES", unreadCount); + subText += " "; + } - subText += getMessage(); - subText += " "; - subText += getTime(); + subText += getMessage(); + subText += " "; + subText += getTime(); - getAtspi().setDescription(subText); - getAtspi().setReadingInfo((Elm_Accessible_Reading_Info_Type)(ELM_ACCESSIBLE_READING_INFO_TYPE_NAME | ELM_ACCESSIBLE_READING_INFO_TYPE_DESCRIPTION)); + getAtspi().setDescription(subText); + getAtspi().setReadingInfo((Elm_Accessible_Reading_Info_Type)(ELM_ACCESSIBLE_READING_INFO_TYPE_NAME | ELM_ACCESSIBLE_READING_INFO_TYPE_DESCRIPTION)); } diff --git a/src/Settings/Controller/inc/BlockedMsgListItem.h b/src/Settings/Controller/inc/BlockedMsgListItem.h index ae521c3..c774c9a 100644 --- a/src/Settings/Controller/inc/BlockedMsgListItem.h +++ b/src/Settings/Controller/inc/BlockedMsgListItem.h @@ -20,18 +20,18 @@ #include "BlockedMsgListViewItem.h" namespace Msg { - class BlockedMsgListItem - : public BlockedMsgListViewItem { + class BlockedMsgListItem + : public BlockedMsgListViewItem { - public: - BlockedMsgListItem(); - virtual ~BlockedMsgListItem(); + public: + BlockedMsgListItem(); + virtual ~BlockedMsgListItem(); - private: - std::string getName() override; - std::string getMessage() override; - std::string getTime() override; - }; + private: + std::string getName() override; + std::string getMessage() override; + std::string getTime() override; + }; } #endif // BlockedMsgListItem_h_ diff --git a/src/Settings/Controller/inc/BlockedNumberListItem.h b/src/Settings/Controller/inc/BlockedNumberListItem.h index 5a31e16..7477e2f 100644 --- a/src/Settings/Controller/inc/BlockedNumberListItem.h +++ b/src/Settings/Controller/inc/BlockedNumberListItem.h @@ -20,17 +20,17 @@ #include "BlockedNumberListViewItem.h" namespace Msg { - class BlockedNumberListItem - : public BlockedNumberListViewItem { + class BlockedNumberListItem + : public BlockedNumberListViewItem { - public: - BlockedNumberListItem(); - virtual ~BlockedNumberListItem(); + public: + BlockedNumberListItem(); + virtual ~BlockedNumberListItem(); - private: - std::string getAddress() override; - std::string getContactName() override; - }; + private: + std::string getAddress() override; + std::string getContactName() override; + }; } #endif // BlockedNumberListItem_h_ diff --git a/src/Settings/Controller/inc/SettingsBlockListFrame.h b/src/Settings/Controller/inc/SettingsBlockListFrame.h index fe3a3e1..2dad384 100644 --- a/src/Settings/Controller/inc/SettingsBlockListFrame.h +++ b/src/Settings/Controller/inc/SettingsBlockListFrame.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -23,76 +23,76 @@ namespace Msg { - class ListView; - class ListItem; - class DefaultLayout; - class MoreOption; - class BottomButton; - class CtxPopupItem; - class SelectButton; - class PaddingListViewItem; - class NoContentLayout; + class ListView; + class ListItem; + class DefaultLayout; + class MoreOption; + class BottomButton; + class CtxPopupItem; + class SelectButton; + class PaddingListViewItem; + class NoContentLayout; - class SettingsBlockListFrame - : public FrameController - , private IListViewListener - , private ISystemSettingsManager { + class SettingsBlockListFrame + : public FrameController + , private IListViewListener + , private ISystemSettingsManager { - public: - enum BlockListType { - BlockedNumType, - BlockedMsgType - }; + public: + enum BlockListType { + BlockedNumType, + BlockedMsgType + }; - SettingsBlockListFrame(NaviFrameController &parent, BlockListType type); - virtual ~SettingsBlockListFrame(); + SettingsBlockListFrame(NaviFrameController &parent, BlockListType type); + virtual ~SettingsBlockListFrame(); - protected: - // NaviFrameItem: - void onAttached(ViewItem &item) override; + protected: + // NaviFrameItem: + void onAttached(ViewItem &item) override; - private: - // Select mode cb: - void onDoneButtonClicked(Evas_Object *obj, void *event); - void onSelectButtonClicked(Evas_Object *obj, void *event); - void onSelectAllButtonClicked(CtxPopupItem &item); - void onDeselectAllButtonClicked(CtxPopupItem &item); + private: + // Select mode cb: + void onDoneButtonClicked(Evas_Object *obj, void *event); + void onSelectButtonClicked(Evas_Object *obj, void *event); + void onSelectAllButtonClicked(CtxPopupItem &item); + void onDeselectAllButtonClicked(CtxPopupItem &item); - // More option: - void onRestoreClicked(MoreOption &obj); - void onDeleteClicked(MoreOption &obj); + // More option: + void onRestoreClicked(MoreOption &obj); + void onDeleteClicked(MoreOption &obj); - // IListViewListener: - void onListItemSelected(ListItem &listItem) override; + // IListViewListener: + void onListItemSelected(ListItem &listItem) override; - // ISystemSettingsManager: - void onTimeFormatChanged() override; - void onLanguageChanged() override; + // ISystemSettingsManager: + void onTimeFormatChanged() override; + void onLanguageChanged() override; - void prepareMainLayout(); - void prepareMoreOption(); - void prepareSelectViews(); - void preapareList(); - void prepareNoContent(); - void updateCheckViews(); - void fillList(); - void setSelectMode(bool value); - void showSelectPopup(); - void updateNoContent(); - void updateLangInfo(); - void insertItem(ListItem *item); + void prepareMainLayout(); + void prepareMoreOption(); + void prepareSelectViews(); + void preapareList(); + void prepareNoContent(); + void updateCheckViews(); + void fillList(); + void setSelectMode(bool value); + void showSelectPopup(); + void updateNoContent(); + void updateLangInfo(); + void insertItem(ListItem *item); - private: - const BlockListType m_BlockListType; - bool m_IsSelectMode; - DefaultLayout *m_pLayout; - MoreOption *m_pMoreOption; - BottomButton *m_pDoneButton; - SelectButton *m_pSelectButton; - ListView *m_pList; - PaddingListViewItem *m_pBottomItem; - NoContentLayout *m_pNoContent; - }; + private: + const BlockListType m_BlockListType; + bool m_IsSelectMode; + DefaultLayout *m_pLayout; + MoreOption *m_pMoreOption; + BottomButton *m_pDoneButton; + SelectButton *m_pSelectButton; + ListView *m_pList; + PaddingListViewItem *m_pBottomItem; + NoContentLayout *m_pNoContent; + }; } #endif /* SettingsBlockListFrame_h_ */ diff --git a/src/Settings/Controller/inc/SettingsBlockedMsgDetailFrame.h b/src/Settings/Controller/inc/SettingsBlockedMsgDetailFrame.h index ecdf776..46c7335 100644 --- a/src/Settings/Controller/inc/SettingsBlockedMsgDetailFrame.h +++ b/src/Settings/Controller/inc/SettingsBlockedMsgDetailFrame.h @@ -20,31 +20,31 @@ #include "FrameController.h" namespace Msg { - class MoreOption; - class DefaultLayout; - - class SettingsBlockedMsgDetailFrame - : public FrameController { - public: - SettingsBlockedMsgDetailFrame(NaviFrameController &parent); - virtual ~SettingsBlockedMsgDetailFrame(); - - protected: - // NaviFrameItem: - void onAttached(ViewItem &item) override; - - private: - // More option: - void onRestoreClicked(MoreOption &obj); - void onDeleteClicked(MoreOption &obj); - - void prepareMainLayout(); - void prepareMoreOption(); - - private: - DefaultLayout *m_pLayout; - MoreOption *m_pMoreOption; - }; + class MoreOption; + class DefaultLayout; + + class SettingsBlockedMsgDetailFrame + : public FrameController { + public: + SettingsBlockedMsgDetailFrame(NaviFrameController &parent); + virtual ~SettingsBlockedMsgDetailFrame(); + + protected: + // NaviFrameItem: + void onAttached(ViewItem &item) override; + + private: + // More option: + void onRestoreClicked(MoreOption &obj); + void onDeleteClicked(MoreOption &obj); + + void prepareMainLayout(); + void prepareMoreOption(); + + private: + DefaultLayout *m_pLayout; + MoreOption *m_pMoreOption; + }; } #endif // SettingsBlockedMsgDetailFrame_h_ diff --git a/src/Settings/Controller/inc/SettingsFrame.h b/src/Settings/Controller/inc/SettingsFrame.h index 59fea87..48f382b 100644 --- a/src/Settings/Controller/inc/SettingsFrame.h +++ b/src/Settings/Controller/inc/SettingsFrame.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -23,50 +23,50 @@ namespace Msg { - class SettingsMenuListItem; + class SettingsMenuListItem; - /** - * @brief A core-class responsible for a whole lifecycle of settings-module and for managing - * sub-components of message settings. - */ - class SettingsFrame - : public FrameController - , private IListViewListener - , private IMsgSettingsListener { + /** + * @brief A core-class responsible for a whole lifecycle of settings-module and for managing + * sub-components of message settings. + */ + class SettingsFrame + : public FrameController + , private IListViewListener + , private IMsgSettingsListener { - public: - /** - * @brief A constructor of Settings object based on outside parent object. - * @param[in] parent an object responsible for automatic removing of Settings instance. - */ - SettingsFrame(NaviFrameController &parent); - virtual ~SettingsFrame(); + public: + /** + * @brief A constructor of Settings object based on outside parent object. + * @param[in] parent an object responsible for automatic removing of Settings instance. + */ + SettingsFrame(NaviFrameController &parent); + virtual ~SettingsFrame(); - private: - // NaviFrameItem: - void onAttached(ViewItem &item) override; + private: + // NaviFrameItem: + void onAttached(ViewItem &item) override; - // ListView: - void onSountItemSelected(ListItem &item); - void onSountItemChecked(SettingsMenuListItem &item); - void onBlockListSelected(ListItem &item); + // ListView: + void onSountItemSelected(ListItem &item); + void onSountItemChecked(SettingsMenuListItem &item); + void onBlockListSelected(ListItem &item); - // IMsgSettingsListener: - void onSendAsAudioChanged(MsgSettings &msgSetting) override; + // IMsgSettingsListener: + void onSendAsAudioChanged(MsgSettings &msgSetting) override; - private: - void preapareList(); - void fillList(); + private: + void preapareList(); + void fillList(); - void updateItems(); - void updateAudioItem(); - void updateBlockListItem(); + void updateItems(); + void updateAudioItem(); + void updateBlockListItem(); - private: - ListView *m_pList; - SettingsMenuListItem *m_pAudioItem; - SettingsMenuListItem *m_pBlockListItem; - }; + private: + ListView *m_pList; + SettingsMenuListItem *m_pAudioItem; + SettingsMenuListItem *m_pBlockListItem; + }; } #endif /* SettingsFrame_h_ */ diff --git a/src/Settings/Controller/inc/SettingsMenuBlockListFrame.h b/src/Settings/Controller/inc/SettingsMenuBlockListFrame.h index f9c5bfe..d2825c0 100644 --- a/src/Settings/Controller/inc/SettingsMenuBlockListFrame.h +++ b/src/Settings/Controller/inc/SettingsMenuBlockListFrame.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -20,29 +20,29 @@ #include "FrameController.h" namespace Msg { - class ListView; - class ListItem; + class ListView; + class ListItem; - class SettingsMenuBlockListFrame - : public FrameController { - public: - SettingsMenuBlockListFrame(NaviFrameController &parent); - virtual ~SettingsMenuBlockListFrame(); + class SettingsMenuBlockListFrame + : public FrameController { + public: + SettingsMenuBlockListFrame(NaviFrameController &parent); + virtual ~SettingsMenuBlockListFrame(); - protected: - // NaviFrameItem: - void onAttached(ViewItem &item) override; + protected: + // NaviFrameItem: + void onAttached(ViewItem &item) override; - private: - void onBlockedNumberSelected(ListItem &listItem); - void onBlockedMsgSelected(ListItem &listItem); + private: + void onBlockedNumberSelected(ListItem &listItem); + void onBlockedMsgSelected(ListItem &listItem); - void preapareList(); - void fillList(); + void preapareList(); + void fillList(); - private: - ListView *m_pList; - }; + private: + ListView *m_pList; + }; } #endif /* SettingsMenuBlockListFrame_h_ */ diff --git a/src/Settings/Controller/src/BlockedMsgListItem.cpp b/src/Settings/Controller/src/BlockedMsgListItem.cpp index 938744e..201598b 100644 --- a/src/Settings/Controller/src/BlockedMsgListItem.cpp +++ b/src/Settings/Controller/src/BlockedMsgListItem.cpp @@ -30,19 +30,19 @@ BlockedMsgListItem::~BlockedMsgListItem() std::string BlockedMsgListItem::getName() { - // TODO: impl. - return "Name"; + // TODO: impl. + return "Name"; } std::string BlockedMsgListItem::getMessage() { - // TODO: impl. - return "Message"; + // TODO: impl. + return "Message"; } std::string BlockedMsgListItem::getTime() { - // TODO: impl. - return ""; + // TODO: impl. + return ""; } diff --git a/src/Settings/Controller/src/BlockedNumberListItem.cpp b/src/Settings/Controller/src/BlockedNumberListItem.cpp index ff551ad..d5392c3 100644 --- a/src/Settings/Controller/src/BlockedNumberListItem.cpp +++ b/src/Settings/Controller/src/BlockedNumberListItem.cpp @@ -20,7 +20,7 @@ using namespace Msg; BlockedNumberListItem::BlockedNumberListItem() { - // TODO: impl. + // TODO: impl. } BlockedNumberListItem::~BlockedNumberListItem() @@ -29,12 +29,12 @@ BlockedNumberListItem::~BlockedNumberListItem() std::string BlockedNumberListItem::getAddress() { - // TODO: impl. - return "Address"; + // TODO: impl. + return "Address"; } std::string BlockedNumberListItem::getContactName() { - // TODO: impl. - return "Name"; + // TODO: impl. + return "Name"; } diff --git a/src/Settings/Controller/src/SettingsBlockListFrame.cpp b/src/Settings/Controller/src/SettingsBlockListFrame.cpp index ea9c81c..1d05acc 100644 --- a/src/Settings/Controller/src/SettingsBlockListFrame.cpp +++ b/src/Settings/Controller/src/SettingsBlockListFrame.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -34,241 +34,241 @@ using namespace Msg; SettingsBlockListFrame::SettingsBlockListFrame(NaviFrameController &parent, BlockListType type) - : FrameController(parent, SettingsGroup) - , m_BlockListType(type) - , m_IsSelectMode(false) - , m_pLayout(nullptr) - , m_pMoreOption(nullptr) - , m_pDoneButton(nullptr) - , m_pSelectButton(nullptr) - , m_pList(nullptr) - , m_pBottomItem(nullptr) - , m_pNoContent(nullptr) + : FrameController(parent, SettingsGroup) + , m_BlockListType(type) + , m_IsSelectMode(false) + , m_pLayout(nullptr) + , m_pMoreOption(nullptr) + , m_pDoneButton(nullptr) + , m_pSelectButton(nullptr) + , m_pList(nullptr) + , m_pBottomItem(nullptr) + , m_pNoContent(nullptr) { - MSG_LOG(""); - prepareMainLayout(); - prepareMoreOption(); - preapareList(); - updateNoContent(); - App::getInst().getSysSettingsManager().addListener(*this); + MSG_LOG(""); + prepareMainLayout(); + prepareMoreOption(); + preapareList(); + updateNoContent(); + App::getInst().getSysSettingsManager().addListener(*this); } SettingsBlockListFrame::~SettingsBlockListFrame() { - App::getInst().getSysSettingsManager().removeListener(*this); + App::getInst().getSysSettingsManager().removeListener(*this); } void SettingsBlockListFrame::setSelectMode(bool value) { - if (value == m_IsSelectMode) - return; - - m_IsSelectMode = value; - m_pLayout->showBottomButton(value); - m_pLayout->showMoreOption(!value); - - if (value) { - prepareSelectViews(); - m_pSelectButton->setText("0"); - m_pSelectButton->showButton(true); - m_pDoneButton->disabled(true); - } else { - if (m_pSelectButton) - m_pSelectButton->showButton(false); - } + if (value == m_IsSelectMode) + return; + + m_IsSelectMode = value; + m_pLayout->showBottomButton(value); + m_pLayout->showMoreOption(!value); + + if (value) { + prepareSelectViews(); + m_pSelectButton->setText("0"); + m_pSelectButton->showButton(true); + m_pDoneButton->disabled(true); + } else { + if (m_pSelectButton) + m_pSelectButton->showButton(false); + } } void SettingsBlockListFrame::prepareMainLayout() { - if (!m_pLayout) { - m_pLayout = new DefaultLayout(getParent()); - m_pLayout->showSelectButton(true); - m_pLayout->showMoreOption(true); - } + if (!m_pLayout) { + m_pLayout = new DefaultLayout(getParent()); + m_pLayout->showSelectButton(true); + m_pLayout->showMoreOption(true); + } } void SettingsBlockListFrame::preapareList() { - if (!m_pList) { - m_pList = new ListView(getParent(), App::getInst().getWindow().getCircleSurface()); - m_pList->setHomogeneous(false); - m_pList->setMultiSelection(false); - m_pList->setListener(this); - m_pLayout->setContent(*m_pList); - fillList(); - } + if (!m_pList) { + m_pList = new ListView(getParent(), App::getInst().getWindow().getCircleSurface()); + m_pList->setHomogeneous(false); + m_pList->setMultiSelection(false); + m_pList->setListener(this); + m_pLayout->setContent(*m_pList); + fillList(); + } } void SettingsBlockListFrame::prepareNoContent() { - if (!m_pNoContent) { - m_pNoContent = new NoContentLayout(*m_pLayout); - m_pNoContent->enableTitle(true); + if (!m_pNoContent) { + m_pNoContent = new NoContentLayout(*m_pLayout); + m_pNoContent->enableTitle(true); - Evas_Object *img = elm_image_add(*m_pNoContent); - std::string imgPath = PathUtils::getResourcePath(IMAGES_EDJ_PATH); - elm_image_file_set(img, imgPath.c_str(), NO_SPAM_MSG_ICON); + Evas_Object *img = elm_image_add(*m_pNoContent); + std::string imgPath = PathUtils::getResourcePath(IMAGES_EDJ_PATH); + elm_image_file_set(img, imgPath.c_str(), NO_SPAM_MSG_ICON); - m_pNoContent->setIcon(img); - m_pLayout->setNoContent(*m_pNoContent); - } + m_pNoContent->setIcon(img); + m_pLayout->setNoContent(*m_pNoContent); + } } void SettingsBlockListFrame::fillList() { - // Title: - auto *titleItem = new TitleListItem; - const char *titleStr = m_BlockListType == BlockedMsgType ? "WDS_MSG_MBODY_BLOCKED_MESSAGES" - : "WDS_MSG_MBODY_BLOCKED_NUMBERS"; - titleItem->setTitle(msg(titleStr)); - m_pList->appendItem(*titleItem); - - // Bottom padding: - m_pBottomItem = new PaddingListViewItem; - insertItem(m_pBottomItem); + // Title: + auto *titleItem = new TitleListItem; + const char *titleStr = m_BlockListType == BlockedMsgType ? "WDS_MSG_MBODY_BLOCKED_MESSAGES" + : "WDS_MSG_MBODY_BLOCKED_NUMBERS"; + titleItem->setTitle(msg(titleStr)); + m_pList->appendItem(*titleItem); + + // Bottom padding: + m_pBottomItem = new PaddingListViewItem; + insertItem(m_pBottomItem); } void SettingsBlockListFrame::prepareMoreOption() { - if (!m_pMoreOption) { - m_pMoreOption = new MoreOption(*m_pLayout); - m_pMoreOption->setDirection(EEXT_MORE_OPTION_DIRECTION_RIGHT); - m_pMoreOption->appendItem(msgt("WDS_MSG_OPT_RESTORE_ABB"), RESTORE_MORE_ICON, makeCbLast(&SettingsBlockListFrame::onRestoreClicked), this); - m_pMoreOption->appendItem(msgt("WDS_MSG_OPT_DELETE_ABB"), DELETEG_MORE_ICON, makeCbLast(&SettingsBlockListFrame::onDeleteClicked), this); - m_pLayout->setMoreOption(*m_pMoreOption); - } + if (!m_pMoreOption) { + m_pMoreOption = new MoreOption(*m_pLayout); + m_pMoreOption->setDirection(EEXT_MORE_OPTION_DIRECTION_RIGHT); + m_pMoreOption->appendItem(msgt("WDS_MSG_OPT_RESTORE_ABB"), RESTORE_MORE_ICON, makeCbLast(&SettingsBlockListFrame::onRestoreClicked), this); + m_pMoreOption->appendItem(msgt("WDS_MSG_OPT_DELETE_ABB"), DELETEG_MORE_ICON, makeCbLast(&SettingsBlockListFrame::onDeleteClicked), this); + m_pLayout->setMoreOption(*m_pMoreOption); + } } void SettingsBlockListFrame::prepareSelectViews() { - if (!m_pDoneButton) { - m_pDoneButton = new BottomButton(*m_pLayout); - m_pDoneButton->setText(msgt("IDS_MSG_ACBUTTON_DELETE_ABB")); - View::addSmartCb(m_pDoneButton->getInnerButton(), "clicked", makeCbFirst(&SettingsBlockListFrame::onDoneButtonClicked), this); - m_pLayout->setBottomButton(*m_pDoneButton); - } - - if (!m_pSelectButton) { - m_pSelectButton = new SelectButton(*m_pLayout); - View::addSmartCb(m_pSelectButton->getInnerButton(), "clicked", makeCbFirst(&SettingsBlockListFrame::onSelectButtonClicked), this); - m_pLayout->setSelectButton(*m_pSelectButton); - } + if (!m_pDoneButton) { + m_pDoneButton = new BottomButton(*m_pLayout); + m_pDoneButton->setText(msgt("IDS_MSG_ACBUTTON_DELETE_ABB")); + View::addSmartCb(m_pDoneButton->getInnerButton(), "clicked", makeCbFirst(&SettingsBlockListFrame::onDoneButtonClicked), this); + m_pLayout->setBottomButton(*m_pDoneButton); + } + + if (!m_pSelectButton) { + m_pSelectButton = new SelectButton(*m_pLayout); + View::addSmartCb(m_pSelectButton->getInnerButton(), "clicked", makeCbFirst(&SettingsBlockListFrame::onSelectButtonClicked), this); + m_pLayout->setSelectButton(*m_pSelectButton); + } } void SettingsBlockListFrame::updateCheckViews() { - if (m_IsSelectMode) { - int count = m_pList->getCheckedItemsCount(); - m_pSelectButton->setText(std::to_string(count)); - m_pDoneButton->disabled(count <= 0); - } + if (m_IsSelectMode) { + int count = m_pList->getCheckedItemsCount(); + m_pSelectButton->setText(std::to_string(count)); + m_pDoneButton->disabled(count <= 0); + } } void SettingsBlockListFrame::showSelectPopup() { - auto *ctx = new SelectCtxPopup; - int checkedCount = m_pList->getCheckedItemsCount(); - int checkableCount = m_pList->getCheckableItemsCount(); + auto *ctx = new SelectCtxPopup; + int checkedCount = m_pList->getCheckedItemsCount(); + int checkableCount = m_pList->getCheckableItemsCount(); - if (checkedCount < checkableCount) - ctx->appendTopItem(msgt("WDS_MSG_OPT_SELECT_ALL_ABB"), makeCbLast(&SettingsBlockListFrame::onSelectAllButtonClicked), this); - if (checkedCount > 0) - ctx->appendBottomItem(msgt("WDS_MSG_OPT_DESELECT_ALL_ABB"), makeCbLast(&SettingsBlockListFrame::onDeselectAllButtonClicked), this); + if (checkedCount < checkableCount) + ctx->appendTopItem(msgt("WDS_MSG_OPT_SELECT_ALL_ABB"), makeCbLast(&SettingsBlockListFrame::onSelectAllButtonClicked), this); + if (checkedCount > 0) + ctx->appendBottomItem(msgt("WDS_MSG_OPT_DESELECT_ALL_ABB"), makeCbLast(&SettingsBlockListFrame::onDeselectAllButtonClicked), this); - if (m_pSelectButton) - ctx->align(m_pSelectButton->getInnerButton()); + if (m_pSelectButton) + ctx->align(m_pSelectButton->getInnerButton()); - ctx->go(); + ctx->go(); } void SettingsBlockListFrame::updateNoContent() { - int count = m_BlockListType == BlockedNumType ? m_pList->getItemsCount() - : m_pList->getItemsCount(); - bool noContent = count <= 0; - - if (noContent) { - const char *text = m_BlockListType == BlockedNumType ? "WDS_MSG_NPBODY_NO_BLOCKED_NUMBERS_ABB" - : "WDS_MSG_NPBODY_NO_BLOCKED_MESSAGES_ABB"; - const char *title = m_BlockListType == BlockedMsgType ? "WDS_MSG_MBODY_BLOCKED_MESSAGES" - : "WDS_MSG_MBODY_BLOCKED_NUMBERS"; - prepareNoContent(); - m_pNoContent->setTitle(msgt(title)); - m_pNoContent->setText(msgt(text)); - } - - m_pLayout->showNoContent(noContent); - m_pLayout->showContent(!noContent); - m_pLayout->showMoreOption(!noContent); + int count = m_BlockListType == BlockedNumType ? m_pList->getItemsCount() + : m_pList->getItemsCount(); + bool noContent = count <= 0; + + if (noContent) { + const char *text = m_BlockListType == BlockedNumType ? "WDS_MSG_NPBODY_NO_BLOCKED_NUMBERS_ABB" + : "WDS_MSG_NPBODY_NO_BLOCKED_MESSAGES_ABB"; + const char *title = m_BlockListType == BlockedMsgType ? "WDS_MSG_MBODY_BLOCKED_MESSAGES" + : "WDS_MSG_MBODY_BLOCKED_NUMBERS"; + prepareNoContent(); + m_pNoContent->setTitle(msgt(title)); + m_pNoContent->setText(msgt(text)); + } + + m_pLayout->showNoContent(noContent); + m_pLayout->showContent(!noContent); + m_pLayout->showMoreOption(!noContent); } void SettingsBlockListFrame::updateLangInfo() { - m_pList->updateRealizedItems(); - // TODO: update items + m_pList->updateRealizedItems(); + // TODO: update items } void SettingsBlockListFrame::insertItem(ListItem *item) { - if(m_pBottomItem && m_pBottomItem != item) - m_pList->insertBeforeItem(*item, *m_pBottomItem); - else - m_pList->appendItem(*item); + if(m_pBottomItem && m_pBottomItem != item) + m_pList->insertBeforeItem(*item, *m_pBottomItem); + else + m_pList->appendItem(*item); } void SettingsBlockListFrame::onAttached(ViewItem &item) { - FrameController::onAttached(item); - setContent(*m_pLayout); + FrameController::onAttached(item); + setContent(*m_pLayout); } void SettingsBlockListFrame::onSelectAllButtonClicked(CtxPopupItem &item) { - MSG_LOG(""); + MSG_LOG(""); } void SettingsBlockListFrame::onDeselectAllButtonClicked(CtxPopupItem &item) { - MSG_LOG(""); + MSG_LOG(""); } void SettingsBlockListFrame::onRestoreClicked(MoreOption &obj) { - MSG_LOG(""); + MSG_LOG(""); } void SettingsBlockListFrame::onDeleteClicked(MoreOption &obj) { - MSG_LOG(""); - setSelectMode(true); + MSG_LOG(""); + setSelectMode(true); } void SettingsBlockListFrame::onDoneButtonClicked(Evas_Object *obj, void *event) { - MSG_LOG(""); - setSelectMode(false); + MSG_LOG(""); + setSelectMode(false); } void SettingsBlockListFrame::onSelectButtonClicked(Evas_Object *obj, void *event) { - MSG_LOG(""); + MSG_LOG(""); } void SettingsBlockListFrame::onListItemSelected(ListItem &listItem) { - MSG_LOG(""); - auto *frame = new SettingsBlockedMsgDetailFrame(getParent()); - getParent().push(*frame); + MSG_LOG(""); + auto *frame = new SettingsBlockedMsgDetailFrame(getParent()); + getParent().push(*frame); } void SettingsBlockListFrame::onTimeFormatChanged() { - MSG_LOG(""); + MSG_LOG(""); } void SettingsBlockListFrame::onLanguageChanged() { - MSG_LOG(""); - updateLangInfo(); + MSG_LOG(""); + updateLangInfo(); } diff --git a/src/Settings/Controller/src/SettingsBlockedMsgDetailFrame.cpp b/src/Settings/Controller/src/SettingsBlockedMsgDetailFrame.cpp index c77d0bf..9943654 100644 --- a/src/Settings/Controller/src/SettingsBlockedMsgDetailFrame.cpp +++ b/src/Settings/Controller/src/SettingsBlockedMsgDetailFrame.cpp @@ -24,12 +24,12 @@ using namespace Msg; SettingsBlockedMsgDetailFrame::SettingsBlockedMsgDetailFrame(NaviFrameController &parent) - : FrameController(parent, SettingsGroup) - , m_pLayout(nullptr) - , m_pMoreOption(nullptr) + : FrameController(parent, SettingsGroup) + , m_pLayout(nullptr) + , m_pMoreOption(nullptr) { - prepareMainLayout(); - prepareMoreOption(); + prepareMainLayout(); + prepareMoreOption(); } SettingsBlockedMsgDetailFrame::~SettingsBlockedMsgDetailFrame() @@ -38,41 +38,41 @@ SettingsBlockedMsgDetailFrame::~SettingsBlockedMsgDetailFrame() void SettingsBlockedMsgDetailFrame::onAttached(ViewItem &item) { - MSG_LOG(""); - FrameController::onAttached(item); - setContent(*m_pLayout); + MSG_LOG(""); + FrameController::onAttached(item); + setContent(*m_pLayout); } void SettingsBlockedMsgDetailFrame::prepareMainLayout() { - if (!m_pLayout) { - m_pLayout = new DefaultLayout(getParent()); - m_pLayout->showMoreOption(true); - } + if (!m_pLayout) { + m_pLayout = new DefaultLayout(getParent()); + m_pLayout->showMoreOption(true); + } } void SettingsBlockedMsgDetailFrame::prepareMoreOption() { - if (!m_pMoreOption) { - m_pMoreOption = new MoreOption(*m_pLayout); - m_pMoreOption->setDirection(EEXT_MORE_OPTION_DIRECTION_RIGHT); - m_pMoreOption->appendItem(msgt("WDS_MSG_OPT_RESTORE_ABB"), RESTORE_MORE_ICON, makeCbLast(&SettingsBlockedMsgDetailFrame::onRestoreClicked), this); - m_pMoreOption->appendItem(msgt("WDS_MSG_OPT_DELETE_ABB"), DELETEG_MORE_ICON, makeCbLast(&SettingsBlockedMsgDetailFrame::onDeleteClicked), this); - m_pLayout->setMoreOption(*m_pMoreOption); - } + if (!m_pMoreOption) { + m_pMoreOption = new MoreOption(*m_pLayout); + m_pMoreOption->setDirection(EEXT_MORE_OPTION_DIRECTION_RIGHT); + m_pMoreOption->appendItem(msgt("WDS_MSG_OPT_RESTORE_ABB"), RESTORE_MORE_ICON, makeCbLast(&SettingsBlockedMsgDetailFrame::onRestoreClicked), this); + m_pMoreOption->appendItem(msgt("WDS_MSG_OPT_DELETE_ABB"), DELETEG_MORE_ICON, makeCbLast(&SettingsBlockedMsgDetailFrame::onDeleteClicked), this); + m_pLayout->setMoreOption(*m_pMoreOption); + } } void SettingsBlockedMsgDetailFrame::onRestoreClicked(MoreOption &obj) { - MSG_LOG(""); - auto *popup = new IconTextPopup; - popup->setIcon(IconTextPopup::CheckIcon); - popup->setText(msgt("WDS_MSG_TPOP_MESSAGE_RESTORED_ABB")); - popup->setTimeOut(); - popup->show(); + MSG_LOG(""); + auto *popup = new IconTextPopup; + popup->setIcon(IconTextPopup::CheckIcon); + popup->setText(msgt("WDS_MSG_TPOP_MESSAGE_RESTORED_ABB")); + popup->setTimeOut(); + popup->show(); } void SettingsBlockedMsgDetailFrame::onDeleteClicked(MoreOption &obj) { - MSG_LOG(""); + MSG_LOG(""); } diff --git a/src/Settings/Controller/src/SettingsFrame.cpp b/src/Settings/Controller/src/SettingsFrame.cpp index d10832f..26487ee 100644 --- a/src/Settings/Controller/src/SettingsFrame.cpp +++ b/src/Settings/Controller/src/SettingsFrame.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -30,107 +30,107 @@ using namespace Msg; SettingsFrame::SettingsFrame(NaviFrameController &parent) - : FrameController(parent, SettingsGroup) - , m_pList(nullptr) - , m_pAudioItem(nullptr) - , m_pBlockListItem(nullptr) + : FrameController(parent, SettingsGroup) + , m_pList(nullptr) + , m_pAudioItem(nullptr) + , m_pBlockListItem(nullptr) { - preapareList(); - App::getInst().getMsgEngine().getSettings().addListener(*this); + preapareList(); + App::getInst().getMsgEngine().getSettings().addListener(*this); } SettingsFrame::~SettingsFrame() { - App::getInst().getMsgEngine().getSettings().removeListener(*this); + App::getInst().getMsgEngine().getSettings().removeListener(*this); } void SettingsFrame::preapareList() { - if (!m_pList) { - m_pList = new ListView(getParent(), App::getInst().getWindow().getCircleSurface()); - m_pList->setHomogeneous(false); - m_pList->setMultiSelection(false); - fillList(); - } + if (!m_pList) { + m_pList = new ListView(getParent(), App::getInst().getWindow().getCircleSurface()); + m_pList->setHomogeneous(false); + m_pList->setMultiSelection(false); + fillList(); + } } void SettingsFrame::fillList() { - using namespace std::placeholders; - - // Title: - auto *titleItem = new TitleListItem; - titleItem->setTitle(msg("WDS_MSG_HEADER_MESSAGES_ABB")); - m_pList->appendItem(*titleItem); - - // Send as audio: - m_pAudioItem = new SettingsMenuListItem(SettingsMenuListItem::twoTextIconStyle); - m_pAudioItem->setOnSelectedCb(std::bind(&SettingsFrame::onSountItemSelected, this, _1)); - m_pAudioItem->setOnChangedCb(std::bind(&SettingsFrame::onSountItemChecked, this, _1)); - updateAudioItem(); - m_pList->appendItem(*m_pAudioItem); - - // Block list: - m_pBlockListItem = new SettingsMenuListItem(SettingsMenuListItem::twoTextStyle); - m_pBlockListItem->setOnSelectedCb(std::bind(&SettingsFrame::onBlockListSelected, this, _1)); - updateBlockListItem(); - m_pList->appendItem(*m_pBlockListItem); - - // Bottom padding: - m_pList->appendItem(*new PaddingListViewItem); + using namespace std::placeholders; + + // Title: + auto *titleItem = new TitleListItem; + titleItem->setTitle(msg("WDS_MSG_HEADER_MESSAGES_ABB")); + m_pList->appendItem(*titleItem); + + // Send as audio: + m_pAudioItem = new SettingsMenuListItem(SettingsMenuListItem::twoTextIconStyle); + m_pAudioItem->setOnSelectedCb(std::bind(&SettingsFrame::onSountItemSelected, this, _1)); + m_pAudioItem->setOnChangedCb(std::bind(&SettingsFrame::onSountItemChecked, this, _1)); + updateAudioItem(); + m_pList->appendItem(*m_pAudioItem); + + // Block list: + m_pBlockListItem = new SettingsMenuListItem(SettingsMenuListItem::twoTextStyle); + m_pBlockListItem->setOnSelectedCb(std::bind(&SettingsFrame::onBlockListSelected, this, _1)); + updateBlockListItem(); + m_pList->appendItem(*m_pBlockListItem); + + // Bottom padding: + m_pList->appendItem(*new PaddingListViewItem); } void SettingsFrame::updateItems() { - updateAudioItem(); - updateBlockListItem(); + updateAudioItem(); + updateBlockListItem(); } void SettingsFrame::updateAudioItem() { - m_pAudioItem->setText(msg("WDS_MSG_MBODY_SEND_AS_AUDIO_ABB")); - m_pAudioItem->setSubText(msg("WDS_MSG_SBODY_USING_VOICE_INPUT_ABB")); - m_pAudioItem->setMenuCheckedState(App::getInst().getMsgEngine().getSettings().getSendAsAudio()); + m_pAudioItem->setText(msg("WDS_MSG_MBODY_SEND_AS_AUDIO_ABB")); + m_pAudioItem->setSubText(msg("WDS_MSG_SBODY_USING_VOICE_INPUT_ABB")); + m_pAudioItem->setMenuCheckedState(App::getInst().getMsgEngine().getSettings().getSendAsAudio()); } void SettingsFrame::updateBlockListItem() { - m_pBlockListItem->setText(msg("WDS_MSG_MBODY_BLOCK_LIST")); + m_pBlockListItem->setText(msg("WDS_MSG_MBODY_BLOCK_LIST")); } void SettingsFrame::onAttached(ViewItem &item) { - MSG_LOG(""); - FrameController::onAttached(item); - preapareList(); - setContent(*m_pList); + MSG_LOG(""); + FrameController::onAttached(item); + preapareList(); + setContent(*m_pList); } void SettingsFrame::onSountItemSelected(ListItem &item) { - MSG_LOG(""); - auto &seetingsItem = static_cast(item); - seetingsItem.changeMenuCheckedState(); - bool newState = seetingsItem.getMenuCheckedState(); - App::getInst().getMsgEngine().getSettings().setSendAsAudio(newState); + MSG_LOG(""); + auto &seetingsItem = static_cast(item); + seetingsItem.changeMenuCheckedState(); + bool newState = seetingsItem.getMenuCheckedState(); + App::getInst().getMsgEngine().getSettings().setSendAsAudio(newState); } void SettingsFrame::onSountItemChecked(SettingsMenuListItem &item) { - MSG_LOG(""); - bool newState = item.getMenuCheckedState(); - App::getInst().getMsgEngine().getSettings().setSendAsAudio(newState); + MSG_LOG(""); + bool newState = item.getMenuCheckedState(); + App::getInst().getMsgEngine().getSettings().setSendAsAudio(newState); } void SettingsFrame::onBlockListSelected(ListItem &item) { - MSG_LOG(""); - auto *frame = new SettingsMenuBlockListFrame(getParent()); - getParent().push(*frame); + MSG_LOG(""); + auto *frame = new SettingsMenuBlockListFrame(getParent()); + getParent().push(*frame); } void SettingsFrame::onSendAsAudioChanged(MsgSettings &msgSetting) { - MSG_LOG(""); - updateAudioItem(); + MSG_LOG(""); + updateAudioItem(); } diff --git a/src/Settings/Controller/src/SettingsMenuBlockListFrame.cpp b/src/Settings/Controller/src/SettingsMenuBlockListFrame.cpp index a63d99a..a082b69 100644 --- a/src/Settings/Controller/src/SettingsMenuBlockListFrame.cpp +++ b/src/Settings/Controller/src/SettingsMenuBlockListFrame.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Samsung Electronics Co., Ltd + * Copyright 2016 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -29,10 +29,10 @@ using namespace Msg; SettingsMenuBlockListFrame::SettingsMenuBlockListFrame(NaviFrameController &parent) - : FrameController(parent, SettingsGroup) - , m_pList(nullptr) + : FrameController(parent, SettingsGroup) + , m_pList(nullptr) { - preapareList(); + preapareList(); } SettingsMenuBlockListFrame::~SettingsMenuBlockListFrame() @@ -42,56 +42,56 @@ SettingsMenuBlockListFrame::~SettingsMenuBlockListFrame() void SettingsMenuBlockListFrame::onAttached(ViewItem &item) { - FrameController::onAttached(item); - setContent(*m_pList); + FrameController::onAttached(item); + setContent(*m_pList); } void SettingsMenuBlockListFrame::preapareList() { - if (!m_pList) { - m_pList = new ListView(getParent(), App::getInst().getWindow().getCircleSurface()); - m_pList->setHomogeneous(false); - m_pList->setMultiSelection(false); - fillList(); - } + if (!m_pList) { + m_pList = new ListView(getParent(), App::getInst().getWindow().getCircleSurface()); + m_pList->setHomogeneous(false); + m_pList->setMultiSelection(false); + fillList(); + } } void SettingsMenuBlockListFrame::fillList() { - using namespace std::placeholders; + using namespace std::placeholders; - // Title: - auto *titleItem = new TitleListItem; - titleItem->setTitle(msg("WDS_MSG_MBODY_BLOCK_LIST")); - m_pList->appendItem(*titleItem); + // Title: + auto *titleItem = new TitleListItem; + titleItem->setTitle(msg("WDS_MSG_MBODY_BLOCK_LIST")); + m_pList->appendItem(*titleItem); - // Blocked number: - auto *blockedNum = new SettingsMenuListItem(SettingsMenuListItem::oneTextStyle); - blockedNum->setText(msg("WDS_MSG_MBODY_BLOCKED_NUMBERS")); - blockedNum->setOnSelectedCb(std::bind(&SettingsMenuBlockListFrame::onBlockedNumberSelected, this, _1)); - m_pList->appendItem(*blockedNum); + // Blocked number: + auto *blockedNum = new SettingsMenuListItem(SettingsMenuListItem::oneTextStyle); + blockedNum->setText(msg("WDS_MSG_MBODY_BLOCKED_NUMBERS")); + blockedNum->setOnSelectedCb(std::bind(&SettingsMenuBlockListFrame::onBlockedNumberSelected, this, _1)); + m_pList->appendItem(*blockedNum); - // Blocked messages: - auto *blockedMsg = new SettingsMenuListItem(SettingsMenuListItem::oneTextStyle); - blockedMsg->setText(msg("WDS_MSG_MBODY_BLOCKED_MESSAGES")); - blockedMsg->setOnSelectedCb(std::bind(&SettingsMenuBlockListFrame::onBlockedMsgSelected, this, _1)); - m_pList->appendItem(*blockedMsg); + // Blocked messages: + auto *blockedMsg = new SettingsMenuListItem(SettingsMenuListItem::oneTextStyle); + blockedMsg->setText(msg("WDS_MSG_MBODY_BLOCKED_MESSAGES")); + blockedMsg->setOnSelectedCb(std::bind(&SettingsMenuBlockListFrame::onBlockedMsgSelected, this, _1)); + m_pList->appendItem(*blockedMsg); - // Bottom padding: - m_pList->appendItem(*new PaddingListViewItem); + // Bottom padding: + m_pList->appendItem(*new PaddingListViewItem); } void SettingsMenuBlockListFrame::onBlockedNumberSelected(ListItem &listItem) { - MSG_LOG(""); - auto *frame = new SettingsBlockListFrame(getParent(), SettingsBlockListFrame::BlockedNumType); - getParent().push(*frame); + MSG_LOG(""); + auto *frame = new SettingsBlockListFrame(getParent(), SettingsBlockListFrame::BlockedNumType); + getParent().push(*frame); } void SettingsMenuBlockListFrame::onBlockedMsgSelected(ListItem &listItem) { - MSG_LOG(""); - auto *frame = new SettingsBlockListFrame(getParent(), SettingsBlockListFrame::BlockedMsgType); - getParent().push(*frame); + MSG_LOG(""); + auto *frame = new SettingsBlockListFrame(getParent(), SettingsBlockListFrame::BlockedMsgType); + getParent().push(*frame); } diff --git a/src/Settings/View/inc/BlockedMsgListViewItem.h b/src/Settings/View/inc/BlockedMsgListViewItem.h index 40307cc..76a913d 100644 --- a/src/Settings/View/inc/BlockedMsgListViewItem.h +++ b/src/Settings/View/inc/BlockedMsgListViewItem.h @@ -21,20 +21,20 @@ #include "LangUtils.h" namespace Msg { - class BlockedMsgListViewItem - : public ListItem { - public: - BlockedMsgListViewItem(); - virtual ~BlockedMsgListViewItem(); + class BlockedMsgListViewItem + : public ListItem { + public: + BlockedMsgListViewItem(); + virtual ~BlockedMsgListViewItem(); - protected: - virtual std::string getName() = 0; - virtual std::string getMessage() = 0; - virtual std::string getTime() = 0; + protected: + virtual std::string getName() = 0; + virtual std::string getMessage() = 0; + virtual std::string getTime() = 0; - private: - std::string getText(ListItem &item, const char *part) override; - }; + private: + std::string getText(ListItem &item, const char *part) override; + }; } #endif // BlockedMsgListIViewItem_h_ diff --git a/src/Settings/View/inc/BlockedNumberListViewItem.h b/src/Settings/View/inc/BlockedNumberListViewItem.h index a221c9b..0d46be6 100644 --- a/src/Settings/View/inc/BlockedNumberListViewItem.h +++ b/src/Settings/View/inc/BlockedNumberListViewItem.h @@ -21,25 +21,25 @@ #include "LangUtils.h" namespace Msg { - class BlockedNumberListViewItem - : public ListItem { + class BlockedNumberListViewItem + : public ListItem { - public: - static ListItemStyleRef numberStyle; - static ListItemStyleRef contactNameStyle; + public: + static ListItemStyleRef numberStyle; + static ListItemStyleRef contactNameStyle; - public: - BlockedNumberListViewItem(); - virtual ~BlockedNumberListViewItem(); + public: + BlockedNumberListViewItem(); + virtual ~BlockedNumberListViewItem(); - protected: - virtual std::string getAddress() = 0; - virtual std::string getContactName() = 0; + protected: + virtual std::string getAddress() = 0; + virtual std::string getContactName() = 0; - private: - std::string getText(ListItem &item, const char *part) override; - }; + private: + std::string getText(ListItem &item, const char *part) override; + }; } #endif // BlockedNumberListViewItem_h_ diff --git a/src/Settings/View/inc/SettingsBlockedMsgDetailView.h b/src/Settings/View/inc/SettingsBlockedMsgDetailView.h index 53e97b5..bce2751 100644 --- a/src/Settings/View/inc/SettingsBlockedMsgDetailView.h +++ b/src/Settings/View/inc/SettingsBlockedMsgDetailView.h @@ -21,22 +21,22 @@ #include "LangUtils.h" namespace Msg { - class SettingsBlockedMsgDetailView - : public ListItem { - public: - SettingsBlockedMsgDetailView(); - virtual ~SettingsBlockedMsgDetailView(); + class SettingsBlockedMsgDetailView + : public ListItem { + public: + SettingsBlockedMsgDetailView(); + virtual ~SettingsBlockedMsgDetailView(); - void setTime(std::string time); - void setMessage(std::string message); + void setTime(std::string time); + void setMessage(std::string message); - private: - std::string getText(ListItem &item, const char *part) override; + private: + std::string getText(ListItem &item, const char *part) override; - private: - std::string m_Time; - std::string m_Message; - }; + private: + std::string m_Time; + std::string m_Message; + }; } #endif // SettingsBlockedMsgDetailView_h_ diff --git a/src/Settings/View/inc/SettingsMenuListItem.h b/src/Settings/View/inc/SettingsMenuListItem.h index a030a67..2387c3f 100644 --- a/src/Settings/View/inc/SettingsMenuListItem.h +++ b/src/Settings/View/inc/SettingsMenuListItem.h @@ -21,41 +21,41 @@ #include "LangUtils.h" namespace Msg { - class SettingsMenuListItem - : public ListItem { + class SettingsMenuListItem + : public ListItem { - public: - using OnChangedCb = std::function; + public: + using OnChangedCb = std::function; - static ListItemStyleRef oneTextStyle; - static ListItemStyleRef twoTextStyle; - static ListItemStyleRef twoTextIconStyle; + static ListItemStyleRef oneTextStyle; + static ListItemStyleRef twoTextStyle; + static ListItemStyleRef twoTextIconStyle; - public: - SettingsMenuListItem(const ListItemStyleRef &itemStyle); - virtual ~SettingsMenuListItem(); + public: + SettingsMenuListItem(const ListItemStyleRef &itemStyle); + virtual ~SettingsMenuListItem(); - void setText(TText text); - void setSubText(TText text); + void setText(TText text); + void setSubText(TText text); - void setOnChangedCb(OnChangedCb cb); - void setMenuCheckedState(bool state); - void changeMenuCheckedState(); - bool getMenuCheckedState() const; + void setOnChangedCb(OnChangedCb cb); + void setMenuCheckedState(bool state); + void changeMenuCheckedState(); + bool getMenuCheckedState() const; - private: - std::string getText(ListItem &item, const char *part) override; - Evas_Object *getContent(ListItem &item, const char *part) override; + private: + std::string getText(ListItem &item, const char *part) override; + Evas_Object *getContent(ListItem &item, const char *part) override; - Evas_Object *createCheck(); - void onCheckChanged(Evas_Object *obj, void *event_info); + Evas_Object *createCheck(); + void onCheckChanged(Evas_Object *obj, void *event_info); - private: - TText m_Text; - TText m_SubText; - Eina_Bool m_CheckedState; - OnChangedCb m_OnChangedCb; - }; + private: + TText m_Text; + TText m_SubText; + Eina_Bool m_CheckedState; + OnChangedCb m_OnChangedCb; + }; } #endif // SettingsMenuListItem_h_ diff --git a/src/Settings/View/src/BlockedMsgListViewItem.cpp b/src/Settings/View/src/BlockedMsgListViewItem.cpp index 0b0162a..91a9cf9 100644 --- a/src/Settings/View/src/BlockedMsgListViewItem.cpp +++ b/src/Settings/View/src/BlockedMsgListViewItem.cpp @@ -20,14 +20,14 @@ using namespace Msg; namespace { - const char *namePart = "elm.text.sliding"; - const char *namePartMask = "elm.text"; - const char *messagePart = "elm.text.1"; - const char *timePart = "elm.text.2"; + const char *namePart = "elm.text.sliding"; + const char *namePartMask = "elm.text"; + const char *messagePart = "elm.text.1"; + const char *timePart = "elm.text.2"; } BlockedMsgListViewItem::BlockedMsgListViewItem() - : ListItem(ListItemStyle::create("preview_msg_list_item")) + : ListItem(ListItemStyle::create("preview_msg_list_item")) { } @@ -37,13 +37,13 @@ BlockedMsgListViewItem::~BlockedMsgListViewItem() std::string BlockedMsgListViewItem::getText(ListItem &item, const char *part) { - if (!strcmp(part, messagePart)) { - return getMessage(); - } else if (!strcmp(part, namePart) || !strcmp(part, namePartMask)) { - return getName(); - } else if (!strcmp(part, timePart)) { - return getTime(); - } + if (!strcmp(part, messagePart)) { + return getMessage(); + } else if (!strcmp(part, namePart) || !strcmp(part, namePartMask)) { + return getName(); + } else if (!strcmp(part, timePart)) { + return getTime(); + } - return ""; + return ""; } diff --git a/src/Settings/View/src/BlockedNumberListViewItem.cpp b/src/Settings/View/src/BlockedNumberListViewItem.cpp index 8702c73..21a3568 100644 --- a/src/Settings/View/src/BlockedNumberListViewItem.cpp +++ b/src/Settings/View/src/BlockedNumberListViewItem.cpp @@ -23,12 +23,12 @@ ListItemStyleRef BlockedNumberListViewItem::numberStyle = ListItemStyle::create( ListItemStyleRef BlockedNumberListViewItem::contactNameStyle = ListItemStyle::create("2text"); namespace { - const char *numberTextPart = "elm.text"; - const char *contactNameTextPart = "elm.text.1"; + const char *numberTextPart = "elm.text"; + const char *contactNameTextPart = "elm.text.1"; } BlockedNumberListViewItem::BlockedNumberListViewItem() - : ListItem(ELM_GENLIST_ITEM_NONE) + : ListItem(ELM_GENLIST_ITEM_NONE) { } @@ -38,11 +38,11 @@ BlockedNumberListViewItem::~BlockedNumberListViewItem() std::string BlockedNumberListViewItem::getText(ListItem &item, const char *part) { - if (strcmp(part, numberTextPart) == 0) - return getAddress(); + if (strcmp(part, numberTextPart) == 0) + return getAddress(); - if (getStyle() == contactNameStyle && strcmp(part, contactNameTextPart) == 0) - return getContactName(); + if (getStyle() == contactNameStyle && strcmp(part, contactNameTextPart) == 0) + return getContactName(); - return ""; + return ""; } diff --git a/src/Settings/View/src/SettingsBlockedMsgDetailView.cpp b/src/Settings/View/src/SettingsBlockedMsgDetailView.cpp index ba8f884..9e69134 100644 --- a/src/Settings/View/src/SettingsBlockedMsgDetailView.cpp +++ b/src/Settings/View/src/SettingsBlockedMsgDetailView.cpp @@ -21,12 +21,12 @@ using namespace Msg; namespace { - const char *msgTime = "elm.text"; - const char *msgText = "elm.text.1"; + const char *msgTime = "elm.text"; + const char *msgText = "elm.text.1"; } SettingsBlockedMsgDetailView::SettingsBlockedMsgDetailView() - : ListItem(ListItemStyle::create("message_detail")) + : ListItem(ListItemStyle::create("message_detail")) { } @@ -36,22 +36,22 @@ SettingsBlockedMsgDetailView::~SettingsBlockedMsgDetailView() void SettingsBlockedMsgDetailView::setTime(std::string time) { - m_Time = std::move(time); + m_Time = std::move(time); } void SettingsBlockedMsgDetailView::setMessage(std::string message) { - m_Message = std::move(message); + m_Message = std::move(message); } std::string SettingsBlockedMsgDetailView::getText(ListItem &item, const char *part) { - if (!strcmp(part, msgTime)) - return m_Time; - else if (!strcmp(part, msgText)) { - return m_Message; - } + if (!strcmp(part, msgTime)) + return m_Time; + else if (!strcmp(part, msgText)) { + return m_Message; + } - return ""; + return ""; } diff --git a/src/Settings/View/src/SettingsMenuListItem.cpp b/src/Settings/View/src/SettingsMenuListItem.cpp index 1a5056a..f0639bb 100644 --- a/src/Settings/View/src/SettingsMenuListItem.cpp +++ b/src/Settings/View/src/SettingsMenuListItem.cpp @@ -23,8 +23,8 @@ using namespace Msg; namespace { - const char *mainTextPart = "elm.text"; - const char *subTextPart = "elm.text.1"; + const char *mainTextPart = "elm.text"; + const char *subTextPart = "elm.text.1"; } ListItemStyleRef SettingsMenuListItem::oneTextStyle = ListItemStyle::create("1text"); @@ -32,8 +32,8 @@ ListItemStyleRef SettingsMenuListItem::twoTextStyle = ListItemStyle::create("2te ListItemStyleRef SettingsMenuListItem::twoTextIconStyle = ListItemStyle::create("2text.1icon.1"); SettingsMenuListItem::SettingsMenuListItem(const ListItemStyleRef &itemStyle) - : ListItem(itemStyle) - , m_CheckedState(false) + : ListItem(itemStyle) + , m_CheckedState(false) { } @@ -43,73 +43,73 @@ SettingsMenuListItem::~SettingsMenuListItem() void SettingsMenuListItem::setText(TText text) { - m_Text = std::move(text); + m_Text = std::move(text); } void SettingsMenuListItem::setSubText(TText text) { - m_SubText = std::move(text); + m_SubText = std::move(text); } void SettingsMenuListItem::setOnChangedCb(OnChangedCb cb) { - m_OnChangedCb = std::move(cb); + m_OnChangedCb = std::move(cb); } void SettingsMenuListItem::setMenuCheckedState(bool state) { - if (m_CheckedState != state) { - m_CheckedState = state; - update(); - } + if (m_CheckedState != state) { + m_CheckedState = state; + update(); + } } void SettingsMenuListItem::changeMenuCheckedState() { - setMenuCheckedState(!m_CheckedState); + setMenuCheckedState(!m_CheckedState); } bool SettingsMenuListItem::getMenuCheckedState() const { - return m_CheckedState; + return m_CheckedState; } std::string SettingsMenuListItem::getText(ListItem &item, const char *part) { - if (strcmp(part, mainTextPart) == 0) - return m_Text.translate(); + if (strcmp(part, mainTextPart) == 0) + return m_Text.translate(); - if (strcmp(part, subTextPart) == 0) - return m_SubText.translate(); + if (strcmp(part, subTextPart) == 0) + return m_SubText.translate(); - return ""; + return ""; } Evas_Object *SettingsMenuListItem::createCheck() { - Evas_Object *check = nullptr; - check = elm_check_add(*getOwner()); - elm_object_focus_allow_set(check, false); - elm_object_style_set(check, "on&off"); - elm_check_state_set(check, m_CheckedState); - elm_check_state_pointer_set(check, &m_CheckedState); - evas_object_propagate_events_set(check, false); - evas_object_smart_callback_add(check, "changed", makeCbFirst(&SettingsMenuListItem::onCheckChanged), this); - View::processSignal(check); - return check; + Evas_Object *check = nullptr; + check = elm_check_add(*getOwner()); + elm_object_focus_allow_set(check, false); + elm_object_style_set(check, "on&off"); + elm_check_state_set(check, m_CheckedState); + elm_check_state_pointer_set(check, &m_CheckedState); + evas_object_propagate_events_set(check, false); + evas_object_smart_callback_add(check, "changed", makeCbFirst(&SettingsMenuListItem::onCheckChanged), this); + View::processSignal(check); + return check; } Evas_Object *SettingsMenuListItem::getContent(ListItem &item, const char *part) { - if (strcmp(part, "elm.icon") == 0) - return createCheck(); - return nullptr; + if (strcmp(part, "elm.icon") == 0) + return createCheck(); + return nullptr; } void SettingsMenuListItem::onCheckChanged(Evas_Object *obj, void *event_info) { - MSG_LOG(""); - if (m_OnChangedCb) - m_OnChangedCb(*this); + MSG_LOG(""); + if (m_OnChangedCb) + m_OnChangedCb(*this); }