From fc5ab3a70c04755d3f00f38b3eb63af5dcf6e027 Mon Sep 17 00:00:00 2001 From: Hubert Chrzaniuk Date: Tue, 19 Jan 2021 14:26:27 +0100 Subject: [PATCH] [EGD-5325] Remove using namespace directives from headers "Using namespace" directive should not be added in headers because this practice pollutes source files. --- .../ApplicationCalendar.cpp | 2 +- .../ApplicationCalendar.hpp | 3 +- .../data/CalendarData.hpp | 6 +- .../application-calendar/data/dateCommon.hpp | 70 ++++++++--------- .../models/AllEventsModel.cpp | 4 +- .../models/DayEventsModel.cpp | 6 +- .../models/DayEventsModel.hpp | 6 +- .../widgets/EventDateItem.cpp | 6 +- .../widgets/EventDateItem.hpp | 4 +- .../widgets/EventTimeItem.cpp | 6 +- .../widgets/EventTimeItem.hpp | 4 +- .../application-calendar/widgets/MonthBox.cpp | 2 +- .../windows/AllEventsWindow.hpp | 2 +- .../windows/CalendarMainWindow.cpp | 4 +- .../windows/DayEventsWindow.hpp | 2 +- .../windows/CellularPassthroughWindow.hpp | 4 +- .../Audio/StreamQueuedEventsListener.cpp | 3 +- .../Audio/StreamQueuedEventsListener.hpp | 6 +- module-db/Common/Query.cpp | 2 +- module-db/Common/Query.hpp | 8 +- module-db/Interface/AlarmsRecord.hpp | 2 +- module-db/Interface/EventsRecord.cpp | 9 ++- module-db/Interface/EventsRecord.hpp | 15 ++-- module-db/Tables/AlarmsTable.cpp | 2 +- module-db/Tables/AlarmsTable.hpp | 5 +- module-db/Tables/EventsTable.cpp | 9 ++- module-db/Tables/EventsTable.hpp | 14 ++-- .../calendar/QueryEventsGetFiltered.cpp | 5 +- .../calendar/QueryEventsGetFiltered.hpp | 9 ++- .../QueryEventsSelectFirstUpcoming.cpp | 2 +- .../QueryEventsSelectFirstUpcoming.hpp | 6 +- module-db/tests/AlarmsRecord_tests.cpp | 2 +- module-db/tests/AlarmsTable_tests.cpp | 10 +-- module-db/tests/EventsRecord_tests.cpp | 11 ++- module-db/tests/EventsTable_tests.cpp | 76 ++++++++++--------- module-db/tests/QueryInterface.cpp | 4 +- .../CellularRequestHandler.cpp | 2 + .../service-cellular/CellularUrcHandler.cpp | 2 + .../service-cellular/CellularUrcHandler.hpp | 24 +++--- .../CellularRequestHandler.hpp | 18 ++--- .../service-desktop/DesktopMessages.cpp | 1 + .../endpoints/EndpointFactory.hpp | 27 ++++--- .../endpoints/backup/BackupEndpoint.cpp | 2 + .../endpoints/backup/BackupEndpoint.hpp | 10 +-- .../calendarEvents/CalendarEventsEndpoint.hpp | 10 +-- .../endpoints/calllog/CalllogEndpoint.hpp | 10 +-- .../endpoints/contacts/ContactsEndpoint.hpp | 10 +-- .../developerMode/DeveloperModeEndpoint.hpp | 10 +-- .../deviceInfo/DeviceInfoEndpoint.cpp | 2 + .../deviceInfo/DeviceInfoEndpoint.hpp | 8 +- .../factoryReset/FactoryResetEndpoint.cpp | 6 +- .../factoryReset/FactoryResetEndpoint.hpp | 8 +- .../filesystem/FilesystemEndpoint.cpp | 4 +- .../filesystem/FilesystemEndpoint.hpp | 10 +-- .../endpoints/messages/MessagesEndpoint.hpp | 10 +-- .../endpoints/restore/RestoreEndpoint.cpp | 2 + .../endpoints/restore/RestoreEndpoint.hpp | 6 +- .../endpoints/update/UpdateEndpoint.cpp | 2 + .../endpoints/update/UpdateEndpoint.hpp | 10 +-- .../service-desktop/DesktopMessages.hpp | 2 +- .../service-fota/FotaUrcHandler.cpp | 2 + .../service-fota/FotaUrcHandler.hpp | 24 +++--- .../service-time/CalendarTimeEvents.hpp | 2 +- .../timeEvents/CalendarTimeEvents.cpp | 7 +- module-sys/SystemManager/SystemManager.cpp | 4 +- module-sys/SystemManager/SystemManager.hpp | 9 ++- module-utils/ical/ParserICS.cpp | 13 ++-- module-utils/ical/ParserICS.hpp | 14 ++-- module-utils/time/TimeRangeParser.cpp | 4 +- module-utils/time/TimeRangeParser.hpp | 4 +- 70 files changed, 311 insertions(+), 299 deletions(-) diff --git a/module-apps/application-calendar/ApplicationCalendar.cpp b/module-apps/application-calendar/ApplicationCalendar.cpp index 8736f5c47..33a1902c8 100644 --- a/module-apps/application-calendar/ApplicationCalendar.cpp +++ b/module-apps/application-calendar/ApplicationCalendar.cpp @@ -147,7 +147,7 @@ namespace app void ApplicationCalendar::destroyUserInterface() {} - void ApplicationCalendar::switchToNoEventsWindow(const std::string &title, const TimePoint &dateFilter) + void ApplicationCalendar::switchToNoEventsWindow(const std::string &title, const calendar::TimePoint &dateFilter) { if (equivalentWindow == EquivalentWindow::DayEventsWindow) { popToWindow(gui::name::window::main_window); diff --git a/module-apps/application-calendar/ApplicationCalendar.hpp b/module-apps/application-calendar/ApplicationCalendar.hpp index e30f45568..15d353f4d 100644 --- a/module-apps/application-calendar/ApplicationCalendar.hpp +++ b/module-apps/application-calendar/ApplicationCalendar.hpp @@ -55,7 +55,8 @@ namespace app } void createUserInterface() override; void destroyUserInterface() override; - void switchToNoEventsWindow(const std::string &title = "", const TimePoint &dateFilter = TimePoint()); + void switchToNoEventsWindow(const std::string &title = "", + const calendar::TimePoint &dateFilter = calendar::TimePoint()); static const std::map reminderOptions; static const std::map repeatOptions; diff --git a/module-apps/application-calendar/data/CalendarData.hpp b/module-apps/application-calendar/data/CalendarData.hpp index c61c518b5..1e27e2e48 100644 --- a/module-apps/application-calendar/data/CalendarData.hpp +++ b/module-apps/application-calendar/data/CalendarData.hpp @@ -42,7 +42,7 @@ class DayMonthData : public gui::SwitchData { protected: std::string dayMonth; - TimePoint dateFilter; + calendar::TimePoint dateFilter; public: DayMonthData() = default; @@ -52,12 +52,12 @@ class DayMonthData : public gui::SwitchData return dayMonth; }; - TimePoint getDateFilter() + calendar::TimePoint getDateFilter() { return dateFilter; }; - virtual void setData(std::string dayMonthText, const TimePoint &dateNumb) + virtual void setData(std::string dayMonthText, const calendar::TimePoint &dateNumb) { dayMonth = dayMonthText; dateFilter = dateNumb; diff --git a/module-apps/application-calendar/data/dateCommon.hpp b/module-apps/application-calendar/data/dateCommon.hpp index 107d5dec3..f3d852d24 100644 --- a/module-apps/application-calendar/data/dateCommon.hpp +++ b/module-apps/application-calendar/data/dateCommon.hpp @@ -9,13 +9,13 @@ #include #include -using namespace std::chrono; -using namespace std::chrono_literals; - -using Clock = system_clock; -using TimePoint = time_point; -using YearMonthDay = date::year_month_day; -using YearMonthDayLast = date::year_month_day_last; +namespace calendar +{ + using Clock = std::chrono::system_clock; + using TimePoint = std::chrono::time_point; + using YearMonthDay = date::year_month_day; + using YearMonthDayLast = date::year_month_day_last; +} // namespace calendar inline constexpr auto max_month_day = 48; @@ -43,7 +43,7 @@ enum class Repeat yearly }; -inline constexpr TimePoint TIME_POINT_INVALID = date::sys_days{date::January / 1 / 1970}; +inline constexpr calendar::TimePoint TIME_POINT_INVALID = date::sys_days{date::January / 1 / 1970}; inline constexpr uint32_t yearDigitsNumb = 4, monthDigitsNumb = 2, dayDigitsNumb = 2, HourDigitsNumb = 2, MinDigitsNumb = 2, SecDigitsNumb = 2; @@ -88,34 +88,34 @@ inline time_t GetAsUTCTime(int year, int month, int day, int hour = 0, int minut return basetime + GetDiffLocalWithUTCTime(); } -inline TimePoint TimePointFromTimeT(const time_t &time) +inline calendar::TimePoint TimePointFromTimeT(const time_t &time) { - return system_clock::from_time_t(time); + return std::chrono::system_clock::from_time_t(time); } -inline time_t TimePointToTimeT(const TimePoint &tp) +inline time_t TimePointToTimeT(const calendar::TimePoint &tp) { - return system_clock::to_time_t(tp); + return std::chrono::system_clock::to_time_t(tp); } -inline TimePoint TimePointNow() +inline calendar::TimePoint TimePointNow() { utils::time::Timestamp timestamp; return TimePointFromTimeT(timestamp.getTime()); } -inline std::string TimePointToString(const TimePoint &tp) +inline std::string TimePointToString(const calendar::TimePoint &tp) { - return date::format("%F %T", time_point_cast(tp)); + return date::format("%F %T", std::chrono::time_point_cast(tp)); } -inline auto TimePointToHourMinSec(const TimePoint &tp) +inline auto TimePointToHourMinSec(const calendar::TimePoint &tp) { auto dp = date::floor(tp); return date::make_time(tp - dp); } -inline uint32_t TimePointToHour24H(const TimePoint &tp) +inline uint32_t TimePointToHour24H(const calendar::TimePoint &tp) { auto time = TimePointToTimeT(tp); utils::time::Timestamp timestamp(time); @@ -123,7 +123,7 @@ inline uint32_t TimePointToHour24H(const TimePoint &tp) return hour; } -inline uint32_t TimePointToMinutes(const TimePoint &tp) +inline uint32_t TimePointToMinutes(const calendar::TimePoint &tp) { auto time = TimePointToTimeT(tp); utils::time::Timestamp timestamp(time); @@ -131,7 +131,7 @@ inline uint32_t TimePointToMinutes(const TimePoint &tp) return minute; } -inline TimePoint getFirstWeekDay(const TimePoint &tp) +inline calendar::TimePoint getFirstWeekDay(const calendar::TimePoint &tp) { date::year_month_day yearMonthDay = date::year_month_day{date::floor(tp)}; auto hourV = TimePointToHour24H(tp); @@ -146,12 +146,12 @@ inline TimePoint getFirstWeekDay(const TimePoint &tp) return finalDateTime; } -inline std::string TimePointToString(const TimePoint &tp, date::months months) +inline std::string TimePointToString(const calendar::TimePoint &tp, date::months months) { date::year_month_day yearMonthDay = date::year_month_day{date::floor(tp)}; date::year_month_day yearMonthDayLast = yearMonthDay.year() / yearMonthDay.month() / date::last; - TimePoint timePoint; + calendar::TimePoint timePoint; if ((static_cast(yearMonthDay.month()) + months.count()) <= 12) { if (yearMonthDayLast.day() == yearMonthDay.day()) { @@ -173,41 +173,41 @@ inline std::string TimePointToString(const TimePoint &tp, date::months months) timePoint = date::sys_days{yearMonthDay.year() / yearMonthDay.month() / yearMonthDay.day()}; } } - return date::format("%F %T", time_point_cast(timePoint)); + return date::format("%F %T", std::chrono::time_point_cast(timePoint)); } -inline std::string TimePointToLocalizedDateString(const TimePoint &tp, const std::string format = "") +inline std::string TimePointToLocalizedDateString(const calendar::TimePoint &tp, const std::string format = "") { auto time = TimePointToTimeT(tp); utils::time::Date timestamp(time); return timestamp.str(format); } -inline std::string TimePointToLocalizedTimeString(const TimePoint &tp, const std::string format = "") +inline std::string TimePointToLocalizedTimeString(const calendar::TimePoint &tp, const std::string format = "") { auto time = TimePointToTimeT(tp); utils::time::Time timestamp(time); return timestamp.str(format); } -inline TimePoint TimePointFromString(const char *s1) +inline calendar::TimePoint TimePointFromString(const char *s1) { - TimePoint tp; + calendar::TimePoint tp; std::istringstream(s1) >> date::parse("%F %T", tp); return tp; } -inline YearMonthDay TimePointToYearMonthDay(const TimePoint &tp) +inline calendar::YearMonthDay TimePointToYearMonthDay(const calendar::TimePoint &tp) { return date::year_month_day{date::floor(tp)}; } -inline TimePoint TimePointFromYearMonthDay(const YearMonthDay &ymd) +inline calendar::TimePoint TimePointFromYearMonthDay(const calendar::YearMonthDay &ymd) { return date::sys_days{ymd.year() / ymd.month() / ymd.day()}; } -inline time_t TimePointToMin(const TimePoint &tp) +inline time_t TimePointToMin(const calendar::TimePoint &tp) { auto time = TimePointToTimeT(tp); auto duration = new utils::time::Duration(time); @@ -215,7 +215,7 @@ inline time_t TimePointToMin(const TimePoint &tp) return minutes; } -inline uint32_t TimePointToHour12H(const TimePoint &tp) +inline uint32_t TimePointToHour12H(const calendar::TimePoint &tp) { auto time = TimePointToTimeT(tp); utils::time::Timestamp timestamp(time); @@ -226,7 +226,7 @@ inline uint32_t TimePointToHour12H(const TimePoint &tp) return hour; } -inline std::string TimePointToHourString12H(const TimePoint &tp) +inline std::string TimePointToHourString12H(const calendar::TimePoint &tp) { auto hour = utils::time::Timestamp(TimePointToTimeT(tp)).get_UTC_date_time_sub_value(utils::time::GetParameters::Hour); @@ -234,14 +234,14 @@ inline std::string TimePointToHourString12H(const TimePoint &tp) return utils::to_string(hour12h); } -inline std::string TimePointToHourString24H(const TimePoint &tp) +inline std::string TimePointToHourString24H(const calendar::TimePoint &tp) { auto hour = utils::time::Timestamp(TimePointToTimeT(tp)).get_UTC_date_time_sub_value(utils::time::GetParameters::Hour); return utils::to_string(hour); } -inline std::string TimePointToMinutesString(const TimePoint &tp) +inline std::string TimePointToMinutesString(const calendar::TimePoint &tp) { auto minute = TimePointToMinutes(tp); auto minuteString = std::to_string(minute); @@ -252,9 +252,9 @@ inline std::string TimePointToMinutesString(const TimePoint &tp) } // 0: Monday, 1: Tuesday ... 6: Sunday -inline unsigned int WeekdayIndexFromTimePoint(const TimePoint &tp) +inline unsigned int WeekdayIndexFromTimePoint(const calendar::TimePoint &tp) { - auto ymw = date::year_month_weekday{floor(tp)}; + auto ymw = date::year_month_weekday{std::chrono::floor(tp)}; return ymw.weekday().iso_encoding() - 1; } diff --git a/module-apps/application-calendar/models/AllEventsModel.cpp b/module-apps/application-calendar/models/AllEventsModel.cpp index 93872f156..9a5a99710 100644 --- a/module-apps/application-calendar/models/AllEventsModel.cpp +++ b/module-apps/application-calendar/models/AllEventsModel.cpp @@ -83,8 +83,8 @@ auto AllEventsModel::handleQueryResponse(db::QueryResult *queryResult) -> bool auto eventShift = app->getEventShift(); if (eventShift) { for (auto &record : records) { - record.date_from += hours(eventShift); - record.date_till += hours(eventShift); + record.date_from += std::chrono::hours(eventShift); + record.date_till += std::chrono::hours(eventShift); } } return this->updateRecords(std::move(records)); diff --git a/module-apps/application-calendar/models/DayEventsModel.cpp b/module-apps/application-calendar/models/DayEventsModel.cpp index 8c5f55e58..b439da6e4 100644 --- a/module-apps/application-calendar/models/DayEventsModel.cpp +++ b/module-apps/application-calendar/models/DayEventsModel.cpp @@ -82,8 +82,8 @@ auto DayEventsModel::handleQueryResponse(db::QueryResult *queryResult) -> bool auto eventShift = app->getEventShift(); if (eventShift) { for (auto &record : records) { - record.date_from += hours(eventShift); - record.date_till += hours(eventShift); + record.date_from += std::chrono::hours(eventShift); + record.date_till += std::chrono::hours(eventShift); } } return updateRecords(std::move(records)); @@ -95,7 +95,7 @@ auto DayEventsModel::handleQueryResponse(db::QueryResult *queryResult) -> bool return false; } -void DayEventsModel::setFilters(TimePoint from, TimePoint till, const std::string &dayMonth) +void DayEventsModel::setFilters(calendar::TimePoint from, calendar::TimePoint till, const std::string &dayMonth) { this->filterFrom = from; this->filterTill = till; diff --git a/module-apps/application-calendar/models/DayEventsModel.hpp b/module-apps/application-calendar/models/DayEventsModel.hpp index 2cfac0f24..b223f0dda 100644 --- a/module-apps/application-calendar/models/DayEventsModel.hpp +++ b/module-apps/application-calendar/models/DayEventsModel.hpp @@ -15,13 +15,13 @@ class DayEventsModel : public app::DatabaseModel, { app::Application *application = nullptr; std::string dayMonthTitle; - TimePoint filterFrom = TIME_POINT_INVALID; - TimePoint filterTill = TIME_POINT_INVALID; + calendar::TimePoint filterFrom = TIME_POINT_INVALID; + calendar::TimePoint filterTill = TIME_POINT_INVALID; public: DayEventsModel(app::Application *app); - void setFilters(TimePoint from, TimePoint till, const std::string &dayMonth); + void setFilters(calendar::TimePoint from, calendar::TimePoint till, const std::string &dayMonth); bool updateRecords(std::vector records) override; auto handleQueryResponse(db::QueryResult *) -> bool; diff --git a/module-apps/application-calendar/widgets/EventDateItem.cpp b/module-apps/application-calendar/widgets/EventDateItem.cpp index 94e5c0379..73e749875 100644 --- a/module-apps/application-calendar/widgets/EventDateItem.cpp +++ b/module-apps/application-calendar/widgets/EventDateItem.cpp @@ -149,7 +149,7 @@ namespace gui return true; } - YearMonthDay EventDateItem::validateDate() + calendar::YearMonthDay EventDateItem::validateDate() { auto actualDate = TimePointToYearMonthDay(TimePointNow()); uint32_t day; @@ -185,7 +185,7 @@ namespace gui } month = std::clamp(static_cast(month), 1u, static_cast(date::dec)); - YearMonthDayLast max_date = date::year(year) / date::month(month) / date::last; + calendar::YearMonthDayLast max_date = date::year(year) / date::month(month) / date::last; if (day > static_cast(max_date.day())) { dayInput->setText(std::to_string(static_cast(max_date.day()))); } @@ -194,7 +194,7 @@ namespace gui return date::year(year) / date::month(month) / date::day(day); } - const YearMonthDay EventDateItem::getChosenDate() + const calendar::YearMonthDay EventDateItem::getChosenDate() { return validateDate(); } diff --git a/module-apps/application-calendar/widgets/EventDateItem.hpp b/module-apps/application-calendar/widgets/EventDateItem.hpp index 2a0ecdff1..3d0cf8edb 100644 --- a/module-apps/application-calendar/widgets/EventDateItem.hpp +++ b/module-apps/application-calendar/widgets/EventDateItem.hpp @@ -24,12 +24,12 @@ namespace gui void buildInterface(); void applyItemSpecificProperties(gui::Text *item); void applyCallbacks(); - YearMonthDay validateDate(); + calendar::YearMonthDay validateDate(); public: EventDateItem(); - const YearMonthDay getChosenDate(); + const calendar::YearMonthDay getChosenDate(); // virtual methods from Item bool onDimensionChanged(const BoundingBox &oldDim, const BoundingBox &newDim) override; }; diff --git a/module-apps/application-calendar/widgets/EventTimeItem.cpp b/module-apps/application-calendar/widgets/EventTimeItem.cpp index 93bd99da5..cb1ad4345 100644 --- a/module-apps/application-calendar/widgets/EventTimeItem.cpp +++ b/module-apps/application-calendar/widgets/EventTimeItem.cpp @@ -433,9 +433,9 @@ namespace gui } } - TimePoint EventTimeItem::calculateEventTime(YearMonthDay date, - std::chrono::hours hours, - std::chrono::minutes minutes) + calendar::TimePoint EventTimeItem::calculateEventTime(calendar::YearMonthDay date, + std::chrono::hours hours, + std::chrono::minutes minutes) { return TimePointFromYearMonthDay(date) + hours + minutes; } diff --git a/module-apps/application-calendar/widgets/EventTimeItem.hpp b/module-apps/application-calendar/widgets/EventTimeItem.hpp index a93dfcf01..5ee53bfd5 100644 --- a/module-apps/application-calendar/widgets/EventTimeItem.hpp +++ b/module-apps/application-calendar/widgets/EventTimeItem.hpp @@ -43,7 +43,9 @@ namespace gui std::chrono::minutes end_hour, uint32_t start_minutes, uint32_t end_minutes); - TimePoint calculateEventTime(YearMonthDay date, std::chrono::hours hours, std::chrono::minutes minutes); + calendar::TimePoint calculateEventTime(calendar::YearMonthDay date, + std::chrono::hours hours, + std::chrono::minutes minutes); public: EventTimeItem(const std::string &description, diff --git a/module-apps/application-calendar/widgets/MonthBox.cpp b/module-apps/application-calendar/widgets/MonthBox.cpp index 4b44d5f08..8d3cce7a2 100644 --- a/module-apps/application-calendar/widgets/MonthBox.cpp +++ b/module-apps/application-calendar/widgets/MonthBox.cpp @@ -58,7 +58,7 @@ namespace gui auto mainWindow = dynamic_cast(parent); if (mainWindow->returnedFromWindow) { focusChangedCallback = [=](Item &item) { - YearMonthDay date = monthFilterValue.year() / monthFilterValue.month() / date::last; + calendar::YearMonthDay date = monthFilterValue.year() / monthFilterValue.month() / date::last; if (unsigned(date.day()) < mainWindow->dayFocusedBefore) { setFocusOnElement(unsigned(date.day()) - 1); } diff --git a/module-apps/application-calendar/windows/AllEventsWindow.hpp b/module-apps/application-calendar/windows/AllEventsWindow.hpp index 5d1b5d5d8..af0fc5d31 100644 --- a/module-apps/application-calendar/windows/AllEventsWindow.hpp +++ b/module-apps/application-calendar/windows/AllEventsWindow.hpp @@ -16,7 +16,7 @@ namespace gui gui::Image *leftArrowImage = nullptr; gui::Image *newDayEventImage = nullptr; - TimePoint dateFilter = TimePointNow(); + calendar::TimePoint dateFilter = TimePointNow(); gui::ListView *allEventsList = nullptr; std::shared_ptr allEventsModel = nullptr; diff --git a/module-apps/application-calendar/windows/CalendarMainWindow.cpp b/module-apps/application-calendar/windows/CalendarMainWindow.cpp index 271d57aab..5702f305e 100644 --- a/module-apps/application-calendar/windows/CalendarMainWindow.cpp +++ b/module-apps/application-calendar/windows/CalendarMainWindow.cpp @@ -197,8 +197,8 @@ namespace gui void CalendarMainWindow::filterRequest() { - YearMonthDay date_from = actualDate.year() / actualDate.month() / 1; - YearMonthDay date_till = date_from + date::months{1}; + calendar::YearMonthDay date_from = actualDate.year() / actualDate.month() / 1; + calendar::YearMonthDay date_till = date_from + date::months{1}; auto filter_from = TimePointFromYearMonthDay(date_from); auto filter_till = TimePointFromYearMonthDay(date_till); LOG_DEBUG("filter: %s", TimePointToString(filter_till).c_str()); diff --git a/module-apps/application-calendar/windows/DayEventsWindow.hpp b/module-apps/application-calendar/windows/DayEventsWindow.hpp index cc5450b4f..0a1e7282f 100644 --- a/module-apps/application-calendar/windows/DayEventsWindow.hpp +++ b/module-apps/application-calendar/windows/DayEventsWindow.hpp @@ -19,7 +19,7 @@ namespace gui class DayEventsWindow : public gui::AppWindow { std::string dayMonthTitle; - TimePoint filterFrom; + calendar::TimePoint filterFrom; gui::Image *leftArrowImage = nullptr; gui::Image *newDayEventImage = nullptr; gui::ListView *dayEventsList = nullptr; diff --git a/module-apps/application-settings/windows/CellularPassthroughWindow.hpp b/module-apps/application-settings/windows/CellularPassthroughWindow.hpp index 9f50c1982..5ad79d9e0 100644 --- a/module-apps/application-settings/windows/CellularPassthroughWindow.hpp +++ b/module-apps/application-settings/windows/CellularPassthroughWindow.hpp @@ -30,8 +30,6 @@ namespace gui } // namespace cellular_passthrough } // namespace window - using namespace bsp::cellular::USB; - class CellularPassthroughWindow : public AppWindow { private: @@ -76,7 +74,7 @@ namespace gui CellularPassthroughWindow::State getInitialState(); - bool set(PassthroughState pass_to_set, BootPinState dfu_to_set); + bool set(bsp::cellular::USB::PassthroughState pass_to_set, bsp::cellular::USB::BootPinState dfu_to_set); void setWindowState(State state); diff --git a/module-audio/Audio/StreamQueuedEventsListener.cpp b/module-audio/Audio/StreamQueuedEventsListener.cpp index 4ea6b2aae..81f8d9f92 100644 --- a/module-audio/Audio/StreamQueuedEventsListener.cpp +++ b/module-audio/Audio/StreamQueuedEventsListener.cpp @@ -5,7 +5,8 @@ using namespace audio; -StreamQueuedEventsListener::StreamQueuedEventsListener(std::shared_ptr eventsQueue) : queue(eventsQueue) +StreamQueuedEventsListener::StreamQueuedEventsListener(std::shared_ptr eventsQueue) + : queue(eventsQueue) {} void StreamQueuedEventsListener::onEvent(Stream *stream, Stream::Event event, Stream::EventSourceMode source) diff --git a/module-audio/Audio/StreamQueuedEventsListener.hpp b/module-audio/Audio/StreamQueuedEventsListener.hpp index b818efa97..100c29a62 100644 --- a/module-audio/Audio/StreamQueuedEventsListener.hpp +++ b/module-audio/Audio/StreamQueuedEventsListener.hpp @@ -13,8 +13,6 @@ namespace audio { - using namespace cpp_freertos; - class StreamQueuedEventsListener : public Stream::EventListener { private: @@ -29,7 +27,7 @@ namespace audio using queuedEvent = std::pair; static constexpr auto listenerElementSize = sizeof(EventStorage); - StreamQueuedEventsListener(std::shared_ptr eventsQueue); + StreamQueuedEventsListener(std::shared_ptr eventsQueue); void onEvent(Stream *stream, Stream::Event event, Stream::EventSourceMode source); @@ -39,7 +37,7 @@ namespace audio std::size_t getEventsCount() const; private: - std::shared_ptr queue; + std::shared_ptr queue; }; }; // namespace audio diff --git a/module-db/Common/Query.cpp b/module-db/Common/Query.cpp index 1f96ccfe8..c8590df6e 100644 --- a/module-db/Common/Query.cpp +++ b/module-db/Common/Query.cpp @@ -21,7 +21,7 @@ bool QueryCallback::handleQueryResponse(QueryResult *response) return callback(response); } -EndpointListener::EndpointListener(EndpointQueryCallbackFunction &&_callback, Context &_context) +EndpointListener::EndpointListener(EndpointQueryCallbackFunction &&_callback, parserFSM::Context &_context) : callback{std::move(_callback)}, context{_context} {} diff --git a/module-db/Common/Query.hpp b/module-db/Common/Query.hpp index d107d2af0..607e7a92f 100644 --- a/module-db/Common/Query.hpp +++ b/module-db/Common/Query.hpp @@ -9,13 +9,11 @@ #include #include -using namespace parserFSM; - namespace db { class QueryResult; // Forward declaration using QueryCallbackFunction = std::function; - using EndpointQueryCallbackFunction = std::function; + using EndpointQueryCallbackFunction = std::function; class QueryListener { @@ -42,13 +40,13 @@ namespace db { public: EndpointListener() = default; - EndpointListener(EndpointQueryCallbackFunction &&_callback, Context &_context); + EndpointListener(EndpointQueryCallbackFunction &&_callback, parserFSM::Context &_context); bool handleQueryResponse(db::QueryResult *result) override; private: EndpointQueryCallbackFunction callback; - Context context; + parserFSM::Context context; }; /// virtual query input interface diff --git a/module-db/Interface/AlarmsRecord.hpp b/module-db/Interface/AlarmsRecord.hpp index e11bbbd66..fb4c1c656 100644 --- a/module-db/Interface/AlarmsRecord.hpp +++ b/module-db/Interface/AlarmsRecord.hpp @@ -28,7 +28,7 @@ namespace db::query::alarms struct AlarmsRecord : public Record { - TimePoint time = TIME_POINT_INVALID; + calendar::TimePoint time = TIME_POINT_INVALID; uint32_t snooze = 0; AlarmStatus status = AlarmStatus::On; uint32_t repeat = 0; diff --git a/module-db/Interface/EventsRecord.cpp b/module-db/Interface/EventsRecord.cpp index c8d2cdef6..ed13ae284 100644 --- a/module-db/Interface/EventsRecord.cpp +++ b/module-db/Interface/EventsRecord.cpp @@ -70,8 +70,8 @@ bool EventsRecordInterface::Add(const EventsRecord &rec) return false; } -std::vector EventsRecordInterface::Select(TimePoint filter_from, - TimePoint filter_till, +std::vector EventsRecordInterface::Select(calendar::TimePoint filter_from, + calendar::TimePoint filter_till, uint32_t offset, uint32_t limit) { @@ -265,12 +265,13 @@ uint32_t EventsRecordInterface::GetCount() return eventsDb->events.count(); } -uint32_t EventsRecordInterface::GetCountFiltered(TimePoint from, TimePoint till) +uint32_t EventsRecordInterface::GetCountFiltered(calendar::TimePoint from, calendar::TimePoint till) { return eventsDb->events.countFromFilter(from, till); } -std::vector EventsRecordInterface::SelectFirstUpcoming(TimePoint filter_from, TimePoint filter_till) +std::vector EventsRecordInterface::SelectFirstUpcoming(calendar::TimePoint filter_from, + calendar::TimePoint filter_till) { auto rows = eventsDb->events.SelectFirstUpcoming(filter_from, filter_till); diff --git a/module-db/Interface/EventsRecord.hpp b/module-db/Interface/EventsRecord.hpp index 6c54c044f..a17566545 100644 --- a/module-db/Interface/EventsRecord.hpp +++ b/module-db/Interface/EventsRecord.hpp @@ -41,11 +41,11 @@ struct EventsRecord : public Record { std::string UID; std::string title; - TimePoint date_from; - TimePoint date_till; + calendar::TimePoint date_from; + calendar::TimePoint date_till; uint32_t reminder = 0; uint32_t repeat = 0; - TimePoint reminder_fired; + calendar::TimePoint reminder_fired; std::string provider_type; std::string provider_id; std::string provider_iCalUid; @@ -77,15 +77,18 @@ class EventsRecordInterface : public RecordInterface Select(TimePoint filter_from, TimePoint filter_till, uint32_t offset, uint32_t limit); + uint32_t GetCountFiltered(calendar::TimePoint from, calendar::TimePoint till); + std::vector Select(calendar::TimePoint filter_from, + calendar::TimePoint filter_till, + uint32_t offset, + uint32_t limit); std::unique_ptr> GetLimitOffset(uint32_t offset, uint32_t limit) override final; std::unique_ptr> GetLimitOffsetByField(uint32_t offset, uint32_t limit, EventsRecordField field, const char *str) override final; std::vector GetLimitOffsetByDate(uint32_t offset, uint32_t limit); - std::vector SelectFirstUpcoming(TimePoint filter_from, TimePoint filter_till); + std::vector SelectFirstUpcoming(calendar::TimePoint filter_from, calendar::TimePoint filter_till); std::unique_ptr runQuery(std::shared_ptr query) override; diff --git a/module-db/Tables/AlarmsTable.cpp b/module-db/Tables/AlarmsTable.cpp index abf7cd680..091492a30 100644 --- a/module-db/Tables/AlarmsTable.cpp +++ b/module-db/Tables/AlarmsTable.cpp @@ -9,7 +9,7 @@ AlarmsTableRow::AlarmsTableRow(const AlarmsRecord &rec) {} AlarmsTableRow::AlarmsTableRow( - uint32_t id, TimePoint time, uint32_t snooze, AlarmStatus status, uint32_t repeat, UTF8 path) + uint32_t id, calendar::TimePoint time, uint32_t snooze, AlarmStatus status, uint32_t repeat, UTF8 path) : Record{id}, time{time}, snooze{snooze}, status{status}, repeat{repeat}, path{std::move(path)} {} diff --git a/module-db/Tables/AlarmsTable.hpp b/module-db/Tables/AlarmsTable.hpp index 1c63dcf6b..83da528b6 100644 --- a/module-db/Tables/AlarmsTable.hpp +++ b/module-db/Tables/AlarmsTable.hpp @@ -25,14 +25,15 @@ enum class AlarmStatus struct AlarmsTableRow : public Record { - TimePoint time = TIME_POINT_INVALID; + calendar::TimePoint time = TIME_POINT_INVALID; uint32_t snooze = 0; AlarmStatus status = AlarmStatus::On; uint32_t repeat = 0; UTF8 path; AlarmsTableRow() = default; - AlarmsTableRow(uint32_t id, TimePoint time, uint32_t snooze, AlarmStatus status, uint32_t repeat, UTF8 path); + AlarmsTableRow( + uint32_t id, calendar::TimePoint time, uint32_t snooze, AlarmStatus status, uint32_t repeat, UTF8 path); explicit AlarmsTableRow(const AlarmsRecord &rec); explicit AlarmsTableRow(const QueryResult &result); }; diff --git a/module-db/Tables/EventsTable.cpp b/module-db/Tables/EventsTable.cpp index 658c16a65..25d508e47 100644 --- a/module-db/Tables/EventsTable.cpp +++ b/module-db/Tables/EventsTable.cpp @@ -643,8 +643,8 @@ EventsTableRow EventsTable::getByUID(const std::string &UID) }; } -std::vector EventsTable::selectByDatePeriod(TimePoint date_filter, - TimePoint filter_till, +std::vector EventsTable::selectByDatePeriod(calendar::TimePoint date_filter, + calendar::TimePoint filter_till, uint32_t offset, uint32_t limit) { @@ -770,7 +770,7 @@ uint32_t EventsTable::count() return (*queryRet)[0].getUInt32(); } -uint32_t EventsTable::countFromFilter(TimePoint from, TimePoint till) +uint32_t EventsTable::countFromFilter(calendar::TimePoint from, calendar::TimePoint till) { auto queryRet = db->query( "SELECT COUNT(*) FROM events WHERE date_from >= date('%q') AND date_from < date('%q', 'start of day');", @@ -791,7 +791,8 @@ uint32_t EventsTable::countByFieldId(const char *field, uint32_t id) return 0; } -std::vector EventsTable::SelectFirstUpcoming(TimePoint filter_from, TimePoint filter_till) +std::vector EventsTable::SelectFirstUpcoming(calendar::TimePoint filter_from, + calendar::TimePoint filter_till) { auto retQuery = db->query("SELECT DATETIME(date_from, '-' || reminder || ' minutes') AS calc_dt, * " "FROM events " diff --git a/module-db/Tables/EventsTable.hpp b/module-db/Tables/EventsTable.hpp index 99b226989..45d5b9be3 100644 --- a/module-db/Tables/EventsTable.hpp +++ b/module-db/Tables/EventsTable.hpp @@ -14,11 +14,11 @@ struct EventsTableRow : public Record { std::string UID; std::string title; - TimePoint date_from = TIME_POINT_INVALID; - TimePoint date_till = TIME_POINT_INVALID; + calendar::TimePoint date_from = TIME_POINT_INVALID; + calendar::TimePoint date_till = TIME_POINT_INVALID; uint32_t reminder = 0; uint32_t repeat = 0; - TimePoint reminder_fired = TIME_POINT_INVALID; + calendar::TimePoint reminder_fired = TIME_POINT_INVALID; std::string provider_type; std::string provider_id; std::string provider_iCalUid; @@ -53,12 +53,12 @@ class EventsTable : public Table bool drop(); EventsTableRow getByUID(const std::string &UID); EventsTableRow getById(uint32_t id) override final; - std::vector selectByDatePeriod(TimePoint filter_from, - TimePoint filter_till, + std::vector selectByDatePeriod(calendar::TimePoint filter_from, + calendar::TimePoint filter_till, uint32_t offset, uint32_t limit); uint32_t count() override final; - uint32_t countFromFilter(TimePoint from, TimePoint till); + uint32_t countFromFilter(calendar::TimePoint from, calendar::TimePoint till); uint32_t countByFieldId(const char *field, uint32_t id) override final; std::vector getLimitOffset(uint32_t offset, uint32_t limit) override final; std::vector getLimitOffsetByField(uint32_t offset, @@ -67,7 +67,7 @@ class EventsTable : public Table const char *str) override final; std::vector getLimitOffsetByDate(uint32_t offset, uint32_t limit); - std::vector SelectFirstUpcoming(TimePoint filter_from, TimePoint filter_till); + std::vector SelectFirstUpcoming(calendar::TimePoint filter_from, calendar::TimePoint filter_till); private: const char *createTableQuery = "CREATE TABLE IF NOT EXISTS events(" diff --git a/module-db/queries/calendar/QueryEventsGetFiltered.cpp b/module-db/queries/calendar/QueryEventsGetFiltered.cpp index 9c1594fd3..5120325b1 100644 --- a/module-db/queries/calendar/QueryEventsGetFiltered.cpp +++ b/module-db/queries/calendar/QueryEventsGetFiltered.cpp @@ -5,7 +5,10 @@ namespace db::query::events { - GetFiltered::GetFiltered(TimePoint filter_from, TimePoint filter_till, uint32_t offset, uint32_t limit) + GetFiltered::GetFiltered(calendar::TimePoint filter_from, + calendar::TimePoint filter_till, + uint32_t offset, + uint32_t limit) : Query(Query::Type::Read), filter_from(filter_from), filter_till(filter_till), offset(offset), limit(limit) {} diff --git a/module-db/queries/calendar/QueryEventsGetFiltered.hpp b/module-db/queries/calendar/QueryEventsGetFiltered.hpp index 250fe8c9a..73ef55117 100644 --- a/module-db/queries/calendar/QueryEventsGetFiltered.hpp +++ b/module-db/queries/calendar/QueryEventsGetFiltered.hpp @@ -13,11 +13,14 @@ namespace db::query::events class GetFiltered : public Query { public: - GetFiltered(TimePoint filter_from, TimePoint filter_till, uint32_t offset = 0, uint32_t limit = UINT32_MAX); + GetFiltered(calendar::TimePoint filter_from, + calendar::TimePoint filter_till, + uint32_t offset = 0, + uint32_t limit = UINT32_MAX); [[nodiscard]] auto debugInfo() const -> std::string override; - TimePoint filter_from; - TimePoint filter_till; + calendar::TimePoint filter_from; + calendar::TimePoint filter_till; uint32_t offset; uint32_t limit; }; diff --git a/module-db/queries/calendar/QueryEventsSelectFirstUpcoming.cpp b/module-db/queries/calendar/QueryEventsSelectFirstUpcoming.cpp index 0dad5dfae..0d4956df6 100644 --- a/module-db/queries/calendar/QueryEventsSelectFirstUpcoming.cpp +++ b/module-db/queries/calendar/QueryEventsSelectFirstUpcoming.cpp @@ -5,7 +5,7 @@ namespace db::query::events { - SelectFirstUpcoming::SelectFirstUpcoming(TimePoint filter_from, TimePoint filter_till) + SelectFirstUpcoming::SelectFirstUpcoming(calendar::TimePoint filter_from, calendar::TimePoint filter_till) : Query(Query::Type::Read), filter_from(filter_from), filter_till(filter_till) {} diff --git a/module-db/queries/calendar/QueryEventsSelectFirstUpcoming.hpp b/module-db/queries/calendar/QueryEventsSelectFirstUpcoming.hpp index c95dbe3ea..ab41cfb20 100644 --- a/module-db/queries/calendar/QueryEventsSelectFirstUpcoming.hpp +++ b/module-db/queries/calendar/QueryEventsSelectFirstUpcoming.hpp @@ -14,11 +14,11 @@ namespace db::query::events class SelectFirstUpcoming : public Query { public: - SelectFirstUpcoming(TimePoint filter_from, TimePoint filter_till); + SelectFirstUpcoming(calendar::TimePoint filter_from, calendar::TimePoint filter_till); [[nodiscard]] auto debugInfo() const -> std::string override; - TimePoint filter_from; - TimePoint filter_till; + calendar::TimePoint filter_from; + calendar::TimePoint filter_till; }; /// Result of SelectFirstUpcoming query diff --git a/module-db/tests/AlarmsRecord_tests.cpp b/module-db/tests/AlarmsRecord_tests.cpp index 12b721714..55ebf6da1 100644 --- a/module-db/tests/AlarmsRecord_tests.cpp +++ b/module-db/tests/AlarmsRecord_tests.cpp @@ -184,7 +184,7 @@ TEST_CASE("Alarms Record tests") } auto getQuery = [&](uint32_t id, - TimePoint alarmTime, + calendar::TimePoint alarmTime, uint32_t snooze, AlarmStatus status, uint32_t repeat, diff --git a/module-db/tests/AlarmsTable_tests.cpp b/module-db/tests/AlarmsTable_tests.cpp index 3cbfb9da2..2a053dd37 100644 --- a/module-db/tests/AlarmsTable_tests.cpp +++ b/module-db/tests/AlarmsTable_tests.cpp @@ -139,11 +139,11 @@ TEST_CASE("Alarms Table tests") REQUIRE(alarmsTbl.add( AlarmsTableRow(5, TimePointFromString("2020-12-11 07:15:00"), 1, AlarmStatus::On, 1, "file2.mp3"))); - const std::array paramTime{TimePointFromString("2020-12-11 07:15:00"), - TimePointFromString("2020-11-11 15:10:00"), - TimePointFromString("2020-11-11 15:15:00"), - TimePointFromString("2020-11-12 17:10:00"), - TimePointFromString("2020-11-11 19:25:00")}; + const std::array paramTime{TimePointFromString("2020-12-11 07:15:00"), + TimePointFromString("2020-11-11 15:10:00"), + TimePointFromString("2020-11-11 15:15:00"), + TimePointFromString("2020-11-12 17:10:00"), + TimePointFromString("2020-11-11 19:25:00")}; REQUIRE(alarmsTbl.count() == 5); auto entries = alarmsTbl.getLimitOffset(0, 5); diff --git a/module-db/tests/EventsRecord_tests.cpp b/module-db/tests/EventsRecord_tests.cpp index bbccec296..9ebb658a0 100644 --- a/module-db/tests/EventsRecord_tests.cpp +++ b/module-db/tests/EventsRecord_tests.cpp @@ -24,6 +24,8 @@ #include #include +using namespace std::chrono_literals; + static auto remove_events(EventsDB &db) -> bool { auto count = db.events.count(); @@ -728,7 +730,7 @@ TEST_CASE("Events Record tests") SECTION("Select first upcoming event") { - TimePoint start_date = TimePointFromString("2019-10-19 14:24:00"); + calendar::TimePoint start_date = TimePointFromString("2019-10-19 14:24:00"); auto nextUpcoming = eventsRecordInterface.SelectFirstUpcoming(start_date, start_date); REQUIRE(nextUpcoming.size() == 1); EventsRecord nextEventsRecord = nextUpcoming.at(0); @@ -797,7 +799,9 @@ TEST_CASE("Events Record tests") getAll(expectedRecords, numberOfEvents); } - auto getFiltered = [&](TimePoint filter_from, TimePoint filter_till, std::vector expected_records) { + auto getFiltered = [&](calendar::TimePoint filter_from, + calendar::TimePoint filter_till, + std::vector expected_records) { auto query = std::make_shared(filter_from, filter_till); auto ret = eventsRecordInterface.runQuery(query); auto result = dynamic_cast(ret.get()); @@ -1009,7 +1013,8 @@ TEST_CASE("Events Record tests") EditQueryICS(testRecord6.UID, testRecord6); } - [[maybe_unused]] auto selectFirstUpcomingEvent = [&](TimePoint filter_from, TimePoint filter_till) { + [[maybe_unused]] auto selectFirstUpcomingEvent = [&](calendar::TimePoint filter_from, + calendar::TimePoint filter_till) { auto query = std::make_shared(filter_from, filter_till); auto ret = eventsRecordInterface.runQuery(query); auto result = dynamic_cast(ret.get()); diff --git a/module-db/tests/EventsTable_tests.cpp b/module-db/tests/EventsTable_tests.cpp index 4f0f9bfc3..bec99eb1f 100644 --- a/module-db/tests/EventsTable_tests.cpp +++ b/module-db/tests/EventsTable_tests.cpp @@ -15,6 +15,8 @@ #include #include +using namespace std::chrono_literals; + static auto remove_events(EventsDB &db) -> bool { auto count = db.events.count(); @@ -164,8 +166,8 @@ TEST_CASE("Events Table tests") CHECK(eventsTbl.count() == 0); uint32_t numberOfEvents = 7; - TimePoint startDate = TimePointFromString("2019-10-20 14:30:00"); - TimePoint endDate = TimePointFromString("2019-10-20 15:30:00"); + calendar::TimePoint startDate = TimePointFromString("2019-10-20 14:30:00"); + calendar::TimePoint endDate = TimePointFromString("2019-10-20 15:30:00"); testRow1.date_from = startDate; testRow1.date_till = endDate; CHECK(eventsTbl.addDaily(testRow1)); @@ -199,8 +201,8 @@ TEST_CASE("Events Table tests") CHECK(eventsTbl.count() == 0); uint32_t numberOfEvents = 4; - TimePoint startDate = TimePointFromString("2019-10-20 14:30:00"); - TimePoint endDate = TimePointFromString("2019-10-20 15:30:00"); + calendar::TimePoint startDate = TimePointFromString("2019-10-20 14:30:00"); + calendar::TimePoint endDate = TimePointFromString("2019-10-20 15:30:00"); testRow1.date_from = startDate; testRow1.date_till = endDate; CHECK(eventsTbl.addWeekly(testRow1)); @@ -234,8 +236,8 @@ TEST_CASE("Events Table tests") CHECK(eventsTbl.count() == 0); uint32_t numberOfEvents = 4; - TimePoint startDate = TimePointFromString("2019-10-20 14:30:00"); - TimePoint endDate = TimePointFromString("2019-10-20 15:30:00"); + calendar::TimePoint startDate = TimePointFromString("2019-10-20 14:30:00"); + calendar::TimePoint endDate = TimePointFromString("2019-10-20 15:30:00"); testRow1.date_from = startDate; testRow1.date_till = endDate; CHECK(eventsTbl.addTwoWeeks(testRow1)); @@ -269,7 +271,7 @@ TEST_CASE("Events Table tests") CHECK(eventsTbl.count() == 0); uint32_t numberOfEvents = 12; - const std::array dates{ + const std::array dates{ TimePointFromString("2019-01-20 14:30:00"), TimePointFromString("2019-01-20 15:30:00"), TimePointFromString("2019-02-20 14:30:00"), TimePointFromString("2019-02-20 15:30:00"), TimePointFromString("2019-03-20 14:30:00"), TimePointFromString("2019-03-20 15:30:00"), @@ -316,14 +318,14 @@ TEST_CASE("Events Table tests") REQUIRE(eventsTbl.count() == 0); uint32_t numberOfEvents = 4; - std::array dates{TimePointFromString("2019-02-20 14:30:00"), - TimePointFromString("2019-02-20 15:30:00"), - TimePointFromString("2020-02-20 14:30:00"), - TimePointFromString("2020-02-20 15:30:00"), - TimePointFromString("2021-02-20 14:30:00"), - TimePointFromString("2021-02-20 15:30:00"), - TimePointFromString("2022-02-20 14:30:00"), - TimePointFromString("2022-02-20 15:30:00")}; + std::array dates{TimePointFromString("2019-02-20 14:30:00"), + TimePointFromString("2019-02-20 15:30:00"), + TimePointFromString("2020-02-20 14:30:00"), + TimePointFromString("2020-02-20 15:30:00"), + TimePointFromString("2021-02-20 14:30:00"), + TimePointFromString("2021-02-20 15:30:00"), + TimePointFromString("2022-02-20 14:30:00"), + TimePointFromString("2022-02-20 15:30:00")}; testRow1.date_from = dates[0]; testRow1.date_till = dates[1]; @@ -365,8 +367,8 @@ TEST_CASE("Events Table tests") { auto check_custom_repeat = [&](uint32_t customRepeatOption, uint32_t numberOfEvents, - TimePoint originalStartDate, - TimePoint originalEndDate) { + calendar::TimePoint originalStartDate, + calendar::TimePoint originalEndDate) { if (eventsTbl.count() > 0) { REQUIRE(remove_events(eventsDb)); } @@ -394,8 +396,8 @@ TEST_CASE("Events Table tests") } } - TimePoint expectedStartDate = TimePointFromString("2020-12-07 14:30:00"); // monday - TimePoint expectedEndDate = TimePointFromString("2020-12-07 15:30:00"); // monday + calendar::TimePoint expectedStartDate = TimePointFromString("2020-12-07 14:30:00"); // monday + calendar::TimePoint expectedEndDate = TimePointFromString("2020-12-07 15:30:00"); // monday uint32_t i = 0; for (uint32_t l = 0; l < numberOfWeeks; l++) { @@ -437,8 +439,8 @@ TEST_CASE("Events Table tests") uint32_t customRepeatOption = static_cast(weekDayOption::monday) + static_cast(weekDayOption::wednesday); uint32_t numberOfEvents = 9; - TimePoint originalStartDate = TimePointFromString("2020-12-10 14:30:00"); // thursday - TimePoint originalEndDate = TimePointFromString("2020-12-10 15:30:00"); // thursday + calendar::TimePoint originalStartDate = TimePointFromString("2020-12-10 14:30:00"); // thursday + calendar::TimePoint originalEndDate = TimePointFromString("2020-12-10 15:30:00"); // thursday check_custom_repeat(customRepeatOption, numberOfEvents, originalStartDate, originalEndDate); } @@ -449,8 +451,8 @@ TEST_CASE("Events Table tests") static_cast(weekDayOption::monday) + static_cast(weekDayOption::wednesday) + static_cast(weekDayOption::tuesday) + static_cast(weekDayOption::sunday); uint32_t numberOfEvents = 17; - TimePoint originalStartDate = TimePointFromString("2020-12-10 14:30:00"); // thursday - TimePoint originalEndDate = TimePointFromString("2020-12-10 15:30:00"); // thursday + calendar::TimePoint originalStartDate = TimePointFromString("2020-12-10 14:30:00"); // thursday + calendar::TimePoint originalEndDate = TimePointFromString("2020-12-10 15:30:00"); // thursday check_custom_repeat(customRepeatOption, numberOfEvents, originalStartDate, originalEndDate); } @@ -459,8 +461,8 @@ TEST_CASE("Events Table tests") { uint32_t customRepeatOption = static_cast(weekDayOption::saturday); uint32_t numberOfEvents = 5; - TimePoint originalStartDate = TimePointFromString("2020-12-10 14:30:00"); // thursday - TimePoint originalEndDate = TimePointFromString("2020-12-10 15:30:00"); // thursday + calendar::TimePoint originalStartDate = TimePointFromString("2020-12-10 14:30:00"); // thursday + calendar::TimePoint originalEndDate = TimePointFromString("2020-12-10 15:30:00"); // thursday check_custom_repeat(customRepeatOption, numberOfEvents, originalStartDate, originalEndDate); } @@ -468,8 +470,8 @@ TEST_CASE("Events Table tests") SECTION("Check count from filter") { - TimePoint from = TimePointFromString("2019-10-20 14:30:00"); - TimePoint till = TimePointFromString("2019-10-24 14:20:00"); + calendar::TimePoint from = TimePointFromString("2019-10-20 14:30:00"); + calendar::TimePoint till = TimePointFromString("2019-10-24 14:20:00"); CHECK(eventsTbl.countFromFilter(from, till) == 4); } @@ -514,8 +516,8 @@ TEST_CASE("Events Table tests") CHECK(eventsTbl.count() == 6); std::string newTitle = "Updated Title", newProviderID = "PurePhoneUpdated"; - TimePoint newDateFrom = TimePointFromString("2020-10-20 15:00:00"), - newDateTill = TimePointFromString("2020-10-20 16:00:00"); + calendar::TimePoint newDateFrom = TimePointFromString("2020-10-20 15:00:00"), + newDateTill = TimePointFromString("2020-10-20 16:00:00"); uint32_t newReminder = static_cast(Reminder::one_week_before); uint32_t newRepeatOption = static_cast(Repeat::biweekly); @@ -570,8 +572,8 @@ TEST_CASE("Events Table tests") std::string newTitle = "Updated Title", newProviderType = "PurePhoneUpdate", newProviderID = "newID", newProvideriCalUid = "new iCalUid"; - TimePoint newDateFrom = TimePointFromString("2020-10-20 15:00:00"), - newDateTill = TimePointFromString("2020-10-20 16:00:00"); + calendar::TimePoint newDateFrom = TimePointFromString("2020-10-20 15:00:00"), + newDateTill = TimePointFromString("2020-10-20 16:00:00"); uint32_t newReminder = static_cast(Reminder::one_week_before); uint32_t newRepeatOption = static_cast(Repeat::biweekly); @@ -628,8 +630,8 @@ TEST_CASE("Events Table tests") std::string newTitle = "Updated Title", newProviderType = "PurePhoneUpdate", newProviderID = "newID", newProvideriCalUid = "new iCalUid"; - TimePoint newDateFrom = TimePointFromString("2020-10-20 15:00:00"), - newDateTill = TimePointFromString("2020-10-20 16:00:00"); + calendar::TimePoint newDateFrom = TimePointFromString("2020-10-20 15:00:00"), + newDateTill = TimePointFromString("2020-10-20 16:00:00"); uint32_t newReminder = static_cast(Reminder::one_week_before); uint32_t newRepeatOption = static_cast(Repeat::biweekly); @@ -727,11 +729,11 @@ TEST_CASE("Events Table tests") } CHECK(eventsTbl.count() == 0); - TimePoint startDate1 = TimePointFromString("2018-10-20 14:24:00"); - TimePoint startDate2 = TimePointFromString("2020-10-20 14:24:00"); + calendar::TimePoint startDate1 = TimePointFromString("2018-10-20 14:24:00"); + calendar::TimePoint startDate2 = TimePointFromString("2020-10-20 14:24:00"); - TimePoint tillDate = TimePointFromString("2030-10-20 15:24:00"); - TimePoint firedDate = TimePointFromString("2018-10-20 14:24:00"); + calendar::TimePoint tillDate = TimePointFromString("2030-10-20 15:24:00"); + calendar::TimePoint firedDate = TimePointFromString("2018-10-20 14:24:00"); EventsTableRow testEvent1 = {{1}, .UID = "test1", diff --git a/module-db/tests/QueryInterface.cpp b/module-db/tests/QueryInterface.cpp index 8c2c1bc14..7a5634194 100644 --- a/module-db/tests/QueryInterface.cpp +++ b/module-db/tests/QueryInterface.cpp @@ -75,9 +75,9 @@ TEST_CASE("Query interface") auto msgJson = json11::Json::parse(testMessage, err); REQUIRE(err.empty()); - Context context(msgJson); + parserFSM::Context context(msgJson); auto listener = std::make_unique( - [=](db::QueryResult *result, Context &context) { + [=](db::QueryResult *result, parserFSM::Context &context) { if (auto SMSResult = dynamic_cast(result)) { auto id = SMSResult->getResults(); auto body = json11::Json::object{{"count", static_cast(id)}}; diff --git a/module-services/service-cellular/CellularRequestHandler.cpp b/module-services/service-cellular/CellularRequestHandler.cpp index dba5104ea..b5ae0f84b 100644 --- a/module-services/service-cellular/CellularRequestHandler.cpp +++ b/module-services/service-cellular/CellularRequestHandler.cpp @@ -22,6 +22,8 @@ #include +using namespace cellular; + void CellularRequestHandler::handle(ImeiRequest &request, at::Result &result) { if (!request.checkModemResponse(result)) { diff --git a/module-services/service-cellular/CellularUrcHandler.cpp b/module-services/service-cellular/CellularUrcHandler.cpp index ff3ba475b..e629ed743 100644 --- a/module-services/service-cellular/CellularUrcHandler.cpp +++ b/module-services/service-cellular/CellularUrcHandler.cpp @@ -11,6 +11,8 @@ #include #include +using namespace at::urc; + // this static function will be replaced by Settings API static bool isSettingsAutomaticTimeSyncEnabled() { diff --git a/module-services/service-cellular/CellularUrcHandler.hpp b/module-services/service-cellular/CellularUrcHandler.hpp index c2beb9541..13e9c9c38 100644 --- a/module-services/service-cellular/CellularUrcHandler.hpp +++ b/module-services/service-cellular/CellularUrcHandler.hpp @@ -18,27 +18,25 @@ #include #include -using namespace at::urc; - /** * ServiceCellular helper for handling Urc messages */ -class CellularUrcHandler : public UrcHandler +class CellularUrcHandler : public at::urc::UrcHandler { public: CellularUrcHandler(ServiceCellular &cellularService) : cellularService(cellularService) {} - void Handle(Clip &urc) final; - void Handle(Creg &urc) final; - void Handle(Cmti &urc) final; - void Handle(Cusd &urc) final; - void Handle(Ctze &urc) final; - void Handle(Qind &urc) final; - void Handle(Cpin &urc) final; - void Handle(Qiurc &urc) final; - void Handle(PoweredDown &urc) final; - void Handle(UrcResponse &urc) final; + void Handle(at::urc::Clip &urc) final; + void Handle(at::urc::Creg &urc) final; + void Handle(at::urc::Cmti &urc) final; + void Handle(at::urc::Cusd &urc) final; + void Handle(at::urc::Ctze &urc) final; + void Handle(at::urc::Qind &urc) final; + void Handle(at::urc::Cpin &urc) final; + void Handle(at::urc::Qiurc &urc) final; + void Handle(at::urc::PoweredDown &urc) final; + void Handle(at::urc::UrcResponse &urc) final; /** * Gets the response that should be returned after handling Urc diff --git a/module-services/service-cellular/service-cellular/CellularRequestHandler.hpp b/module-services/service-cellular/service-cellular/CellularRequestHandler.hpp index cf7d387be..a14653b1c 100644 --- a/module-services/service-cellular/service-cellular/CellularRequestHandler.hpp +++ b/module-services/service-cellular/service-cellular/CellularRequestHandler.hpp @@ -6,21 +6,19 @@ #include "RequestHandler.hpp" #include "service-cellular/ServiceCellular.hpp" -using namespace cellular; - -class CellularRequestHandler : public RequestHandler +class CellularRequestHandler : public cellular::RequestHandler { public: CellularRequestHandler(ServiceCellular &serviceCellular) : cellular(serviceCellular) {} - void handle(ImeiRequest &request, at::Result &result) final; - void handle(UssdRequest &request, at::Result &result) final; - void handle(CallRequest &request, at::Result &result) final; - void handle(PasswordRegistrationRequest &request, at::Result &result) final; - void handle(SupplementaryServicesRequest &request, at::Result &result) final; - void handle(PinChangeRequest &request, at::Result &result) final; - void handle(ClirRequest &request, at::Result &result) final; + void handle(cellular::ImeiRequest &request, at::Result &result) final; + void handle(cellular::UssdRequest &request, at::Result &result) final; + void handle(cellular::CallRequest &request, at::Result &result) final; + void handle(cellular::PasswordRegistrationRequest &request, at::Result &result) final; + void handle(cellular::SupplementaryServicesRequest &request, at::Result &result) final; + void handle(cellular::PinChangeRequest &request, at::Result &result) final; + void handle(cellular::ClirRequest &request, at::Result &result) final; private: ServiceCellular &cellular; diff --git a/module-services/service-desktop/DesktopMessages.cpp b/module-services/service-desktop/DesktopMessages.cpp index e7671357e..e8832206c 100644 --- a/module-services/service-desktop/DesktopMessages.cpp +++ b/module-services/service-desktop/DesktopMessages.cpp @@ -6,6 +6,7 @@ namespace sdesktop::developerMode { + using namespace parserFSM; void Event::send() { MessageHandler::putToSendQueue(context.createSimpleResponse()); diff --git a/module-services/service-desktop/endpoints/EndpointFactory.hpp b/module-services/service-desktop/endpoints/EndpointFactory.hpp index a6e93db78..58aba098c 100644 --- a/module-services/service-desktop/endpoints/EndpointFactory.hpp +++ b/module-services/service-desktop/endpoints/EndpointFactory.hpp @@ -19,36 +19,35 @@ #include "restore/RestoreEndpoint.hpp" #include "update/UpdateEndpoint.hpp" -using namespace parserFSM; - class EndpointFactory { public: - static auto create(Context &context, sys::Service *ownerServicePtr) -> std::unique_ptr + static auto create(parserFSM::Context &context, sys::Service *ownerServicePtr) + -> std::unique_ptr { LOG_DEBUG("Creating endpoint: %d", static_cast(context.getEndpoint())); switch (context.getEndpoint()) { - case EndpointType::update: + case parserFSM::EndpointType::update: return std::make_unique(ownerServicePtr); - case EndpointType::filesystemUpload: + case parserFSM::EndpointType::filesystemUpload: return std::make_unique(ownerServicePtr); - case EndpointType::backup: + case parserFSM::EndpointType::backup: return std::make_unique(ownerServicePtr); - case EndpointType::deviceInfo: + case parserFSM::EndpointType::deviceInfo: return std::make_unique(ownerServicePtr); - case EndpointType::restore: + case parserFSM::EndpointType::restore: return std::make_unique(ownerServicePtr); - case EndpointType::contacts: + case parserFSM::EndpointType::contacts: return std::make_unique(ownerServicePtr); - case EndpointType::messages: + case parserFSM::EndpointType::messages: return std::make_unique(ownerServicePtr); - case EndpointType::factory: + case parserFSM::EndpointType::factory: return std::make_unique(ownerServicePtr); - case EndpointType::calllog: + case parserFSM::EndpointType::calllog: return std::make_unique(ownerServicePtr); - case EndpointType::developerMode: + case parserFSM::EndpointType::developerMode: return std::make_unique(ownerServicePtr); - case EndpointType::calendarEvents: + case parserFSM::EndpointType::calendarEvents: return std::make_unique(ownerServicePtr); default: return nullptr; diff --git a/module-services/service-desktop/endpoints/backup/BackupEndpoint.cpp b/module-services/service-desktop/endpoints/backup/BackupEndpoint.cpp index 71d4936c5..e5fd80b8a 100644 --- a/module-services/service-desktop/endpoints/backup/BackupEndpoint.cpp +++ b/module-services/service-desktop/endpoints/backup/BackupEndpoint.cpp @@ -18,6 +18,8 @@ static bool backupReady = false; +using namespace parserFSM; + auto BackupEndpoint::handle(Context &context) -> void { switch (context.getMethod()) { diff --git a/module-services/service-desktop/endpoints/backup/BackupEndpoint.hpp b/module-services/service-desktop/endpoints/backup/BackupEndpoint.hpp index 35c834995..25ae94b89 100644 --- a/module-services/service-desktop/endpoints/backup/BackupEndpoint.hpp +++ b/module-services/service-desktop/endpoints/backup/BackupEndpoint.hpp @@ -20,16 +20,14 @@ namespace sys class Service; } // namespace sys -using namespace parserFSM; - -class BackupEndpoint : public Endpoint +class BackupEndpoint : public parserFSM::Endpoint { public: BackupEndpoint(sys::Service *ownerServicePtr) : Endpoint(ownerServicePtr) { debugName = "BackupEndpoint"; } - auto handle(Context &context) -> void override; - auto request(Context &context) -> sys::ReturnCodes; - auto upload(Context &context) -> sys::ReturnCodes; + auto handle(parserFSM::Context &context) -> void override; + auto request(parserFSM::Context &context) -> sys::ReturnCodes; + auto upload(parserFSM::Context &context) -> sys::ReturnCodes; }; diff --git a/module-services/service-desktop/endpoints/calendarEvents/CalendarEventsEndpoint.hpp b/module-services/service-desktop/endpoints/calendarEvents/CalendarEventsEndpoint.hpp index f0bd26f68..778f4a055 100644 --- a/module-services/service-desktop/endpoints/calendarEvents/CalendarEventsEndpoint.hpp +++ b/module-services/service-desktop/endpoints/calendarEvents/CalendarEventsEndpoint.hpp @@ -7,18 +7,16 @@ #include "Service/Service.hpp" #include "CalendarEventsHelper.hpp" -using namespace parserFSM; - -class CalendarEventsEndpoint : public Endpoint +class CalendarEventsEndpoint : public parserFSM::Endpoint { private: std::string debugName = "CalendarEventsEndpoint"; - std::unique_ptr helper; + std::unique_ptr helper; public: CalendarEventsEndpoint(sys::Service *_ownerServicePtr) : Endpoint(_ownerServicePtr) { - helper = std::make_unique(ownerServicePtr); + helper = std::make_unique(ownerServicePtr); } - void handle(Context &context) override; + void handle(parserFSM::Context &context) override; }; diff --git a/module-services/service-desktop/endpoints/calllog/CalllogEndpoint.hpp b/module-services/service-desktop/endpoints/calllog/CalllogEndpoint.hpp index 87412f26f..b3a78730d 100644 --- a/module-services/service-desktop/endpoints/calllog/CalllogEndpoint.hpp +++ b/module-services/service-desktop/endpoints/calllog/CalllogEndpoint.hpp @@ -20,18 +20,16 @@ namespace sys class Service; } // namespace sys -using namespace parserFSM; - -class CalllogEndpoint : public Endpoint +class CalllogEndpoint : public parserFSM::Endpoint { private: - std::unique_ptr helper; + std::unique_ptr helper; public: CalllogEndpoint(sys::Service *_ownerServicePtr) : Endpoint(_ownerServicePtr) { debugName = "CalllogEndpoint"; - helper = std::make_unique(ownerServicePtr); + helper = std::make_unique(ownerServicePtr); } - auto handle(Context &context) -> void override; + auto handle(parserFSM::Context &context) -> void override; }; diff --git a/module-services/service-desktop/endpoints/contacts/ContactsEndpoint.hpp b/module-services/service-desktop/endpoints/contacts/ContactsEndpoint.hpp index 5eebf9dda..c6630079e 100644 --- a/module-services/service-desktop/endpoints/contacts/ContactsEndpoint.hpp +++ b/module-services/service-desktop/endpoints/contacts/ContactsEndpoint.hpp @@ -22,18 +22,16 @@ namespace sys class Service; } // namespace sys -using namespace parserFSM; - -class ContactsEndpoint : public Endpoint +class ContactsEndpoint : public parserFSM::Endpoint { private: - std::unique_ptr helper; + std::unique_ptr helper; public: ContactsEndpoint(sys::Service *_ownerServicePtr) : Endpoint(_ownerServicePtr) { debugName = "ContactsEndpoint"; - helper = std::make_unique(ownerServicePtr); + helper = std::make_unique(ownerServicePtr); } - auto handle(Context &context) -> void override; + auto handle(parserFSM::Context &context) -> void override; }; diff --git a/module-services/service-desktop/endpoints/developerMode/DeveloperModeEndpoint.hpp b/module-services/service-desktop/endpoints/developerMode/DeveloperModeEndpoint.hpp index 32d93f69f..9fe43d931 100644 --- a/module-services/service-desktop/endpoints/developerMode/DeveloperModeEndpoint.hpp +++ b/module-services/service-desktop/endpoints/developerMode/DeveloperModeEndpoint.hpp @@ -21,18 +21,16 @@ namespace sys class Service; } // namespace sys -using namespace parserFSM; - -class DeveloperModeEndpoint : public Endpoint +class DeveloperModeEndpoint : public parserFSM::Endpoint { private: - std::unique_ptr helper; + std::unique_ptr helper; public: DeveloperModeEndpoint(sys::Service *_ownerServicePtr) : Endpoint(_ownerServicePtr) { debugName = "DeveloperModeEndpoint"; - helper = std::make_unique(ownerServicePtr); + helper = std::make_unique(ownerServicePtr); } - auto handle(Context &context) -> void override; + auto handle(parserFSM::Context &context) -> void override; }; diff --git a/module-services/service-desktop/endpoints/deviceInfo/DeviceInfoEndpoint.cpp b/module-services/service-desktop/endpoints/deviceInfo/DeviceInfoEndpoint.cpp index 0289b113b..6220717b1 100644 --- a/module-services/service-desktop/endpoints/deviceInfo/DeviceInfoEndpoint.cpp +++ b/module-services/service-desktop/endpoints/deviceInfo/DeviceInfoEndpoint.cpp @@ -13,6 +13,8 @@ #include #include +using namespace parserFSM; + auto DeviceInfoEndpoint::handle(Context &context) -> void { switch (context.getMethod()) { diff --git a/module-services/service-desktop/endpoints/deviceInfo/DeviceInfoEndpoint.hpp b/module-services/service-desktop/endpoints/deviceInfo/DeviceInfoEndpoint.hpp index a89b2b7d2..9159c555c 100644 --- a/module-services/service-desktop/endpoints/deviceInfo/DeviceInfoEndpoint.hpp +++ b/module-services/service-desktop/endpoints/deviceInfo/DeviceInfoEndpoint.hpp @@ -19,9 +19,7 @@ namespace sys class Service; } // namespace sys -using namespace parserFSM; - -class DeviceInfoEndpoint : public Endpoint +class DeviceInfoEndpoint : public parserFSM::Endpoint { public: @@ -29,6 +27,6 @@ class DeviceInfoEndpoint : public Endpoint { debugName = "DeviceInfoEndpoint"; } - auto handle(Context &context) -> void override; - auto getDeviceInfo(Context &context) -> bool; + auto handle(parserFSM::Context &context) -> void override; + auto getDeviceInfo(parserFSM::Context &context) -> bool; }; diff --git a/module-services/service-desktop/endpoints/factoryReset/FactoryResetEndpoint.cpp b/module-services/service-desktop/endpoints/factoryReset/FactoryResetEndpoint.cpp index 1848bf451..38455921b 100644 --- a/module-services/service-desktop/endpoints/factoryReset/FactoryResetEndpoint.cpp +++ b/module-services/service-desktop/endpoints/factoryReset/FactoryResetEndpoint.cpp @@ -13,7 +13,7 @@ #include -auto FactoryResetEndpoint::handle(Context &context) -> void +auto FactoryResetEndpoint::handle(parserFSM::Context &context) -> void { if (context.getMethod() == parserFSM::http::Method::post) { @@ -27,14 +27,14 @@ auto FactoryResetEndpoint::handle(Context &context) -> void context.setResponseBody(json11::Json::object({{parserFSM::json::factoryRequest, false}})); } - MessageHandler::putToSendQueue(context.createSimpleResponse()); + parserFSM::MessageHandler::putToSendQueue(context.createSimpleResponse()); return; } else { context.setResponseBody(json11::Json::object({{parserFSM::json::factoryRequest, false}})); - MessageHandler::putToSendQueue(context.createSimpleResponse()); + parserFSM::MessageHandler::putToSendQueue(context.createSimpleResponse()); return; } diff --git a/module-services/service-desktop/endpoints/factoryReset/FactoryResetEndpoint.hpp b/module-services/service-desktop/endpoints/factoryReset/FactoryResetEndpoint.hpp index cfe854607..e01ba9503 100644 --- a/module-services/service-desktop/endpoints/factoryReset/FactoryResetEndpoint.hpp +++ b/module-services/service-desktop/endpoints/factoryReset/FactoryResetEndpoint.hpp @@ -19,9 +19,7 @@ namespace sys class Service; } // namespace sys -using namespace parserFSM; - -class FactoryResetEndpoint : public Endpoint +class FactoryResetEndpoint : public parserFSM::Endpoint { public: @@ -29,6 +27,6 @@ class FactoryResetEndpoint : public Endpoint { debugName = "FactoryResetEndpoint"; } - auto handle(Context &context) -> void override; - auto makeFactoryReset(Context &context) -> bool; + auto handle(parserFSM::Context &context) -> void override; + auto makeFactoryReset(parserFSM::Context &context) -> bool; }; diff --git a/module-services/service-desktop/endpoints/filesystem/FilesystemEndpoint.cpp b/module-services/service-desktop/endpoints/filesystem/FilesystemEndpoint.cpp index e33df861f..888266d35 100644 --- a/module-services/service-desktop/endpoints/filesystem/FilesystemEndpoint.cpp +++ b/module-services/service-desktop/endpoints/filesystem/FilesystemEndpoint.cpp @@ -6,6 +6,8 @@ #include "service-desktop/ServiceDesktop.hpp" #include +using namespace parserFSM; + auto FilesystemEndpoint::handle(Context &context) -> void { LOG_DEBUG("handle"); @@ -68,4 +70,4 @@ auto FilesystemEndpoint::run(Context &context) -> sys::ReturnCodes MessageHandler::putToSendQueue(context.createSimpleResponse()); return returnCode; -} \ No newline at end of file +} diff --git a/module-services/service-desktop/endpoints/filesystem/FilesystemEndpoint.hpp b/module-services/service-desktop/endpoints/filesystem/FilesystemEndpoint.hpp index 97381db1c..b972d1ba4 100644 --- a/module-services/service-desktop/endpoints/filesystem/FilesystemEndpoint.hpp +++ b/module-services/service-desktop/endpoints/filesystem/FilesystemEndpoint.hpp @@ -6,14 +6,12 @@ #include #include "Service/Service.hpp" -using namespace parserFSM; - -class FilesystemEndpoint : public Endpoint +class FilesystemEndpoint : public parserFSM::Endpoint { public: FilesystemEndpoint(sys::Service *ownerServicePtr) : Endpoint(ownerServicePtr) {} - auto handle(Context &context) -> void override; - auto run(Context &context) -> sys::ReturnCodes; - auto getUpdates(Context &context) -> sys::ReturnCodes; + auto handle(parserFSM::Context &context) -> void override; + auto run(parserFSM::Context &context) -> sys::ReturnCodes; + auto getUpdates(parserFSM::Context &context) -> sys::ReturnCodes; }; diff --git a/module-services/service-desktop/endpoints/messages/MessagesEndpoint.hpp b/module-services/service-desktop/endpoints/messages/MessagesEndpoint.hpp index f4fa97760..bb2a220d1 100644 --- a/module-services/service-desktop/endpoints/messages/MessagesEndpoint.hpp +++ b/module-services/service-desktop/endpoints/messages/MessagesEndpoint.hpp @@ -21,18 +21,16 @@ namespace sys class Service; } // namespace sys -using namespace parserFSM; - -class MessagesEndpoint : public Endpoint +class MessagesEndpoint : public parserFSM::Endpoint { private: - std::shared_ptr helper; + std::shared_ptr helper; public: MessagesEndpoint(sys::Service *_ownerServicePtr) : Endpoint(_ownerServicePtr) { debugName = "MessagesEndpoint"; - helper = std::make_shared(ownerServicePtr); + helper = std::make_shared(ownerServicePtr); } - auto handle(Context &context) -> void override; + auto handle(parserFSM::Context &context) -> void override; }; diff --git a/module-services/service-desktop/endpoints/restore/RestoreEndpoint.cpp b/module-services/service-desktop/endpoints/restore/RestoreEndpoint.cpp index 01ecc8102..0cf1fb1a1 100644 --- a/module-services/service-desktop/endpoints/restore/RestoreEndpoint.cpp +++ b/module-services/service-desktop/endpoints/restore/RestoreEndpoint.cpp @@ -14,6 +14,8 @@ #include +using namespace parserFSM; + auto RestoreEndpoint::handle(Context &context) -> void { if (context.getMethod() == parserFSM::http::Method::post) { diff --git a/module-services/service-desktop/endpoints/restore/RestoreEndpoint.hpp b/module-services/service-desktop/endpoints/restore/RestoreEndpoint.hpp index 82e38f42a..61c5afc96 100644 --- a/module-services/service-desktop/endpoints/restore/RestoreEndpoint.hpp +++ b/module-services/service-desktop/endpoints/restore/RestoreEndpoint.hpp @@ -16,14 +16,12 @@ namespace sys class Service; } // namespace sys -using namespace parserFSM; - -class RestoreEndpoint : public Endpoint +class RestoreEndpoint : public parserFSM::Endpoint { public: RestoreEndpoint(sys::Service *ownerServicePtr) : Endpoint(ownerServicePtr) { debugName = "RestoreEndpoint"; } - auto handle(Context &context) -> void override; + auto handle(parserFSM::Context &context) -> void override; }; diff --git a/module-services/service-desktop/endpoints/update/UpdateEndpoint.cpp b/module-services/service-desktop/endpoints/update/UpdateEndpoint.cpp index 8868a9c13..0b5ba5f39 100644 --- a/module-services/service-desktop/endpoints/update/UpdateEndpoint.cpp +++ b/module-services/service-desktop/endpoints/update/UpdateEndpoint.cpp @@ -17,6 +17,8 @@ #include #include +using namespace parserFSM; + auto UpdateEndpoint::handle(Context &context) -> void { switch (context.getMethod()) { diff --git a/module-services/service-desktop/endpoints/update/UpdateEndpoint.hpp b/module-services/service-desktop/endpoints/update/UpdateEndpoint.hpp index 5319be921..1e3972fa3 100644 --- a/module-services/service-desktop/endpoints/update/UpdateEndpoint.hpp +++ b/module-services/service-desktop/endpoints/update/UpdateEndpoint.hpp @@ -20,9 +20,7 @@ namespace sys class Service; } // namespace sys -using namespace parserFSM; - -class UpdateEndpoint : public Endpoint +class UpdateEndpoint : public parserFSM::Endpoint { public: @@ -30,7 +28,7 @@ class UpdateEndpoint : public Endpoint { debugName = "UpdateEndpoint"; } - auto handle(Context &context) -> void override; - auto run(Context &context) -> sys::ReturnCodes; - auto getUpdates(Context &context) -> sys::ReturnCodes; + auto handle(parserFSM::Context &context) -> void override; + auto run(parserFSM::Context &context) -> sys::ReturnCodes; + auto getUpdates(parserFSM::Context &context) -> sys::ReturnCodes; }; diff --git a/module-services/service-desktop/service-desktop/DesktopMessages.hpp b/module-services/service-desktop/service-desktop/DesktopMessages.hpp index 54340a13f..3ef7a9bb2 100644 --- a/module-services/service-desktop/service-desktop/DesktopMessages.hpp +++ b/module-services/service-desktop/service-desktop/DesktopMessages.hpp @@ -71,7 +71,7 @@ namespace sdesktop class Event { protected: - Context context; + parserFSM::Context context; public: void send(); diff --git a/module-services/service-fota/FotaUrcHandler.cpp b/module-services/service-fota/FotaUrcHandler.cpp index 5ad157273..0c6991450 100644 --- a/module-services/service-fota/FotaUrcHandler.cpp +++ b/module-services/service-fota/FotaUrcHandler.cpp @@ -3,6 +3,8 @@ #include "FotaUrcHandler.hpp" +using namespace at::urc; + void FotaUrcHandler::Handle(Qind &urc) { if (urc.isFotaValid()) { diff --git a/module-services/service-fota/FotaUrcHandler.hpp b/module-services/service-fota/FotaUrcHandler.hpp index 3f96f81d3..65a24bd73 100644 --- a/module-services/service-fota/FotaUrcHandler.hpp +++ b/module-services/service-fota/FotaUrcHandler.hpp @@ -8,27 +8,25 @@ #include #include -using namespace at::urc; - /** * ServiceFota helper for handling Urc messages */ -class FotaUrcHandler : public UrcHandler +class FotaUrcHandler : public at::urc::UrcHandler { public: FotaUrcHandler(FotaService::Service &fotaService) : fotaService(fotaService) {} - void Handle(Qind &urc) final; - virtual void Handle(Clip &urc){}; - virtual void Handle(Creg &urc){}; - virtual void Handle(Cmti &urc){}; - virtual void Handle(Cusd &urc){}; - virtual void Handle(Ctze &urc){}; - virtual void Handle(Cpin &urc){}; - virtual void Handle(Qiurc &urc){}; - virtual void Handle(PoweredDown &urc){}; - virtual void Handle(UrcResponse &urc){}; + void Handle(at::urc::Qind &urc) final; + virtual void Handle(at::urc::Clip &urc){}; + virtual void Handle(at::urc::Creg &urc){}; + virtual void Handle(at::urc::Cmti &urc){}; + virtual void Handle(at::urc::Cusd &urc){}; + virtual void Handle(at::urc::Ctze &urc){}; + virtual void Handle(at::urc::Cpin &urc){}; + virtual void Handle(at::urc::Qiurc &urc){}; + virtual void Handle(at::urc::PoweredDown &urc){}; + virtual void Handle(at::urc::UrcResponse &urc){}; private: FotaService::Service &fotaService; diff --git a/module-services/service-time/service-time/CalendarTimeEvents.hpp b/module-services/service-time/service-time/CalendarTimeEvents.hpp index 35e7f26ea..0ac0374cb 100644 --- a/module-services/service-time/service-time/CalendarTimeEvents.hpp +++ b/module-services/service-time/service-time/CalendarTimeEvents.hpp @@ -27,7 +27,7 @@ namespace stm { private: EventsRecord eventRecord; - TimePoint startTP = TIME_POINT_INVALID; + calendar::TimePoint startTP = TIME_POINT_INVALID; protected: const std::string timerName() override diff --git a/module-services/service-time/timeEvents/CalendarTimeEvents.cpp b/module-services/service-time/timeEvents/CalendarTimeEvents.cpp index 88292d363..9fcaa8450 100644 --- a/module-services/service-time/timeEvents/CalendarTimeEvents.cpp +++ b/module-services/service-time/timeEvents/CalendarTimeEvents.cpp @@ -29,6 +29,7 @@ namespace sys namespace stm { + using namespace std::chrono_literals; constexpr static auto eventTimerMinSkipInterval = 100ms; CalendarTimeEvents::CalendarTimeEvents(sys::Service *service) : TimeEvents(service) @@ -36,8 +37,8 @@ namespace stm bool CalendarTimeEvents::sendNextEventQuery() { - TimePoint filterFrom = TimePointNow(); - TimePoint filterTill = filterFrom; + calendar::TimePoint filterFrom = TimePointNow(); + calendar::TimePoint filterTill = filterFrom; if (startTP != TIME_POINT_INVALID) { filterFrom = std::min(startTP, filterFrom); filterTill = filterFrom; @@ -64,7 +65,7 @@ namespace stm } eventRecord = records.at(0); - startTP = eventRecord.date_from - minutes{eventRecord.reminder}; + startTP = eventRecord.date_from - std::chrono::minutes{eventRecord.reminder}; auto duration = eventRecord.date_from - std::chrono::minutes{eventRecord.reminder} - TimePointNow(); if (duration.count() <= 0) { duration = std::chrono::milliseconds(eventTimerMinSkipInterval); diff --git a/module-sys/SystemManager/SystemManager.cpp b/module-sys/SystemManager/SystemManager.cpp index c37f90bb6..56322019d 100644 --- a/module-sys/SystemManager/SystemManager.cpp +++ b/module-sys/SystemManager/SystemManager.cpp @@ -116,7 +116,7 @@ namespace sys // pingPongTimerID = CreateTimer(Ticks::MsToTicks(pingInterval), true); // ReloadTimer(pingPongTimerID); - cpuStatisticsTimer = std::make_unique("cpuStatistics", this, timerInitInterval.count()); + cpuStatisticsTimer = std::make_unique("cpuStatistics", this, constants::timerInitInterval.count()); cpuStatisticsTimer->connect([&](sys::Timer &) { CpuStatisticsTimerHandler(); }); cpuStatisticsTimer->start(); } @@ -354,7 +354,7 @@ namespace sys { if (!cpuStatisticsTimerInit) { cpuStatisticsTimerInit = true; - cpuStatisticsTimer->setInterval(timerPeriodInterval.count()); + cpuStatisticsTimer->setInterval(constants::timerPeriodInterval.count()); } cpuStatistics->Update(); diff --git a/module-sys/SystemManager/SystemManager.hpp b/module-sys/SystemManager/SystemManager.hpp index a5a48b369..f15777d15 100644 --- a/module-sys/SystemManager/SystemManager.hpp +++ b/module-sys/SystemManager/SystemManager.hpp @@ -26,9 +26,12 @@ namespace sys { - using namespace std::chrono_literals; - inline constexpr std::chrono::milliseconds timerInitInterval{30s}; - inline constexpr std::chrono::milliseconds timerPeriodInterval{100ms}; + namespace constants + { + using namespace std::chrono_literals; + inline constexpr std::chrono::milliseconds timerInitInterval{30s}; + inline constexpr std::chrono::milliseconds timerPeriodInterval{100ms}; + } // namespace constants enum class Code { diff --git a/module-utils/ical/ParserICS.cpp b/module-utils/ical/ParserICS.cpp index 54bfe3d13..d28f535ca 100644 --- a/module-utils/ical/ParserICS.cpp +++ b/module-utils/ical/ParserICS.cpp @@ -446,7 +446,7 @@ auto Event::timeStringFrom(const std::string &icalTime) const -> std::string getSecondsFromIcalTime(icalTime); } -auto Event::TimePointFromIcalDate(const std::string &icalDateTime) const -> TimePoint +auto Event::TimePointFromIcalDate(const std::string &icalDateTime) const -> calendar::TimePoint { std::string icalDate(getDateFromIcalFormat(icalDateTime)); std::string icalTime(getTimeFromIcalFormat(icalDateTime)); @@ -459,7 +459,7 @@ auto Event::TimePointFromIcalDate(const std::string &icalDateTime) const -> Time return TimePointFromString(dateTime.c_str()); } -auto Event::TimePointToIcalDate(const TimePoint &tp) const -> std::string +auto Event::TimePointToIcalDate(const calendar::TimePoint &tp) const -> std::string { constexpr uint32_t bufferLimit = 16; auto time = TimePointToTimeT(tp); @@ -541,7 +541,10 @@ auto Event::validateUID(const std::string &UID) -> bool return validateDT(DTimestamp); } -Event::Event(const std::string &summary, const TimePoint from, TimePoint till, const std::string &uid) +Event::Event(const std::string &summary, + const calendar::TimePoint from, + calendar::TimePoint till, + const std::string &uid) { if (summary.empty()) { isValid = false; @@ -595,12 +598,12 @@ auto Event::getSummary() const -> std::string return summary; } -auto Event::getDTStartTimePoint() const -> TimePoint +auto Event::getDTStartTimePoint() const -> calendar::TimePoint { return dtstart; } -auto Event::getDTEndTimePoint() const -> TimePoint +auto Event::getDTEndTimePoint() const -> calendar::TimePoint { return dtend; } diff --git a/module-utils/ical/ParserICS.hpp b/module-utils/ical/ParserICS.hpp index 0397fa4fe..ddcd8a5f7 100644 --- a/module-utils/ical/ParserICS.hpp +++ b/module-utils/ical/ParserICS.hpp @@ -91,8 +91,8 @@ class Event { std::string uid; std::string summary; - TimePoint dtstart; - TimePoint dtend; + calendar::TimePoint dtstart; + calendar::TimePoint dtend; auto isDate(const std::string &dt) -> bool; auto isTime(const std::string &dt) -> bool; @@ -112,13 +112,13 @@ class Event [[nodiscard]] auto dateStringFrom(const std::string &icalDate) const -> std::string; [[nodiscard]] auto timeStringFrom(const std::string &icalTime) const -> std::string; - [[nodiscard]] auto TimePointFromIcalDate(const std::string &icalDateTime) const -> TimePoint; - [[nodiscard]] auto TimePointToIcalDate(const TimePoint &tp) const -> std::string; + [[nodiscard]] auto TimePointFromIcalDate(const std::string &icalDateTime) const -> calendar::TimePoint; + [[nodiscard]] auto TimePointToIcalDate(const calendar::TimePoint &tp) const -> std::string; public: bool isValid = true; Event() = default; - Event(const std::string &summary, TimePoint from, TimePoint till, const std::string &uid); + Event(const std::string &summary, calendar::TimePoint from, calendar::TimePoint till, const std::string &uid); void setUID(const std::string &property); void setSummary(const std::string &property); @@ -127,8 +127,8 @@ class Event [[nodiscard]] auto getUID() const -> std::string; [[nodiscard]] auto getSummary() const -> std::string; - [[nodiscard]] auto getDTStartTimePoint() const -> TimePoint; - [[nodiscard]] auto getDTEndTimePoint() const -> TimePoint; + [[nodiscard]] auto getDTStartTimePoint() const -> calendar::TimePoint; + [[nodiscard]] auto getDTEndTimePoint() const -> calendar::TimePoint; [[nodiscard]] auto getDTStartString() const -> std::string; [[nodiscard]] auto getDTEndString() const -> std::string; diff --git a/module-utils/time/TimeRangeParser.cpp b/module-utils/time/TimeRangeParser.cpp index 867a15078..e8db6dd13 100644 --- a/module-utils/time/TimeRangeParser.cpp +++ b/module-utils/time/TimeRangeParser.cpp @@ -19,8 +19,8 @@ namespace utils::time return utils::localize.get(utils::time::Locale::getPM()); } - std::string TimeRangeParser::getCalendarTimeString(TimePoint startDate, - TimePoint endDate, + std::string TimeRangeParser::getCalendarTimeString(calendar::TimePoint startDate, + calendar::TimePoint endDate, Version version, bool isMode24H) { diff --git a/module-utils/time/TimeRangeParser.hpp b/module-utils/time/TimeRangeParser.hpp index 9a24aa247..8e43b696a 100644 --- a/module-utils/time/TimeRangeParser.hpp +++ b/module-utils/time/TimeRangeParser.hpp @@ -20,8 +20,8 @@ namespace utils::time std::string AMPMtoString(bool isAm); public: - std::string getCalendarTimeString(TimePoint startDate, - TimePoint endDate, + std::string getCalendarTimeString(calendar::TimePoint startDate, + calendar::TimePoint endDate, Version version = Version::normal, bool isMode24H = false); };