diff options
author | Evgen Servetnik <e.servetnik@samsung.com> | 2017-07-28 11:51:39 +0300 |
---|---|---|
committer | Evgen Servetnik <e.servetnik@samsung.com> | 2017-07-28 15:10:04 +0300 |
commit | 2b76baee13ba141549baacd7629fd2ca62c3b196 (patch) | |
tree | 5725f9dbcc528f819cebf7d3a97bf31b8631d287 | |
parent | fa2dd6c7993a40fbe4f07fd135a0bbb5e78e092e (diff) | |
download | idle-clock-digital-2b76baee13ba141549baacd7629fd2ca62c3b196.tar.gz idle-clock-digital-2b76baee13ba141549baacd7629fd2ca62c3b196.tar.bz2 idle-clock-digital-2b76baee13ba141549baacd7629fd2ca62c3b196.zip |
TizenRefApp-8943 Replace whitespaces to tabssubmit/tizen_4.0/20170811.094300submit/tizen/20170803.061943submit/tizen/20170802.150451submit/tizen/20170802.150301
Change-Id: I7c5caba55388cabbc02613c751db05dca1da945b
Signed-off-by: Evgen Servetnik <e.servetnik@samsung.com>
27 files changed, 1560 insertions, 1560 deletions
diff --git a/inc/Config.h b/inc/Config.h index ba1303a..c5ace70 100644 --- a/inc/Config.h +++ b/inc/Config.h @@ -25,8 +25,8 @@ #define PROJECT_NAME "idle-clock-proto" #endif -#ifdef LOGGER_TAG -#undef LOGGER_TAG +#ifdef LOGGER_TAG +#undef LOGGER_TAG #endif #define LOGGER_TAG "idleclock" diff --git a/inc/Resource.h b/inc/Resource.h index 1b3c9d1..372901b 100644 --- a/inc/Resource.h +++ b/inc/Resource.h @@ -20,7 +20,7 @@ #define EDJ_PATH "edje" #define IMAGE_PATH "images" -#define MAINT_LAYOUT_EDJ "main-layout.edj" -#define CLOCK_DIGITAL_EDJ "clock-digital.edj" +#define MAINT_LAYOUT_EDJ "main-layout.edj" +#define CLOCK_DIGITAL_EDJ "clock-digital.edj" #endif /* RESOURCE_H_ */ diff --git a/src/App/inc/DateTimeFormatter.h b/src/App/inc/DateTimeFormatter.h index d38d4d6..95500f8 100644 --- a/src/App/inc/DateTimeFormatter.h +++ b/src/App/inc/DateTimeFormatter.h @@ -26,42 +26,42 @@ namespace IdleClock { - class DateTimeFormatter { - public: - DateTimeFormatter(); - ~DateTimeFormatter(); + class DateTimeFormatter { + public: + DateTimeFormatter(); + ~DateTimeFormatter(); - DateTimeFormatter(const DateTimeFormatter&) = delete; - DateTimeFormatter &operator=(const DateTimeFormatter&) = delete; + DateTimeFormatter(const DateTimeFormatter&) = delete; + DateTimeFormatter &operator=(const DateTimeFormatter&) = delete; - std::string getTime(time_t intime) const; - std::string getDate(time_t intime) const; + std::string getTime(time_t intime) const; + std::string getDate(time_t intime) const; - void set24hTimeFormat(bool value); - void setRegion(std::string region); - void setTimeZone(const std::string &timeZone); - void update(); + void set24hTimeFormat(bool value); + void setRegion(std::string region); + void setTimeZone(const std::string &timeZone); + void update(); - private: - std::string getDateTime(time_t intime, const i18n_udate_format_h format) const; + private: + std::string getDateTime(time_t intime, const i18n_udate_format_h format) const; - void updateTime(); - void updateDate(); - void updateGen(); + void updateTime(); + void updateDate(); + void updateGen(); - void destroy(); - void destroyGen(); - void destroyTime(); - void destroyDate(); + void destroy(); + void destroyGen(); + void destroyTime(); + void destroyDate(); - private: - bool m_IsTime24Format; - std::string m_Region; - I18nString m_TimeZoneId; - i18n_udate_format_h m_Time; - i18n_udate_format_h m_Date; - i18n_udatepg_h m_Gen; - }; + private: + bool m_IsTime24Format; + std::string m_Region; + I18nString m_TimeZoneId; + i18n_udate_format_h m_Time; + i18n_udate_format_h m_Date; + i18n_udatepg_h m_Gen; + }; } #endif /* DateTimeFormatter_h_ */ diff --git a/src/App/inc/DateTimeView.h b/src/App/inc/DateTimeView.h index 59c5510..69c7f16 100644 --- a/src/App/inc/DateTimeView.h +++ b/src/App/inc/DateTimeView.h @@ -20,15 +20,15 @@ #include "View.h" namespace IdleClock { - class DateTimeView - : public View { - public: - DateTimeView(Evas_Object *parent); - virtual ~DateTimeView(); + class DateTimeView + : public View { + public: + DateTimeView(Evas_Object *parent); + virtual ~DateTimeView(); - void setHours(const std::string &time); - void setMinutes(const std::string &time); - }; + void setHours(const std::string &time); + void setMinutes(const std::string &time); + }; } #endif /* DateTimeView_h_ */ diff --git a/src/App/inc/MainController.h b/src/App/inc/MainController.h index 15a97e9..0bd8ceb 100644 --- a/src/App/inc/MainController.h +++ b/src/App/inc/MainController.h @@ -22,35 +22,35 @@ #include "DateTimeView.h" namespace IdleClock { - class MainController - : public MainLayout { - - public: - MainController(Evas_Object *parent); - virtual ~MainController(); - - void onPause(); - void onResume(); - void onControl(app_control_h app_control); - void onTick(watch_time_h watch_time); - void onAmbientTick(watch_time_h watch_time); - void onAmbientChanged(bool ambient_mode); - void onLanguageChanged(app_event_info_h appEvent); - void onLowBattery(app_event_info_h appEvent); - void onRegionChanged(app_event_info_h appEvent); - void onTimeFormatChanged(); - void onTimeChanged(); - - private: - void updateTime(); - void dispTime(watch_time_h watch_time); - void dispTime(time_t tt); - void dispTime(); - - private: - DateTimeFormatter m_Formatter; - DateTimeView *m_pTimeView; - }; + class MainController + : public MainLayout { + + public: + MainController(Evas_Object *parent); + virtual ~MainController(); + + void onPause(); + void onResume(); + void onControl(app_control_h app_control); + void onTick(watch_time_h watch_time); + void onAmbientTick(watch_time_h watch_time); + void onAmbientChanged(bool ambient_mode); + void onLanguageChanged(app_event_info_h appEvent); + void onLowBattery(app_event_info_h appEvent); + void onRegionChanged(app_event_info_h appEvent); + void onTimeFormatChanged(); + void onTimeChanged(); + + private: + void updateTime(); + void dispTime(watch_time_h watch_time); + void dispTime(time_t tt); + void dispTime(); + + private: + DateTimeFormatter m_Formatter; + DateTimeView *m_pTimeView; + }; } #endif /* MainController_h_ */ diff --git a/src/App/inc/MainLayout.h b/src/App/inc/MainLayout.h index 1341731..16fda6d 100644 --- a/src/App/inc/MainLayout.h +++ b/src/App/inc/MainLayout.h @@ -20,14 +20,14 @@ #include "View.h" namespace IdleClock { - class MainLayout - : public View { - public: - MainLayout(Evas_Object *parent); - virtual ~MainLayout(); + class MainLayout + : public View { + public: + MainLayout(Evas_Object *parent); + virtual ~MainLayout(); - void setDateTime(Evas_Object *dateTime); - }; + void setDateTime(Evas_Object *dateTime); + }; } #endif /* MainLayout_h_ */ diff --git a/src/App/inc/WatchApp.h b/src/App/inc/WatchApp.h index bb30649..92ba722 100644 --- a/src/App/inc/WatchApp.h +++ b/src/App/inc/WatchApp.h @@ -25,50 +25,50 @@ #include <string> namespace IdleClock { - class WatchWindow; - class MainController; + class WatchWindow; + class MainController; - class WatchApp { - public: - static WatchApp &getInst(); - int start(int argc, char *argv[]); - void exit(); - WatchWindow &getWindow(); - const WatchWindow &getWindow() const; + class WatchApp { + public: + static WatchApp &getInst(); + int start(int argc, char *argv[]); + void exit(); + WatchWindow &getWindow(); + const WatchWindow &getWindow() const; - std::string getLang() const; - std::string getTimeZone() const; - std::string getCountry() const; - bool is24TimeFormat() const; + std::string getLang() const; + std::string getTimeZone() const; + std::string getCountry() const; + bool is24TimeFormat() const; - private: - WatchApp(); - ~WatchApp(); - WatchApp(WatchApp &) = delete; - WatchApp &operator=(WatchApp &) = delete; + private: + WatchApp(); + ~WatchApp(); + WatchApp(WatchApp &) = delete; + WatchApp &operator=(WatchApp &) = delete; - std::string getStr(system_settings_key_e key) const; + std::string getStr(system_settings_key_e key) const; - // App cbs: - bool onCreate(int width, int height); - void onTerminate(); - void onPause(); - void onResume(); - void onControl(app_control_h app_control); - void onTick(watch_time_h watch_time); - void onAmbientTick(watch_time_h watch_time); - void onAmbientChanged(bool ambient_mode); - void onLanguageChanged(app_event_info_h appEvent); - void onLowBattery(app_event_info_h appEvent); - void onRegionChanged(app_event_info_h appEvent); - void onTimeFormatChanged(system_settings_key_e key); - void onTimeChanged(system_settings_key_e key); + // App cbs: + bool onCreate(int width, int height); + void onTerminate(); + void onPause(); + void onResume(); + void onControl(app_control_h app_control); + void onTick(watch_time_h watch_time); + void onAmbientTick(watch_time_h watch_time); + void onAmbientChanged(bool ambient_mode); + void onLanguageChanged(app_event_info_h appEvent); + void onLowBattery(app_event_info_h appEvent); + void onRegionChanged(app_event_info_h appEvent); + void onTimeFormatChanged(system_settings_key_e key); + void onTimeChanged(system_settings_key_e key); - private: - static WatchApp m_AppInst; - WatchWindow *m_pWindow; - MainController *m_pRootController; - }; + private: + static WatchApp m_AppInst; + WatchWindow *m_pWindow; + MainController *m_pRootController; + }; } #endif /* WatchApp_h_ */ diff --git a/src/App/src/DateTimeFormatter.cpp b/src/App/src/DateTimeFormatter.cpp index f2f400c..e5ab173 100644 --- a/src/App/src/DateTimeFormatter.cpp +++ b/src/App/src/DateTimeFormatter.cpp @@ -20,189 +20,189 @@ using namespace IdleClock; namespace { - const std::string defaultRegion = "en_US"; + const std::string defaultRegion = "en_US"; - std::string highlightKeyword(const std::string &str, const std::string &searchWord, - const std::string &tagOpen, const std::string &tagClose) - { - if (str.empty() || searchWord.empty()) - return str; + std::string highlightKeyword(const std::string &str, const std::string &searchWord, + const std::string &tagOpen, const std::string &tagClose) + { + 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; - std::string res; - res.reserve(str.length() + tagOpen.length() + tagClose.length()); + std::string res; + res.reserve(str.length() + tagOpen.length() + tagClose.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 += tagOpen; - res += std::string(found, searchWord.length()); - res += tagClose; - res += lastPart; + res += firstPart; + res += tagOpen; + res += std::string(found, searchWord.length()); + res += tagClose; + res += lastPart; - return res; - } + return res; + } - void cleanupPattern(std::string &s, const std::string &charSet) - { - size_t pos = 0; - do { - pos = s.find_first_of(charSet); - if (pos != std::string::npos) - s.erase(pos, 1); - } while (pos != std::string::npos); - } + void cleanupPattern(std::string &s, const std::string &charSet) + { + size_t pos = 0; + do { + pos = s.find_first_of(charSet); + if (pos != std::string::npos) + s.erase(pos, 1); + } while (pos != std::string::npos); + } } DateTimeFormatter::DateTimeFormatter() - : m_IsTime24Format(false) - , m_Region(defaultRegion) - , m_TimeZoneId() - , m_Time() - , m_Date() - , m_Gen() + : m_IsTime24Format(false) + , m_Region(defaultRegion) + , m_TimeZoneId() + , m_Time() + , m_Date() + , m_Gen() { - update(); + update(); } DateTimeFormatter::~DateTimeFormatter() { - destroy(); + destroy(); } std::string DateTimeFormatter::getDateTime(time_t intime, const i18n_udate_format_h format) const { - static const int maxLen = 128; - I18nString res(maxLen); - i18n_udate uTime = (i18n_udate)intime * 1000; - int32_t formattedStrLen = 0; - i18n_udate_format_date(format, uTime, res.getUStr(), res.getCapacity(), nullptr, &formattedStrLen); - return res.toStr(); + static const int maxLen = 128; + I18nString res(maxLen); + i18n_udate uTime = (i18n_udate)intime * 1000; + int32_t formattedStrLen = 0; + i18n_udate_format_date(format, uTime, res.getUStr(), res.getCapacity(), nullptr, &formattedStrLen); + return res.toStr(); } std::string DateTimeFormatter::getTime(time_t intime) const { - return getDateTime(intime, m_Time); + return getDateTime(intime, m_Time); } std::string DateTimeFormatter::getDate(time_t intime) const { - return getDateTime(intime, m_Date); + return getDateTime(intime, m_Date); } void DateTimeFormatter::set24hTimeFormat(bool value) { - m_IsTime24Format = value; - LOG("24Format: ", value); + m_IsTime24Format = value; + LOG("24Format: ", value); } void DateTimeFormatter::setRegion(std::string region) { - m_Region = std::move(region); - if (m_Region.empty()) - m_Region = defaultRegion; + m_Region = std::move(region); + if (m_Region.empty()) + m_Region = defaultRegion; - LOG("Region: ", m_Region); + LOG("Region: ", m_Region); } void DateTimeFormatter::setTimeZone(const std::string &timeZone) { - m_TimeZoneId = timeZone; - LOG("TimeZone: ", m_TimeZoneId.toStr()); + m_TimeZoneId = timeZone; + LOG("TimeZone: ", m_TimeZoneId.toStr()); } void DateTimeFormatter::update() { - i18n_ulocale_set_default(nullptr); - i18n_ucalendar_set_default_timezone(m_TimeZoneId); - updateGen(); - updateTime(); - updateDate(); + i18n_ulocale_set_default(nullptr); + i18n_ucalendar_set_default_timezone(m_TimeZoneId); + updateGen(); + updateTime(); + updateDate(); } void DateTimeFormatter::updateDate() { - destroyDate(); + destroyDate(); - int32_t bestPatternLen = 0; + int32_t bestPatternLen = 0; - I18nString skeleton = "MMMEd"; - I18nString uBestPattern(128); + I18nString skeleton = "MMMEd"; + I18nString uBestPattern(128); - i18n_udatepg_get_best_pattern(m_Gen, skeleton, skeleton.getLen(), uBestPattern, uBestPattern.getCapacity(), &bestPatternLen); - std::string aPattern = uBestPattern.toStr(); - i18n_udate_create(I18N_UDATE_PATTERN, I18N_UDATE_PATTERN, m_Region.c_str(), m_TimeZoneId, -1, uBestPattern, -1, &m_Date); - LOG("BestPattern: ", uBestPattern.toStr()); + i18n_udatepg_get_best_pattern(m_Gen, skeleton, skeleton.getLen(), uBestPattern, uBestPattern.getCapacity(), &bestPatternLen); + std::string aPattern = uBestPattern.toStr(); + i18n_udate_create(I18N_UDATE_PATTERN, I18N_UDATE_PATTERN, m_Region.c_str(), m_TimeZoneId, -1, uBestPattern, -1, &m_Date); + LOG("BestPattern: ", uBestPattern.toStr()); } void DateTimeFormatter::updateTime() { - int32_t bestPatternLen = 0; - I18nString uBestPattern(128); - static const std::string period = "a"; - I18nString skeleton = m_IsTime24Format ? "HH:mm" : ("h:mm " + period); + int32_t bestPatternLen = 0; + I18nString uBestPattern(128); + static const std::string period = "a"; + I18nString skeleton = m_IsTime24Format ? "HH:mm" : ("h:mm " + period); - destroyTime(); - i18n_udatepg_get_best_pattern(m_Gen, skeleton, skeleton.getLen(), uBestPattern, uBestPattern.getCapacity(), &bestPatternLen); - std::string aPattern = uBestPattern.toStr(); + destroyTime(); + i18n_udatepg_get_best_pattern(m_Gen, skeleton, skeleton.getLen(), uBestPattern, uBestPattern.getCapacity(), &bestPatternLen); + std::string aPattern = uBestPattern.toStr(); - if (m_IsTime24Format) { - // Remove am/pm: - cleanupPattern(aPattern, " a"); - } else { - static const std::string searchWord = period; - static const std::string tagOpen = "'<ampm>'"; - static const std::string tagClose = "'</ampm>'"; - aPattern = highlightKeyword(aPattern, searchWord, tagOpen, tagClose); - cleanupPattern(aPattern, " "); - } + if (m_IsTime24Format) { + // Remove am/pm: + cleanupPattern(aPattern, " a"); + } else { + static const std::string searchWord = period; + static const std::string tagOpen = "'<ampm>'"; + static const std::string tagClose = "'</ampm>'"; + aPattern = highlightKeyword(aPattern, searchWord, tagOpen, tagClose); + cleanupPattern(aPattern, " "); + } - uBestPattern = aPattern; + uBestPattern = aPattern; - i18n_udate_create(I18N_UDATE_PATTERN, I18N_UDATE_PATTERN, m_Region.c_str(), m_TimeZoneId, -1, uBestPattern, -1, &m_Time); - LOG("BestPattern: ", uBestPattern.toStr()); + i18n_udate_create(I18N_UDATE_PATTERN, I18N_UDATE_PATTERN, m_Region.c_str(), m_TimeZoneId, -1, uBestPattern, -1, &m_Time); + LOG("BestPattern: ", uBestPattern.toStr()); } void DateTimeFormatter::destroyGen() { - if (m_Gen) { - i18n_udatepg_destroy(m_Gen); - m_Gen = nullptr; - } + if (m_Gen) { + i18n_udatepg_destroy(m_Gen); + m_Gen = nullptr; + } } void DateTimeFormatter::destroyTime() { - if (m_Time) { - i18n_udate_destroy(m_Time); - m_Time = nullptr; - } + if (m_Time) { + i18n_udate_destroy(m_Time); + m_Time = nullptr; + } } void DateTimeFormatter::destroyDate() { - if (m_Date) { - i18n_udate_destroy(m_Date); - m_Date = nullptr; - } + if (m_Date) { + i18n_udate_destroy(m_Date); + m_Date = nullptr; + } } void DateTimeFormatter::destroy() { - destroyTime(); - destroyDate(); - destroyGen(); + destroyTime(); + destroyDate(); + destroyGen(); } void DateTimeFormatter::updateGen() { - destroyGen(); - i18n_udatepg_create(m_Region.c_str(), &m_Gen); + destroyGen(); + i18n_udatepg_create(m_Region.c_str(), &m_Gen); } diff --git a/src/App/src/DateTimeView.cpp b/src/App/src/DateTimeView.cpp index 44e1464..33bb897 100644 --- a/src/App/src/DateTimeView.cpp +++ b/src/App/src/DateTimeView.cpp @@ -25,7 +25,7 @@ using namespace IdleClock; DateTimeView::DateTimeView(Evas_Object *parent) { - setEo(View::addLayout(parent, CLOCK_DIGITAL_EDJ, "layout_clock_digital")); + setEo(View::addLayout(parent, CLOCK_DIGITAL_EDJ, "layout_clock_digital")); } DateTimeView::~DateTimeView() @@ -34,10 +34,10 @@ DateTimeView::~DateTimeView() void DateTimeView::setHours(const std::string &time) { - setText(time, "text_hour"); + setText(time, "text_hour"); } void DateTimeView::setMinutes(const std::string &time) { - setText(time, "text_min"); + setText(time, "text_min"); } diff --git a/src/App/src/MainController.cpp b/src/App/src/MainController.cpp index 0214295..e2fa387 100644 --- a/src/App/src/MainController.cpp +++ b/src/App/src/MainController.cpp @@ -24,12 +24,12 @@ using namespace IdleClock; MainController::MainController(Evas_Object *parent) - : MainLayout(parent) - , m_pTimeView(nullptr) + : MainLayout(parent) + , m_pTimeView(nullptr) { - m_pTimeView = new DateTimeView(getEo()); - MainLayout::setDateTime(*m_pTimeView); - updateTime(); + m_pTimeView = new DateTimeView(getEo()); + MainLayout::setDateTime(*m_pTimeView); + updateTime(); } MainController::~MainController() @@ -38,98 +38,98 @@ MainController::~MainController() void MainController::onPause() { - LOG(""); + LOG(""); } void MainController::onResume() { - LOG(""); - dispTime(); + LOG(""); + dispTime(); } void MainController::onControl(app_control_h app_control) { - LOG(""); + LOG(""); } void MainController::onTick(watch_time_h watch_time) { - LOG(""); - dispTime(watch_time); + LOG(""); + dispTime(watch_time); } void MainController::onAmbientTick(watch_time_h watch_time) { - LOG(""); - dispTime(watch_time); + LOG(""); + dispTime(watch_time); } void MainController::onAmbientChanged(bool ambient_mode) { - LOG(""); + LOG(""); } void MainController::onLanguageChanged(app_event_info_h appEvent) { - LOG(""); - updateTime(); + LOG(""); + updateTime(); } void MainController::onLowBattery(app_event_info_h appEvent) { - LOG(""); + LOG(""); } void MainController::onRegionChanged(app_event_info_h appEvent) { - LOG(""); - updateTime(); + LOG(""); + updateTime(); } void MainController::onTimeFormatChanged() { - LOG(""); - updateTime(); + LOG(""); + updateTime(); } void MainController::onTimeChanged() { - LOG(""); - updateTime(); + LOG(""); + updateTime(); } void MainController::dispTime() { - dispTime(time(nullptr)); + dispTime(time(nullptr)); } void MainController::dispTime(time_t tt) { - std::string timeStr = m_Formatter.getTime(tt); - LOG("Time: ", timeStr); + std::string timeStr = m_Formatter.getTime(tt); + LOG("Time: ", timeStr); - char *lexeme = strtok(const_cast<char*>(timeStr.c_str()), ":"); - std::string hoursStr = lexeme; - lexeme = strtok(nullptr, ":"); - std::string minutesStr = lexeme; + char *lexeme = strtok(const_cast<char*>(timeStr.c_str()), ":"); + std::string hoursStr = lexeme; + lexeme = strtok(nullptr, ":"); + std::string minutesStr = lexeme; - m_pTimeView->setHours(hoursStr); - m_pTimeView->setMinutes(minutesStr); + m_pTimeView->setHours(hoursStr); + m_pTimeView->setMinutes(minutesStr); } void MainController::dispTime(watch_time_h watch_time) { - time_t tt = {}; - if (watch_time_get_utc_timestamp(watch_time, &tt) == 0) - dispTime(tt); + time_t tt = {}; + if (watch_time_get_utc_timestamp(watch_time, &tt) == 0) + dispTime(tt); } void MainController::updateTime() { - LOG(""); - m_Formatter.set24hTimeFormat(WatchApp::getInst().is24TimeFormat()); - m_Formatter.setTimeZone(WatchApp::getInst().getTimeZone()); - m_Formatter.setRegion(WatchApp::getInst().getCountry()); - m_Formatter.update(); - dispTime(); + LOG(""); + m_Formatter.set24hTimeFormat(WatchApp::getInst().is24TimeFormat()); + m_Formatter.setTimeZone(WatchApp::getInst().getTimeZone()); + m_Formatter.setRegion(WatchApp::getInst().getCountry()); + m_Formatter.update(); + dispTime(); } diff --git a/src/App/src/MainLayout.cpp b/src/App/src/MainLayout.cpp index 9c779f6..b347345 100644 --- a/src/App/src/MainLayout.cpp +++ b/src/App/src/MainLayout.cpp @@ -25,7 +25,7 @@ using namespace IdleClock; MainLayout::MainLayout(Evas_Object *parent) { - setEo(View::addLayout(parent, MAINT_LAYOUT_EDJ, "main")); + setEo(View::addLayout(parent, MAINT_LAYOUT_EDJ, "main")); } MainLayout::~MainLayout() @@ -34,5 +34,5 @@ MainLayout::~MainLayout() void MainLayout::setDateTime(Evas_Object *dateTime) { - setContent(dateTime, "time.part"); + setContent(dateTime, "time.part"); } diff --git a/src/App/src/WatchApp.cpp b/src/App/src/WatchApp.cpp index dbc6a60..715ecf4 100644 --- a/src/App/src/WatchApp.cpp +++ b/src/App/src/WatchApp.cpp @@ -29,8 +29,8 @@ using namespace IdleClock; WatchApp WatchApp::m_AppInst; WatchApp::WatchApp() - : m_pWindow(nullptr) - , m_pRootController(nullptr) + : m_pWindow(nullptr) + , m_pRootController(nullptr) { } @@ -40,175 +40,175 @@ WatchApp::~WatchApp() WatchApp &WatchApp::getInst() { - return m_AppInst; + return m_AppInst; } void WatchApp::exit() { - watch_app_exit(); + watch_app_exit(); } WatchWindow &WatchApp::getWindow() { - ASSERT(m_pWindow, "Window is null"); - return *m_pWindow; + ASSERT(m_pWindow, "Window is null"); + return *m_pWindow; } const WatchWindow &WatchApp::getWindow() const { - return const_cast<WatchApp*>(this)->getWindow(); + return const_cast<WatchApp*>(this)->getWindow(); } int WatchApp::start(int argc, char *argv[]) { - watch_app_lifecycle_callback_s cbs = {}; + watch_app_lifecycle_callback_s cbs = {}; - cbs.create = makeCbLast(&WatchApp::onCreate); - cbs.terminate = makeCbLast(&WatchApp::onTerminate); - cbs.pause = makeCbLast(&WatchApp::onPause); - cbs.resume = makeCbLast(&WatchApp::onResume); - cbs.app_control = makeCbLast(&WatchApp::onControl); - cbs.time_tick = makeCbLast(&WatchApp::onTick); - cbs.ambient_tick = makeCbLast(&WatchApp::onAmbientTick); - cbs.ambient_changed = makeCbLast(&WatchApp::onAmbientChanged); + cbs.create = makeCbLast(&WatchApp::onCreate); + cbs.terminate = makeCbLast(&WatchApp::onTerminate); + cbs.pause = makeCbLast(&WatchApp::onPause); + cbs.resume = makeCbLast(&WatchApp::onResume); + cbs.app_control = makeCbLast(&WatchApp::onControl); + cbs.time_tick = makeCbLast(&WatchApp::onTick); + cbs.ambient_tick = makeCbLast(&WatchApp::onAmbientTick); + cbs.ambient_changed = makeCbLast(&WatchApp::onAmbientChanged); - app_event_handler_h events[3] = {}; + app_event_handler_h events[3] = {}; - watch_app_add_event_handler(&events[0], APP_EVENT_LANGUAGE_CHANGED, makeCbLast(&WatchApp::onLanguageChanged), this); - watch_app_add_event_handler(&events[1], APP_EVENT_REGION_FORMAT_CHANGED, makeCbLast(&WatchApp::onRegionChanged), this); - watch_app_add_event_handler(&events[2], APP_EVENT_LOW_BATTERY, makeCbLast(&WatchApp::onLowBattery), this); + watch_app_add_event_handler(&events[0], APP_EVENT_LANGUAGE_CHANGED, makeCbLast(&WatchApp::onLanguageChanged), this); + watch_app_add_event_handler(&events[1], APP_EVENT_REGION_FORMAT_CHANGED, makeCbLast(&WatchApp::onRegionChanged), this); + watch_app_add_event_handler(&events[2], APP_EVENT_LOW_BATTERY, makeCbLast(&WatchApp::onLowBattery), this); - system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_LOCALE_TIMEFORMAT_24HOUR, makeCbLast(&WatchApp::onTimeFormatChanged), this); - system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_TIME_CHANGED, makeCbLast(&WatchApp::onTimeChanged), this); + system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_LOCALE_TIMEFORMAT_24HOUR, makeCbLast(&WatchApp::onTimeFormatChanged), this); + system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_TIME_CHANGED, makeCbLast(&WatchApp::onTimeChanged), this); - return watch_app_main(argc, argv, &cbs, this); + return watch_app_main(argc, argv, &cbs, this); } std::string WatchApp::getStr(system_settings_key_e key) const { - std::string res; - char *value = nullptr; - system_settings_get_value_string(key, &value); - if (value) { - res = value; - free(value); - } - return res; + std::string res; + char *value = nullptr; + system_settings_get_value_string(key, &value); + if (value) { + res = value; + free(value); + } + return res; } std::string WatchApp::getLang() const { - return getStr(SYSTEM_SETTINGS_KEY_LOCALE_TIMEZONE); + return getStr(SYSTEM_SETTINGS_KEY_LOCALE_TIMEZONE); } std::string WatchApp::getTimeZone() const { - return getStr(SYSTEM_SETTINGS_KEY_LOCALE_TIMEZONE); + return getStr(SYSTEM_SETTINGS_KEY_LOCALE_TIMEZONE); } std::string WatchApp::getCountry() const { - return getStr(SYSTEM_SETTINGS_KEY_LOCALE_COUNTRY); + return getStr(SYSTEM_SETTINGS_KEY_LOCALE_COUNTRY); } bool WatchApp::is24TimeFormat() const { - bool value = false; - system_settings_get_value_bool(SYSTEM_SETTINGS_KEY_LOCALE_TIMEFORMAT_24HOUR, &value); - return value; + bool value = false; + system_settings_get_value_bool(SYSTEM_SETTINGS_KEY_LOCALE_TIMEFORMAT_24HOUR, &value); + return value; } bool WatchApp::onCreate(int width, int height) { - 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"); - watch_app_set_time_tick_frequency(1, WATCH_APP_TIME_TICKS_PER_MINUTE); + elm_app_base_scale_set(1.3); + elm_config_accel_preference_set("3d"); + watch_app_set_time_tick_frequency(1, WATCH_APP_TIME_TICKS_PER_MINUTE); - m_pWindow = new WatchWindow; - m_pWindow->resize(width, height); - m_pWindow->show(); + m_pWindow = new WatchWindow; + m_pWindow->resize(width, height); + m_pWindow->show(); - m_pRootController = new MainController(m_pWindow->getLayout()); - m_pWindow->setContent(*m_pRootController); + m_pRootController = new MainController(m_pWindow->getLayout()); + m_pWindow->setContent(*m_pRootController); - return true; + return true; } void WatchApp::onTerminate() { - TRACE; - m_pWindow->destroy(); + TRACE; + m_pWindow->destroy(); } void WatchApp::onTimeFormatChanged(system_settings_key_e key) { - if (m_pRootController) - m_pRootController->onTimeFormatChanged(); + if (m_pRootController) + m_pRootController->onTimeFormatChanged(); } void WatchApp::onTimeChanged(system_settings_key_e key) { - if (m_pRootController) - m_pRootController->onTimeChanged(); + if (m_pRootController) + m_pRootController->onTimeChanged(); } void WatchApp::onPause() { - if (m_pRootController) - m_pRootController->onPause(); + if (m_pRootController) + m_pRootController->onPause(); } void WatchApp::onResume() { - if (m_pRootController) - m_pRootController->onResume(); + if (m_pRootController) + m_pRootController->onResume(); } void WatchApp::onTick(watch_time_h watch_time) { - if (m_pRootController) - m_pRootController->onTick(watch_time); + if (m_pRootController) + m_pRootController->onTick(watch_time); } void WatchApp::onAmbientTick(watch_time_h watch_time) { - if (m_pRootController) - m_pRootController->onAmbientTick(watch_time); + if (m_pRootController) + m_pRootController->onAmbientTick(watch_time); } void WatchApp::onAmbientChanged(bool ambient_mode) { - if (m_pRootController) - m_pRootController->onAmbientChanged(ambient_mode); + if (m_pRootController) + m_pRootController->onAmbientChanged(ambient_mode); } void WatchApp::onControl(app_control_h app_control) { - if (m_pRootController) - m_pRootController->onControl(app_control); + if (m_pRootController) + m_pRootController->onControl(app_control); } void WatchApp::onLanguageChanged(app_event_info_h appEvent) { - if (m_pRootController) - m_pRootController->onLanguageChanged(appEvent); + if (m_pRootController) + m_pRootController->onLanguageChanged(appEvent); } void WatchApp::onLowBattery(app_event_info_h appEvent) { - if (m_pRootController) - m_pRootController->onLowBattery(appEvent); + if (m_pRootController) + m_pRootController->onLowBattery(appEvent); } void WatchApp::onRegionChanged(app_event_info_h appEvent) { - if (m_pRootController) - m_pRootController->onRegionChanged(appEvent); + if (m_pRootController) + m_pRootController->onRegionChanged(appEvent); } diff --git a/src/Common/inc/Atspi.h b/src/Common/inc/Atspi.h index b92bdc8..ed8e076 100644 --- a/src/Common/inc/Atspi.h +++ b/src/Common/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. @@ -23,132 +23,132 @@ #include <Elementary.h> namespace IdleClock { - /** - * @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 char *text); - void setDescription(const std::string &text); - void setName(const char *text); - void setName(const std::string &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 char *text) - { - elm_atspi_accessible_description_set(m_pEo, text); - elm_atspi_accessible_translation_domain_set(m_pEo, PACKAGE_NAME); - } - - inline void Atspi::setDescription(const std::string &text) - { - setDescription(text.c_str()); - } - - inline void Atspi::setName(const char *text) - { - elm_atspi_accessible_name_set(m_pEo, (char*)text); - } - - inline void Atspi::setName(const std::string &text) - { - setName(text.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 char *text); + void setDescription(const std::string &text); + void setName(const char *text); + void setName(const std::string &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 char *text) + { + elm_atspi_accessible_description_set(m_pEo, text); + elm_atspi_accessible_translation_domain_set(m_pEo, PACKAGE_NAME); + } + + inline void Atspi::setDescription(const std::string &text) + { + setDescription(text.c_str()); + } + + inline void Atspi::setName(const char *text) + { + elm_atspi_accessible_name_set(m_pEo, (char*)text); + } + + inline void Atspi::setName(const std::string &text) + { + setName(text.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/inc/BaseView.h b/src/Common/inc/BaseView.h index fbdd988..ddba3bd 100644 --- a/src/Common/inc/BaseView.h +++ b/src/Common/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 IdleClock { - /** - * @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/inc/Callback.h b/src/Common/inc/Callback.h index f71259d..c5c2f9f 100644 --- a/src/Common/inc/Callback.h +++ b/src/Common/inc/Callback.h @@ -22,19 +22,19 @@ struct Callback; template <class R, class C, class... A> struct Callback<R(C::*)(A...)> { - using M = R(C::*)(A...); + using M = R(C::*)(A...); - template <M m> - static R stubFirst(void *obj, A... args) - { - return (static_cast<C*>(obj)->*m)(args...); - } + template <M m> + static R stubFirst(void *obj, A... args) + { + return (static_cast<C*>(obj)->*m)(args...); + } - template <M m> - static R stubLast(A... args, void *obj) - { - return (static_cast<C*>(obj)->*m)(args...); - } + template <M m> + static R stubLast(A... args, void *obj) + { + return (static_cast<C*>(obj)->*m)(args...); + } }; #define makeCbFirst(method) Callback<decltype(method)>::stubFirst<method> diff --git a/src/Common/inc/I18nString.h b/src/Common/inc/I18nString.h index 89f61b9..3203030 100644 --- a/src/Common/inc/I18nString.h +++ b/src/Common/inc/I18nString.h @@ -22,36 +22,36 @@ namespace IdleClock { - class I18nString : - private std::basic_string<i18n_uchar> { - - public: - I18nString(); - I18nString(const I18nString &that); - I18nString(I18nString &&that); - I18nString(size_t count); - I18nString(const char *str); - I18nString(const i18n_uchar *uStr); - I18nString(const std::string &str); - - I18nString &operator=(const I18nString &that); - i18n_uchar *getUStr() const; - operator i18n_uchar *() const; - int getLen() const; - std::string toStr() const; - size_t getCapacity() const; - void clear(); - bool isEmpty() const; - - private: - using Impl = std::basic_string<i18n_uchar>; - - private: - void copyStr(const I18nString &that); - void copyStr(const i18n_uchar *uStr); - void copyStr(const std::string &str); - void copyStr(const char *str); - }; + class I18nString : + private std::basic_string<i18n_uchar> { + + public: + I18nString(); + I18nString(const I18nString &that); + I18nString(I18nString &&that); + I18nString(size_t count); + I18nString(const char *str); + I18nString(const i18n_uchar *uStr); + I18nString(const std::string &str); + + I18nString &operator=(const I18nString &that); + i18n_uchar *getUStr() const; + operator i18n_uchar *() const; + int getLen() const; + std::string toStr() const; + size_t getCapacity() const; + void clear(); + bool isEmpty() const; + + private: + using Impl = std::basic_string<i18n_uchar>; + + private: + void copyStr(const I18nString &that); + void copyStr(const i18n_uchar *uStr); + void copyStr(const std::string &str); + void copyStr(const char *str); + }; } #endif /* I18nString_h_ */ diff --git a/src/Common/inc/LangUtils.h b/src/Common/inc/LangUtils.h index 659793b..f1b99fa 100644 --- a/src/Common/inc/LangUtils.h +++ b/src/Common/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,122 +28,122 @@ namespace IdleClock { - // Translatable Text - struct TText - { - // Constructor for nullptr; - TText(std::nullptr_t) - : m_pDomain(nullptr) - , m_IsTranslatable(false) - { - } - - // 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 = APP_DOMAIN) - : m_pDomain(domainName) - , m_Str(str ? str : "") - , m_IsTranslatable(translatable) - { - } - - // Constructor for C++ string - TText(std::string str, bool translatable = false, const char *domainName = APP_DOMAIN) - : m_pDomain(domainName) - , m_Str(std::move(str)) - , m_IsTranslatable(translatable) - { - } - - 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; - } - - private: - const char *m_pDomain; - std::string m_Str; - bool m_IsTranslatable; - }; - - // dgettext - struct DText - { - explicit DText(const char *stringId, const char *domainName) - { - m_pMsg = dgettext(domainName, stringId); - } - - explicit DText(const std::string &stringId, const char *domainName) - { - m_pMsg = dgettext(domainName, stringId.c_str()); - } - - explicit DText(char dummyArg, 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; - } - - const char* cStr() const - { - return m_pMsg; - } - - operator std::string() const - { - return m_pMsg; - } - - private: - DText(DText&) = delete; - DText operator =(DText&) = delete; - - static const int maxBufSize = 1024; - char m_Buf[maxBufSize]; - const char *m_pMsg; - }; - - #define msgt(strId) TText(strId, true, MSG_DOMAIN) - #define msg(strId) DText(strId, MSG_DOMAIN) - #define msgArgs(strId, ...) DText(0, strId, MSG_DOMAIN, __VA_ARGS__) - #define sys(strId) DText(strId, SYS_DOMAIN) - #define syst(strId) TText(strId, true, SYS_DOMAIN) - #define sysArgs(strId, ...) DText(0, strId, SYS_DOMAIN, __VA_ARGS__) + // Translatable Text + struct TText + { + // Constructor for nullptr; + TText(std::nullptr_t) + : m_pDomain(nullptr) + , m_IsTranslatable(false) + { + } + + // 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 = APP_DOMAIN) + : m_pDomain(domainName) + , m_Str(str ? str : "") + , m_IsTranslatable(translatable) + { + } + + // Constructor for C++ string + TText(std::string str, bool translatable = false, const char *domainName = APP_DOMAIN) + : m_pDomain(domainName) + , m_Str(std::move(str)) + , m_IsTranslatable(translatable) + { + } + + 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; + } + + private: + const char *m_pDomain; + std::string m_Str; + bool m_IsTranslatable; + }; + + // dgettext + struct DText + { + explicit DText(const char *stringId, const char *domainName) + { + m_pMsg = dgettext(domainName, stringId); + } + + explicit DText(const std::string &stringId, const char *domainName) + { + m_pMsg = dgettext(domainName, stringId.c_str()); + } + + explicit DText(char dummyArg, 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; + } + + const char* cStr() const + { + return m_pMsg; + } + + operator std::string() const + { + return m_pMsg; + } + + private: + DText(DText&) = delete; + DText operator =(DText&) = delete; + + static const int maxBufSize = 1024; + char m_Buf[maxBufSize]; + const char *m_pMsg; + }; + + #define msgt(strId) TText(strId, true, MSG_DOMAIN) + #define msg(strId) DText(strId, MSG_DOMAIN) + #define msgArgs(strId, ...) DText(0, strId, MSG_DOMAIN, __VA_ARGS__) + #define sys(strId) DText(strId, SYS_DOMAIN) + #define syst(strId) TText(strId, true, SYS_DOMAIN) + #define sysArgs(strId, ...) DText(0, strId, SYS_DOMAIN, __VA_ARGS__) } #endif /* LangUtils_h_ */ diff --git a/src/Common/inc/Logger.h b/src/Common/inc/Logger.h index 14b6bab..657ad40 100644 --- a/src/Common/inc/Logger.h +++ b/src/Common/inc/Logger.h @@ -23,65 +23,65 @@ #include <string> #include <sstream> -#ifndef LOGGER_TAG - #error "Please define LOGGER_TAG" +#ifndef LOGGER_TAG + #error "Please define LOGGER_TAG" #endif 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<typename... Tail> 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<bool> { (messageStr << msg, true)... }; - dlog_print(static_cast<log_priority>(prior) - , tag, "%s: %s(%d) -> %s", file, function, line - , messageStr.str().c_str()); + std::ostringstream messageStr; + (void)std::initializer_list<bool> { (messageStr << msg, true)... }; + dlog_print(static_cast<log_priority>(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; }; #define TRACE\ - LoggerImpl __tmp_logger_unique(LOGGER_TAG, __FILE__, __FUNCTION__, __LINE__);\ + LoggerImpl __tmp_logger_unique(LOGGER_TAG, __FILE__, __FUNCTION__, __LINE__);\ #define LOG(...)\ - loggerImpl(LogPriority::INFO, LOGGER_TAG, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__); + loggerImpl(LogPriority::INFO, LOGGER_TAG, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__); #define LOG_INFO(...)\ - loggerImpl(LogPriority::INFO, LOGGER_TAG, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__); + loggerImpl(LogPriority::INFO, LOGGER_TAG, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__); #define LOG_ERROR(...)\ - loggerImpl(LogPriority::ERROR, LOGGER_TAG, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__); + loggerImpl(LogPriority::ERROR, LOGGER_TAG, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__); #define LOG_WARN(...)\ - loggerImpl(LogPriority::WARN, LOGGER_TAG, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__); + loggerImpl(LogPriority::WARN, LOGGER_TAG, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__); #define ASSERT(expr, ...)\ - if (!(expr)) { LOG_ERROR(__VA_ARGS__); } \ - assert(expr) + if (!(expr)) { LOG_ERROR(__VA_ARGS__); } \ + assert(expr) #endif /* LOGGER_H_ */ diff --git a/src/Common/inc/PathUtils.h b/src/Common/inc/PathUtils.h index 177ac97..b2db5ad 100644 --- a/src/Common/inc/PathUtils.h +++ b/src/Common/inc/PathUtils.h @@ -21,53 +21,53 @@ #include "Resource.h" namespace IdleClock { - 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/inc/View.h b/src/Common/inc/View.h index 803ef0b..cb113cd 100644 --- a/src/Common/inc/View.h +++ b/src/Common/inc/View.h @@ -24,599 +24,599 @@ #include <efl_extension.h> namespace IdleClock { - /** - * @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<typename T> - static T staticCast(void *evasObj); - template<typename T> - static T reinterpretCast(void *evasObj); - template<typename T> - 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; - - /** - * @brief Resize view - * @param[in] w width - * @param[in] h height - */ - void resize(Evas_Coord w, Evas_Coord h); - - 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); - - protected: - virtual ~View(); - - /** - * @brief Allows children-classes to perform some cleanup activities before their destroying. - */ - virtual void onBeforeDelete() {}; - 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.getMsg()); - } - } - - 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); - } - - inline void View::resize(Evas_Coord w, Evas_Coord h) - { - evas_object_resize(m_pEo, w, h); - } - - template<typename T> - inline T View::staticCast(void *evasObj) - { - return static_cast<T>(getData((Evas_Object*)evasObj)); - } - - template<typename T> - inline T View::reinterpretCast(void *evasObj) - { - return reinterpret_cast<T>(getData((Evas_Object*)evasObj)); - } - - template<typename T> - inline T View::dynamicCast(void *evasObj) - { - return dynamic_cast<T>(staticCast<View*>(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<typename T> + static T staticCast(void *evasObj); + template<typename T> + static T reinterpretCast(void *evasObj); + template<typename T> + 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; + + /** + * @brief Resize view + * @param[in] w width + * @param[in] h height + */ + void resize(Evas_Coord w, Evas_Coord h); + + 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); + + protected: + virtual ~View(); + + /** + * @brief Allows children-classes to perform some cleanup activities before their destroying. + */ + virtual void onBeforeDelete() {}; + 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.getMsg()); + } + } + + 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); + } + + inline void View::resize(Evas_Coord w, Evas_Coord h) + { + evas_object_resize(m_pEo, w, h); + } + + template<typename T> + inline T View::staticCast(void *evasObj) + { + return static_cast<T>(getData((Evas_Object*)evasObj)); + } + + template<typename T> + inline T View::reinterpretCast(void *evasObj) + { + return reinterpret_cast<T>(getData((Evas_Object*)evasObj)); + } + + template<typename T> + inline T View::dynamicCast(void *evasObj) + { + return dynamic_cast<T>(staticCast<View*>(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/inc/WatchWindow.h b/src/Common/inc/WatchWindow.h index 7d98ff6..54b7877 100644 --- a/src/Common/inc/WatchWindow.h +++ b/src/Common/inc/WatchWindow.h @@ -20,19 +20,19 @@ #include "View.h" namespace IdleClock { - class WatchWindow - : public View { - public: - WatchWindow(); - virtual ~WatchWindow(); + class WatchWindow + : public View { + public: + WatchWindow(); + virtual ~WatchWindow(); - Evas_Object *getLayout() const; - void setContent(Evas_Object *content); - void getScreenSize(int *w, int *h) const; - int getRotation() const; - void lower(); - void raise(); - }; + Evas_Object *getLayout() const; + void setContent(Evas_Object *content); + void getScreenSize(int *w, int *h) const; + int getRotation() const; + void lower(); + void raise(); + }; } #endif /* WatchWindow_h_ */ diff --git a/src/Common/src/I18nString.cpp b/src/Common/src/I18nString.cpp index 8ce901e..cac4eac 100644 --- a/src/Common/src/I18nString.cpp +++ b/src/Common/src/I18nString.cpp @@ -25,113 +25,113 @@ I18nString::I18nString() I18nString::I18nString(const I18nString &that) { - copyStr(that); + copyStr(that); } I18nString::I18nString(I18nString &&that) - : Impl(std::move(that)) + : Impl(std::move(that)) { } I18nString::I18nString(size_t count) - : Impl(count, 0) + : Impl(count, 0) { } I18nString::I18nString(const char *str) { - copyStr(str); + copyStr(str); } I18nString::I18nString(const i18n_uchar *uStr) { - copyStr(uStr); + copyStr(uStr); } I18nString::I18nString(const std::string &str) - : I18nString(str.c_str()) + : I18nString(str.c_str()) { } i18n_uchar *I18nString::getUStr() const { - return (i18n_uchar*)&front(); + return (i18n_uchar*)&front(); } I18nString::operator i18n_uchar *() const { - return getUStr(); + return getUStr(); } I18nString &I18nString::operator=(const I18nString &that) { - copyStr(that); - return *this; + copyStr(that); + return *this; } int I18nString::getLen() const { - return data() ? i18n_ustring_get_length(data()) : 0; + return data() ? i18n_ustring_get_length(data()) : 0; } std::string I18nString::toStr() const { - std::string res; - int len = length() * sizeof(i18n_uchar); - if (len >= 0) { - res.resize(len); - i18n_ustring_copy_au(&res.front(), data()); - } - return res; + std::string res; + int len = length() * sizeof(i18n_uchar); + if (len >= 0) { + res.resize(len); + i18n_ustring_copy_au(&res.front(), data()); + } + return res; } size_t I18nString::getCapacity() const { - return capacity(); + return capacity(); } void I18nString::clear() { - std::basic_string<i18n_uchar>::clear(); + std::basic_string<i18n_uchar>::clear(); } bool I18nString::isEmpty() const { - return Impl::empty(); + return Impl::empty(); } void I18nString::copyStr(const I18nString &that) { - copyStr(that.getUStr()); + copyStr(that.getUStr()); } void I18nString::copyStr(const i18n_uchar *uStr) { - clear(); - if (uStr) { - int len = uStr ? i18n_ustring_get_length(uStr) : 0; - resize(len); - i18n_ustring_mem_copy(getUStr(), uStr, len); - } + clear(); + if (uStr) { + int len = uStr ? i18n_ustring_get_length(uStr) : 0; + resize(len); + i18n_ustring_mem_copy(getUStr(), uStr, len); + } } void I18nString::copyStr(const std::string &str) { - clear(); - if (!str.empty()) { - size_t len = str.length(); - resize(len); - i18n_ustring_copy_ua_n(getUStr(), str.c_str(), len); - } + clear(); + if (!str.empty()) { + size_t len = str.length(); + resize(len); + i18n_ustring_copy_ua_n(getUStr(), str.c_str(), len); + } } void I18nString::copyStr(const char *str) { - clear(); - if (str) { - size_t len = strlen(str); - resize(len); - i18n_ustring_copy_ua_n(getUStr(), str, len); - } + clear(); + if (str) { + size_t len = strlen(str); + resize(len); + i18n_ustring_copy_ua_n(getUStr(), str, len); + } } diff --git a/src/Common/src/Logger.cpp b/src/Common/src/Logger.cpp index 1ac27ff..c9220ef 100644 --- a/src/Common/src/Logger.cpp +++ b/src/Common/src/Logger.cpp @@ -17,29 +17,29 @@ #include "Logger.h" 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/src/PathUtils.cpp b/src/Common/src/PathUtils.cpp index 1750fc1..7d04934 100644 --- a/src/Common/src/PathUtils.cpp +++ b/src/Common/src/PathUtils.cpp @@ -27,115 +27,115 @@ 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) { - int *internalStorage = (int *)userData; - *internalStorage = storageId; - return false; - } - return true; + if (type == STORAGE_TYPE_INTERNAL) { + 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) - storage_get_directory(storageId, STORAGE_DIRECTORY_DOWNLOADS, &dirPath); + int error = storage_foreach_device_supported(storageCb, &storageId); + if (error == STORAGE_ERROR_NONE) + 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/src/View.cpp b/src/Common/src/View.cpp index 639f4c2..3081ea7 100644 --- a/src/Common/src/View.cpp +++ b/src/Common/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 IdleClock; namespace { - const char *thisKey = "this"; + const char *thisKey = "this"; } View::View() @@ -39,125 +39,125 @@ View::~View() void View::setEo(Evas_Object *eo) { - if (m_pEo) { - LOG_ERROR("m_pEo not null"); - assert(false); - return; - } + if (m_pEo) { + LOG_ERROR("m_pEo not null"); + assert(false); + return; + } - BaseView::setEo(eo); + BaseView::setEo(eo); - if (eo) { - setData(this); - evas_object_event_callback_add(eo, EVAS_CALLBACK_FREE, on_free_cb, this); - evas_object_event_callback_add(eo, EVAS_CALLBACK_DEL, on_del_cb, this); - } + if (eo) { + setData(this); + evas_object_event_callback_add(eo, EVAS_CALLBACK_FREE, on_free_cb, this); + evas_object_event_callback_add(eo, EVAS_CALLBACK_DEL, on_del_cb, this); + } } -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) { - auto *view = static_cast<View*>(data); - if (view) - view->onViewDestroyed(); + auto *view = static_cast<View*>(data); + if (view) + view->onViewDestroyed(); } void View::on_del_cb(void *data, Evas *e, Evas_Object *obj, void *event_info) { - auto *view = static_cast<View*>(data); - if (view) - view->onBeforeDelete(); + auto *view = static_cast<View*>(data); + if (view) + view->onBeforeDelete(); } 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::getEdjePath(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::getEdjePath(edjePath); + elm_layout_file_set(layout, edjAbsPath.c_str(), group.c_str()); + return layout; } 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 IdleClock::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 IdleClock::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 IdleClock::markupToUtf8(const std::string &str) { - return markupToUtf8(str.c_str()); + return markupToUtf8(str.c_str()); } std::string IdleClock::utf8ToMarkup(const std::string &str) { - return utf8ToMarkup(str.c_str()); + return utf8ToMarkup(str.c_str()); } diff --git a/src/Common/src/WatchWindow.cpp b/src/Common/src/WatchWindow.cpp index 627f21b..5c87fb6 100644 --- a/src/Common/src/WatchWindow.cpp +++ b/src/Common/src/WatchWindow.cpp @@ -23,20 +23,20 @@ using namespace IdleClock; WatchWindow::WatchWindow() { - Evas_Object *win = nullptr; + Evas_Object *win = nullptr; - watch_app_get_elm_win(&win); - if (!win) - return; + watch_app_get_elm_win(&win); + if (!win) + return; - setEo(win); - elm_win_title_set(win, PROJECT_NAME); - elm_win_borderless_set(win, true); - elm_win_alpha_set(win, false); - elm_win_indicator_mode_set(win, ELM_WIN_INDICATOR_HIDE); - elm_win_indicator_opacity_set(win, ELM_WIN_INDICATOR_BG_TRANSPARENT); - elm_win_prop_focus_skip_set(win, true); - elm_win_role_set(win, "no-effect"); + setEo(win); + elm_win_title_set(win, PROJECT_NAME); + elm_win_borderless_set(win, true); + elm_win_alpha_set(win, false); + elm_win_indicator_mode_set(win, ELM_WIN_INDICATOR_HIDE); + elm_win_indicator_opacity_set(win, ELM_WIN_INDICATOR_BG_TRANSPARENT); + elm_win_prop_focus_skip_set(win, true); + elm_win_role_set(win, "no-effect"); } WatchWindow::~WatchWindow() @@ -45,33 +45,33 @@ WatchWindow::~WatchWindow() void WatchWindow::lower() { - elm_win_lower(getEo()); + elm_win_lower(getEo()); } void WatchWindow::raise() { - elm_win_raise(getEo()); + elm_win_raise(getEo()); } Evas_Object *WatchWindow::getLayout() const { - return getEo(); + return getEo(); } void WatchWindow::setContent(Evas_Object *content) { - expand(content); - evas_object_show(content); - elm_win_resize_object_add(getEo(), content); + expand(content); + evas_object_show(content); + elm_win_resize_object_add(getEo(), content); } void WatchWindow::getScreenSize(int *w, int *h) const { - elm_win_screen_size_get(getEo(), nullptr, nullptr, w, h); + elm_win_screen_size_get(getEo(), nullptr, nullptr, w, h); } int WatchWindow::getRotation() const { - return elm_win_rotation_get(getEo()); + return elm_win_rotation_get(getEo()); } diff --git a/src/main.cpp b/src/main.cpp index 5d4be0a..9a40d36 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -20,6 +20,6 @@ EXPORT_API int main(int argc, char *argv[]) { - TRACE; - return IdleClock::WatchApp::getInst().start(argc, argv); + TRACE; + return IdleClock::WatchApp::getInst().start(argc, argv); } |