M module-apps/application-alarm-clock/ApplicationAlarmClock.cpp => module-apps/application-alarm-clock/ApplicationAlarmClock.cpp +2 -2
@@ 11,8 11,8 @@
#include "windows/Dialog.hpp"
#include "windows/AppWindow.hpp"
#include "windows/OptionWindow.hpp"
-#include <module-services/service-db/service-db/DBNotificationMessage.hpp>
-#include <module-services/service-db/service-db/QueryMessage.hpp>
+#include <service-db/DBNotificationMessage.hpp>
+#include <service-db/QueryMessage.hpp>
namespace app
{
M module-apps/application-alarm-clock/windows/AlarmClockMainWindow.cpp => module-apps/application-alarm-clock/windows/AlarmClockMainWindow.cpp +1 -1
@@ 9,7 9,7 @@
#include <InputEvent.hpp>
#include <header/AddElementAction.hpp>
#include <service-appmgr/Controller.hpp>
-#include <module-services/service-db/service-db/DBNotificationMessage.hpp>
+#include <service-db/DBNotificationMessage.hpp>
namespace app::alarmClock
{
M module-apps/application-call/ApplicationCall.cpp => module-apps/application-call/ApplicationCall.cpp +0 -1
@@ 12,7 12,6 @@
#include <apps-common/windows/DialogMetadata.hpp>
#include <log/log.hpp>
#include <module-apps/application-phonebook/data/PhonebookItemData.hpp>
-#include <module-services/service-db/service-db/DBServiceAPI.hpp>
#include <module-sys/Timers/TimerFactory.hpp>
#include <PhoneNumber.hpp>
#include <service-appmgr/Controller.hpp>
M module-apps/application-calllog/windows/CallLogMainWindow.cpp => module-apps/application-calllog/windows/CallLogMainWindow.cpp +1 -1
@@ 16,7 16,7 @@
#include <cassert>
#include <functional>
#include <memory>
-#include <module-services/service-db/service-db/DBNotificationMessage.hpp>
+#include <service-db/DBNotificationMessage.hpp>
using namespace style;
using namespace callLogStyle;
M module-apps/application-calllog/windows/CallLogOptionsWindow.cpp => module-apps/application-calllog/windows/CallLogOptionsWindow.cpp +0 -1
@@ 3,7 3,6 @@
#include "CallLogOptionsWindow.hpp"
#include <i18n/i18n.hpp>
-#include <module-services/service-db/service-db/DBServiceAPI.hpp>
#include <OptionContact.hpp>
/// below just for apps names...
M module-apps/application-desktop/ApplicationDesktop.cpp => module-apps/application-desktop/ApplicationDesktop.cpp +0 -1
@@ 20,7 20,6 @@
#include <messages/DialogMetadataMessage.hpp>
#include <MessageType.hpp>
#include <module-gui/gui/widgets/status-bar/SIM.hpp>
-#include <module-services/service-db/agents/settings/SystemSettings.hpp>
#include <module-services/service-desktop/service-desktop/Constants.hpp>
#include <popups/presenter/PowerOffPresenter.hpp>
#include <popups/TetheringOffPopup.hpp>
M module-apps/application-messages/windows/OptionsMessages.cpp => module-apps/application-messages/windows/OptionsMessages.cpp +0 -1
@@ 7,7 7,6 @@
#include <apps-common/options/type/OptionContact.hpp>
#include <Clipboard.hpp>
#include <i18n/i18n.hpp>
-#include <module-services/service-db/service-db/DBServiceAPI.hpp>
#include <Option.hpp>
#include <OptionsMessages.hpp>
#include <Text.hpp>
M module-apps/application-messages/windows/ThreadWindowOptions.cpp => module-apps/application-messages/windows/ThreadWindowOptions.cpp +0 -1
@@ 5,7 5,6 @@
#include <i18n/i18n.hpp>
#include <log.hpp>
-#include <module-services/service-db/service-db/DBServiceAPI.hpp>
#include <OptionCall.hpp>
#include <OptionContact.hpp>
#include <OptionWindow.hpp>
M module-apps/application-notes/presenter/NotesSearchResultPresenter.hpp => module-apps/application-notes/presenter/NotesSearchResultPresenter.hpp +1 -1
@@ 6,7 6,7 @@
#include <apps-common/BasePresenter.hpp>
#include <module-apps/application-notes/model/NotesSearchListModel.hpp>
-#include <module-services/service-db/service-db/DBNotificationMessage.hpp>
+#include <service-db/DBNotificationMessage.hpp>
namespace app::notes
{
M module-apps/application-notes/windows/NoteMainWindow.cpp => module-apps/application-notes/windows/NoteMainWindow.cpp +1 -1
@@ 15,7 15,7 @@
#include <header/SearchAction.hpp>
#include <module-apps/application-notes/style/NotesListStyle.hpp>
-#include <module-services/service-db/service-db/DBNotificationMessage.hpp>
+#include <service-db/DBNotificationMessage.hpp>
namespace app::notes
{
M module-apps/application-onboarding/ApplicationOnBoarding.cpp => module-apps/application-onboarding/ApplicationOnBoarding.cpp +1 -1
@@ 18,9 18,9 @@
#include <application-settings/windows/system/ChangeTimeZone.hpp>
#include <apps-common/locks/data/PhoneLockMessages.hpp>
-#include <module-services/service-db/agents/settings/SystemSettings.hpp>
#include <service-appmgr/Constants.hpp>
#include <service-appmgr/messages/GetCurrentDisplayLanguageResponse.hpp>
+#include <service-db/agents/settings/SystemSettings.hpp>
namespace app
{
M module-apps/application-settings/data/QuoteSwitchData.hpp => module-apps/application-settings/data/QuoteSwitchData.hpp +1 -1
@@ 4,7 4,7 @@
#pragma once
#include <gui/SwitchData.hpp>
-#include <service-db/service-db/QuotesMessages.hpp>
+#include <service-db/QuotesMessages.hpp>
namespace Quotes
{
M module-apps/apps-common/Application.cpp => module-apps/apps-common/Application.cpp +1 -1
@@ 36,7 36,7 @@
#include <WindowsFactory.hpp>
#include <service-gui/Common.hpp>
#include <module-utils/Utils.hpp>
-#include <service-db/service-db/Settings.hpp>
+#include <service-db/Settings.hpp>
#include <service-db/agents/settings/SystemSettings.hpp>
#include <service-audio/AudioServiceAPI.hpp> // for GetOutputVolume
M module-apps/apps-common/locks/handlers/PhoneLockHandler.cpp => module-apps/apps-common/locks/handlers/PhoneLockHandler.cpp +1 -1
@@ 9,7 9,7 @@
#include <memory>
#include <apps-common/popups/data/PopupRequestParams.hpp>
-#include <module-services/service-db/agents/settings/SystemSettings.hpp>
+#include <service-db/agents/settings/SystemSettings.hpp>
namespace locks
{
M module-apps/apps-common/locks/handlers/PhoneLockHandler.hpp => module-apps/apps-common/locks/handlers/PhoneLockHandler.hpp +1 -1
@@ 7,7 7,7 @@
#include <locks/data/PhoneLockMessages.hpp>
#include <locks/data/LockData.hpp>
-#include <service-db/service-db/Settings.hpp>
+#include <service-db/Settings.hpp>
#include <module-sys/Service/Service.hpp>
namespace locks
M module-apps/apps-common/notifications/NotificationsConfiguration.cpp => module-apps/apps-common/notifications/NotificationsConfiguration.cpp +1 -1
@@ 3,7 3,7 @@
#include "NotificationsConfiguration.hpp"
#include <Utils.hpp>
-#include <agents/settings/SystemSettings.hpp>
+#include <service-db/agents/settings/SystemSettings.hpp>
using namespace notifications;
M module-db/Common/Query.hpp => module-db/Common/Query.hpp +0 -3
@@ 3,10 3,7 @@
#pragma once
-#include <memory>
-#include <string>
#include <functional>
-#include <log.hpp>
#include <module-services/service-desktop/endpoints/Context.hpp>
namespace db
M module-services/service-appmgr/model/ApplicationManagerCommon.cpp => module-services/service-appmgr/model/ApplicationManagerCommon.cpp +1 -1
@@ 28,7 28,7 @@
#include <log/log.hpp>
#include <module-db/queries/notifications/QueryNotificationsGetAll.hpp>
#include <service-audio/AudioMessage.hpp>
-#include <module-services/service-db/agents/settings/SystemSettings.hpp>
+#include <service-db/agents/settings/SystemSettings.hpp>
#include <module-sys/Timers/TimerFactory.hpp>
#include <module-utils/Utils.hpp>
#include <service-appmgr/Constants.hpp>
M module-services/service-bluetooth/service-bluetooth/SettingsHolder.cpp => module-services/service-bluetooth/service-bluetooth/SettingsHolder.cpp +3 -0
@@ 2,6 2,9 @@
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#include "SettingsHolder.hpp"
+
+#include <service-db/agents/settings/SystemSettings.hpp>
+
namespace bluetooth
{
std::map<Settings, std::string> SettingsHolder::settingString{
M module-services/service-bluetooth/service-bluetooth/SettingsHolder.hpp => module-services/service-bluetooth/service-bluetooth/SettingsHolder.hpp +0 -1
@@ 5,7 5,6 @@
#include <string>
#include <variant>
#include <service-db/Settings.hpp>
-#include <agents/settings/SystemSettings.hpp>
#include <module-utils/Utils.hpp>
#include "SettingsSerializer.hpp"
M module-services/service-cellular/ServiceCellular.cpp => module-services/service-cellular/ServiceCellular.cpp +1 -0
@@ 65,6 65,7 @@
#include <service-antenna/ServiceAntenna.hpp>
#include <service-appmgr/Constants.hpp>
#include <service-appmgr/Controller.hpp>
+#include <service-db/agents/settings/SystemSettings.hpp>
#include <service-db/DBServiceAPI.hpp>
#include <service-db/DBNotificationMessage.hpp>
#include <service-db/QueryMessage.hpp>
M module-services/service-cellular/service-cellular/ServiceCellular.hpp => module-services/service-cellular/service-cellular/ServiceCellular.hpp +0 -1
@@ 24,7 24,6 @@
#include <bsp/common.hpp>
#include <utf8/UTF8.hpp>
#include <service-db/Settings.hpp>
-#include <module-services/service-db/agents/settings/SystemSettings.hpp>
#include <module-sys/PhoneModes/Observer.hpp>
#include <service-db/DBServiceName.hpp>
#include <service-db/DBNotificationMessage.hpp>
M module-services/service-db/CMakeLists.txt => module-services/service-db/CMakeLists.txt +4 -2
@@ 6,7 6,7 @@ set(SOURCES
DBServiceAPI.cpp
DBServiceAPI_GetByQuery.cpp
DatabaseAgent.cpp
- ServiceDB.cpp
+ ServiceDBCommon.cpp
EntryPath.cpp
messages/DBCalllogMessage.cpp
messages/DBContactMessage.cpp
@@ 25,8 25,10 @@ set(SOURCES
add_library(${PROJECT_NAME} STATIC ${SOURCES})
target_include_directories(${PROJECT_NAME}
+ PRIVATE
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/agents>
PUBLIC
- ${CMAKE_CURRENT_LIST_DIR}
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
)
target_link_libraries(${PROJECT_NAME}
A module-services/service-db/ServiceDBCommon.cpp => module-services/service-db/ServiceDBCommon.cpp +79 -0
@@ 0,0 1,79 @@
+// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
+// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+
+#include <service-db/DBNotificationMessage.hpp>
+#include <service-db/DBServiceName.hpp>
+#include <service-db/ServiceDBCommon.hpp>
+#include <service-db/agents/quotes/QuotesAgent.cpp>
+
+static const auto service_db_stack = 1024 * 24;
+
+ServiceDBCommon::ServiceDBCommon() : sys::Service(service::name::db, "", service_db_stack, sys::ServicePriority::Idle)
+{
+ LOG_INFO("[ServiceDB] Initializing");
+}
+
+db::Interface *ServiceDBCommon::getInterface(db::Interface::Name interface)
+{
+ return nullptr;
+}
+
+// Invoked upon receiving data message
+sys::MessagePointer ServiceDBCommon::DataReceivedHandler(sys::DataMessage *msgl, sys::ResponseMessage *resp)
+{
+ std::shared_ptr<sys::ResponseMessage> responseMsg;
+ auto type = static_cast<MessageType>(msgl->messageType);
+ switch (type) {
+ case MessageType::DBQuery: {
+ auto msg = dynamic_cast<db::QueryMessage *>(msgl);
+ assert(msg);
+ db::Interface *interface = getInterface(msg->getInterface());
+ assert(interface != nullptr);
+ auto query = msg->getQuery();
+ auto queryType = query->type;
+ auto result = interface->runQuery(std::move(query));
+ responseMsg = std::make_shared<db::QueryResponse>(std::move(result));
+ sendUpdateNotification(msg->getInterface(), queryType);
+ } break;
+
+ default:
+ break;
+ }
+
+ if (responseMsg == nullptr) {
+ return responseMsg;
+ }
+
+ responseMsg->responseTo = msgl->messageType;
+ return responseMsg;
+}
+
+sys::ReturnCodes ServiceDBCommon::InitHandler()
+{
+ if (const auto isSuccess = Database::initialize(); !isSuccess) {
+ return sys::ReturnCodes::Failure;
+ }
+ return sys::ReturnCodes::Success;
+}
+
+sys::ReturnCodes ServiceDBCommon::DeinitHandler()
+{
+ return sys::ReturnCodes::Success;
+}
+
+void ServiceDBCommon::ProcessCloseReason(sys::CloseReason closeReason)
+{
+ sendCloseReadyMessage(this);
+}
+
+sys::ReturnCodes ServiceDBCommon::SwitchPowerModeHandler(const sys::ServicePowerMode mode)
+{
+ LOG_FATAL("[%s] PowerModeHandler: %s", this->GetName().c_str(), c_str(mode));
+ return sys::ReturnCodes::Success;
+}
+
+void ServiceDBCommon::sendUpdateNotification(db::Interface::Name interface, db::Query::Type type)
+{
+ auto notificationMessage = std::make_shared<db::NotificationMessage>(interface, type);
+ bus.sendMulticast(notificationMessage, sys::BusChannel::ServiceDBNotifications);
+}
M module-services/service-db/agents/settings/FactorySettings.cpp => module-services/service-db/agents/settings/FactorySettings.cpp +3 -0
@@ 3,6 3,9 @@
#include "FactorySettings.hpp"
+#include <log.hpp>
+#include <service-db/SettingsMessages.hpp>
+
namespace settings
{
M module-services/service-db/agents/settings/FactorySettings.hpp => module-services/service-db/agents/settings/FactorySettings.hpp +0 -1
@@ 7,7 7,6 @@
#include <purefs/filesystem_paths.hpp>
#include <json11.hpp>
#include <fstream>
-#include <module-services/service-db/service-db/SettingsMessages.hpp>
#include "Settings_queries.hpp"
namespace settings
M module-services/service-db/agents/settings/Settings_queries.hpp => module-services/service-db/agents/settings/Settings_queries.hpp +0 -2
@@ 3,8 3,6 @@
#pragma once
-#include <log.hpp>
-
namespace settings::Statements
{
constexpr auto getValue = R"sql(
R module-services/service-db/service-db/DBCalllogMessage.hpp => module-services/service-db/include/service-db/DBCalllogMessage.hpp +0 -0
R module-services/service-db/service-db/DBContactMessage.hpp => module-services/service-db/include/service-db/DBContactMessage.hpp +0 -0
R module-services/service-db/service-db/DBMessage.hpp => module-services/service-db/include/service-db/DBMessage.hpp +0 -0
R module-services/service-db/service-db/DBNotificationMessage.hpp => module-services/service-db/include/service-db/DBNotificationMessage.hpp +0 -0
R module-services/service-db/service-db/DBServiceAPI.hpp => module-services/service-db/include/service-db/DBServiceAPI.hpp +0 -0
R module-services/service-db/service-db/DBServiceMessage.hpp => module-services/service-db/include/service-db/DBServiceMessage.hpp +0 -0
R module-services/service-db/service-db/DBServiceName.hpp => module-services/service-db/include/service-db/DBServiceName.hpp +0 -0
R module-services/service-db/service-db/DBSettingsMessage.hpp => module-services/service-db/include/service-db/DBSettingsMessage.hpp +0 -0
R module-services/service-db/service-db/DatabaseAgent.hpp => module-services/service-db/include/service-db/DatabaseAgent.hpp +0 -0
R module-services/service-db/service-db/EntryPath.hpp => module-services/service-db/include/service-db/EntryPath.hpp +0 -0
R module-services/service-db/service-db/FileIndexerMessages.hpp => module-services/service-db/include/service-db/FileIndexerMessages.hpp +2 -2
@@ 14,8 14,8 @@
namespace FileIndexer
{
- constexpr unsigned int FILE_ID_NOT_EXISTS = 0;
- constexpr unsigned int FILE_RECORD_COLUMN_COUNT = 7;
+ constexpr unsigned int FILE_ID_NOT_EXISTS = 0;
+ constexpr unsigned int FILE_RECORD_COLUMN_COUNT = 7;
constexpr unsigned int NOTIFICATION_RECORD_COLUMN_COUNT = 3;
// refers to file_tab
R module-services/service-db/service-db/PagedData.hpp => module-services/service-db/include/service-db/PagedData.hpp +1 -1
@@ 22,7 22,7 @@ auto getList(unsigned int offset, unsigned int limit, std::shared_ptr<QueryResul
pagedData->data.clear();
return pagedData;
}
- pagedData->count = query->getRowCount();
+ pagedData->count = query->getRowCount();
// returns all records
if (limit == 0) {
R module-services/service-db/service-db/QueryMessage.hpp => module-services/service-db/include/service-db/QueryMessage.hpp +0 -0
R module-services/service-db/service-db/QuotesMessages.hpp => module-services/service-db/include/service-db/QuotesMessages.hpp +0 -0
A module-services/service-db/include/service-db/ServiceDBCommon.hpp => module-services/service-db/include/service-db/ServiceDBCommon.hpp +32 -0
@@ 0,0 1,32 @@
+// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
+// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+
+#pragma once
+
+#include <module-db/Common/Query.hpp>
+#include <module-db/Interface/BaseInterface.hpp>
+#include <service-db/DatabaseAgent.hpp>
+
+#include <set>
+
+class ServiceDBCommon : public sys::Service
+{
+ protected:
+ virtual db::Interface *getInterface(db::Interface::Name interface);
+ std::set<std::unique_ptr<DatabaseAgent>> databaseAgents;
+
+ public:
+ ServiceDBCommon();
+
+ sys::MessagePointer DataReceivedHandler(sys::DataMessage *msgl, sys::ResponseMessage *resp) override;
+
+ sys::ReturnCodes InitHandler() override;
+
+ sys::ReturnCodes DeinitHandler() override;
+
+ void ProcessCloseReason(sys::CloseReason closeReason) override;
+
+ sys::ReturnCodes SwitchPowerModeHandler(const sys::ServicePowerMode mode) final;
+
+ void sendUpdateNotification(db::Interface::Name interface, db::Query::Type type);
+};
R module-services/service-db/service-db/Settings.hpp => module-services/service-db/include/service-db/Settings.hpp +2 -2
@@ 23,8 23,8 @@ namespace settings
class Settings
{
public:
- using ValueChangedCallback = std::function<void(const std::string &)>;
- using ValueChangedCallbackWithName = std::function<void(const std::string &, const std::string &value)>;
+ using ValueChangedCallback = std::function<void(const std::string &)>;
+ using ValueChangedCallbackWithName = std::function<void(const std::string &, const std::string &value)>;
Settings() = default;
virtual ~Settings();
R module-services/service-db/service-db/SettingsCache.hpp => module-services/service-db/include/service-db/SettingsCache.hpp +0 -0
R module-services/service-db/service-db/SettingsMessages.hpp => module-services/service-db/include/service-db/SettingsMessages.hpp +0 -0
R module-services/service-db/service-db/SettingsProxy.hpp => module-services/service-db/include/service-db/SettingsProxy.hpp +0 -0
R module-services/service-db/service-db/SettingsScope.hpp => module-services/service-db/include/service-db/SettingsScope.hpp +0 -0
M module-services/service-db/test/test-factory-settings.cpp => module-services/service-db/test/test-factory-settings.cpp +2 -1
@@ 2,7 2,8 @@
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#include <catch2/catch.hpp>
-#include <module-services/service-db/agents/settings/FactorySettings.hpp>
+#include <service-db/agents/settings/FactorySettings.hpp>
+#include <service-db/EntryPath.hpp>
const std::string valid_json = "{\"serial\" : \"00000000000000\", \"case_colour\" : \"nocase\"}";
const std::string invalid_json = "{\"serial\" : \"00000000000000\", \"case_colour\" : \"nocase\"}}";
M module-services/service-db/test/test-service-db-file_indexer.cpp => module-services/service-db/test/test-service-db-file_indexer.cpp +2 -2
@@ 6,9 6,9 @@
#include <Service/Service.hpp>
#include <functional>
#include <thread> // for Message_t, ResponseMessage, DataMessage, Message
-#include <service-db/ServiceDB.hpp>
+#include <service-db/ServiceDBCommon.hpp>
-#include <module-services/service-db/test/test-service-db-file_indexer.hpp>
+#include <service-db/test/test-service-db-file_indexer.hpp>
#include <service-db/FileIndexerMessages.hpp>
class ClientService : public sys::Service
M module-services/service-db/test/test-service-db-file_indexer.hpp => module-services/service-db/test/test-service-db-file_indexer.hpp +1 -1
@@ 5,7 5,7 @@
#include <service-db/DatabaseAgent.hpp>
#include <service-db/FileIndexerMessages.hpp>
-#include <module-services/service-db/agents/file_indexer/FileIndexerAgent.hpp>
+#include <service-db/agents/file_indexer/FileIndexerAgent.hpp>
class FileIndexerTest : public FileIndexerAgent
{
M module-services/service-db/test/test-settings-Settings/test-settings-Settings.cpp => module-services/service-db/test/test-settings-Settings/test-settings-Settings.cpp +2 -2
@@ 2,8 2,8 @@
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#include <catch2/catch.hpp>
-#include <module-services/service-db/service-db/Settings.hpp>
-#include "module-services/service-db/service-db/SettingsCache.hpp"
+#include <service-db/Settings.hpp>
+#include <service-db/SettingsCache.hpp>
#include <utility>
/// stub
M module-services/service-desktop/ServiceDesktop.cpp => module-services/service-desktop/ServiceDesktop.cpp +2 -4
@@ 15,7 15,8 @@
#include <json11.hpp>
#include <log.hpp>
#include <application-desktop/Constants.hpp>
-#include <service-db/service-db/Settings.hpp>
+#include <locks/data/PhoneLockMessages.hpp>
+#include <service-appmgr/Constants.hpp>
#include <service-db/QueryMessage.hpp>
#include <service-evtmgr/EventManagerCommon.hpp>
#include <service-evtmgr/EVMessages.hpp>
@@ 23,9 24,6 @@
#include <module-sys/SystemManager/SystemManagerCommon.hpp>
#include <module-sys/Timers/TimerFactory.hpp>
-#include <locks/data/PhoneLockMessages.hpp>
-#include <service-appmgr/Constants.hpp>
-#include <module-services/service-db/agents/settings/SystemSettings.hpp>
#include <module-sys/SystemManager/Constants.hpp>
#include <module-sys/SystemManager/messages/TetheringStateRequest.hpp>
#include <endpoints/bluetooth/BluetoothMessagesHandler.hpp>
M module-services/service-desktop/USBSecurityModel.cpp => module-services/service-desktop/USBSecurityModel.cpp +2 -2
@@ 7,8 7,8 @@
#include "service-desktop/DesktopMessages.hpp"
#include "service-desktop/WorkerDesktop.hpp"
-#include <service-db/service-db/Settings.hpp>
-#include <module-services/service-db/agents/settings/SystemSettings.hpp>
+#include <service-db/Settings.hpp>
+#include <service-db/agents/settings/SystemSettings.hpp>
namespace sdesktop
{
M module-services/service-desktop/endpoints/developerMode/DeveloperModeHelper.cpp => module-services/service-desktop/endpoints/developerMode/DeveloperModeHelper.cpp +1 -0
@@ 20,6 20,7 @@
#include <module-sys/SystemManager/messages/TetheringStateRequest.hpp>
#include <module-sys/SystemManager/Constants.hpp>
+#include <service-db/agents/settings/SystemSettings.hpp>
#include <service-db/DBServiceAPI.hpp>
#include <service-desktop/parser/MessageHandler.hpp>
#include <service-desktop/endpoints/developerMode/event/ATRequest.hpp>
M module-services/service-evtmgr/backlight-handler/BacklightHandler.cpp => module-services/service-evtmgr/backlight-handler/BacklightHandler.cpp +1 -1
@@ 3,7 3,7 @@
#include "BacklightHandler.hpp"
#include <service-db/agents/settings/SystemSettings.hpp>
-#include <service-db/service-db/Settings.hpp>
+#include <service-db/Settings.hpp>
#include <Timers/TimerFactory.hpp>
#include <Utils.hpp>
M module-services/service-evtmgr/battery-level-check/BatteryLevelCheck.cpp => module-services/service-evtmgr/battery-level-check/BatteryLevelCheck.cpp +1 -1
@@ 4,7 4,7 @@
#include "BatteryLevelCheck.hpp"
#include "service-evtmgr/BatteryMessages.hpp"
#include "SystemManager/Constants.hpp"
-#include <agents/settings/SystemSettings.hpp>
+#include <service-db/agents/settings/SystemSettings.hpp>
#include <EventStore.hpp>
#include <Utils.hpp>
M module-services/service-evtmgr/battery-level-check/BatteryLevelCheck.hpp => module-services/service-evtmgr/battery-level-check/BatteryLevelCheck.hpp +1 -1
@@ 4,7 4,7 @@
#pragma once
#include <Service/Service.hpp>
-#include <service-db/service-db/Settings.hpp>
+#include <service-db/Settings.hpp>
namespace sys
{
M module-services/service-time/ServiceTime.cpp => module-services/service-time/ServiceTime.cpp +0 -1
@@ 20,7 20,6 @@
#include <time/time_conversion_factory.hpp>
#include <time/TimeZone.hpp>
#include <service-evtmgr/Constants.hpp>
-#include <service-db/service-db/Settings.hpp>
#include <service-db/agents/settings/SystemSettings.hpp>
#include <memory>
M products/BellHybrid/BellHybridMain.cpp => products/BellHybrid/BellHybridMain.cpp +1 -1
@@ 10,13 10,13 @@
// services
#include <appmgr/ApplicationManager.hpp>
+#include <db/ServiceDB.hpp>
#include <evtmgr/EventManager.hpp>
#include <module-services/service-eink/ServiceEink.hpp>
#include <Service/ServiceCreator.hpp>
#include <service-appmgr/Constants.hpp>
#include <service-audio/ServiceAudio.hpp>
#include <service-bluetooth/ServiceBluetooth.hpp>
-#include <service-db/ServiceDB.hpp>
#include <service-desktop/ServiceDesktop.hpp>
#include <service-fileindexer/Constants.hpp>
#include <service-gui/ServiceGUI.hpp>
M products/BellHybrid/CMakeLists.txt => products/BellHybrid/CMakeLists.txt +1 -0
@@ 41,6 41,7 @@ target_link_libraries(BellHybrid
application-bell-settings
application-music-player
appmgr
+ db
evtmgr
messagetype
module-apps
M products/BellHybrid/services/CMakeLists.txt => products/BellHybrid/services/CMakeLists.txt +2 -1
@@ 1,2 1,3 @@
-add_subdirectory(evtmgr)
add_subdirectory(appmgr)
+add_subdirectory(evtmgr)
+add_subdirectory(db)
A products/BellHybrid/services/db/CMakeLists.txt => products/BellHybrid/services/db/CMakeLists.txt +19 -0
@@ 0,0 1,19 @@
+add_library(db STATIC)
+
+target_sources(db
+ PRIVATE
+ ServiceDB.cpp
+ PUBLIC
+ include/db/ServiceDB.hpp
+)
+
+target_include_directories(db
+ PUBLIC
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
+)
+
+target_link_libraries(db
+ PRIVATE
+ module-utils
+ service-db
+)
A products/BellHybrid/services/db/ServiceDB.cpp => products/BellHybrid/services/db/ServiceDB.cpp +4 -0
@@ 0,0 1,4 @@
+// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
+// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+
+#include <db/ServiceDB.hpp>
A products/BellHybrid/services/db/include/db/ServiceDB.hpp => products/BellHybrid/services/db/include/db/ServiceDB.hpp +27 -0
@@ 0,0 1,27 @@
+// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
+// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+
+#pragma once
+
+#include <service-db/DBServiceName.hpp>
+#include <service-db/ServiceDBCommon.hpp>
+
+class ServiceDB : public ServiceDBCommon
+{};
+
+namespace sys
+{
+ template <> struct ManifestTraits<ServiceDB>
+ {
+ static auto GetManifest() -> ServiceManifest
+ {
+ ServiceManifest manifest;
+ manifest.name = service::name::db;
+#if ENABLE_FILEINDEXER_SERVICE
+ manifest.dependencies = {service::name::file_indexer.data()};
+#endif
+ manifest.timeout = std::chrono::minutes{1};
+ return manifest;
+ }
+ };
+} // namespace sys
M products/PurePhone/CMakeLists.txt => products/PurePhone/CMakeLists.txt +1 -0
@@ 56,6 56,7 @@ target_link_libraries(PurePhone
application-settings
application-special-input
appmgr
+ db
evtmgr
messagetype
module-apps
M products/PurePhone/PurePhoneMain.cpp => products/PurePhone/PurePhoneMain.cpp +12 -1
@@ 21,13 21,24 @@
#include <application-alarm-clock/ApplicationAlarmClock.hpp>
#include <application-onboarding/ApplicationOnBoarding.hpp>
+// modules
+#include <module-db/Databases/AlarmsDB.hpp>
+#include <module-db/Databases/CountryCodesDB.hpp>
+#include <module-db/Databases/EventsDB.hpp>
+#include <module-db/Databases/NotificationsDB.hpp>
+#include <module-db/Interface/AlarmEventRecord.hpp>
+#include <module-db/Interface/AlarmsRecord.hpp>
+#include <module-db/Interface/CountryCodeRecord.hpp>
+#include <module-db/Interface/NotificationsRecord.hpp>
+
// services
#include <appmgr/ApplicationManager.hpp>
+#include <db/ServiceDB.hpp>
#include <evtmgr/EventManager.hpp>
#include <service-appmgr/Constants.hpp>
#include <service-audio/ServiceAudio.hpp>
#include <service-bluetooth/ServiceBluetooth.hpp>
-#include <service-db/ServiceDB.hpp>
+#include <service-db/agents/quotes/QuotesAgent.hpp>
#include <service-lwip/ServiceLwIP.hpp>
#include <service-time/ServiceTime.hpp>
#include <Service/ServiceCreator.hpp>
M products/PurePhone/services/CMakeLists.txt => products/PurePhone/services/CMakeLists.txt +2 -1
@@ 1,2 1,3 @@
-add_subdirectory(evtmgr)
add_subdirectory(appmgr)
+add_subdirectory(evtmgr)
+add_subdirectory(db)
M products/PurePhone/services/appmgr/ApplicationManager.cpp => products/PurePhone/services/appmgr/ApplicationManager.cpp +1 -1
@@ 16,7 16,7 @@
#include <service-appmgr/messages/GetAllNotificationsRequest.hpp>
#include <service-cellular/service-cellular/CellularMessage.hpp>
#include <service-db/agents/settings/SystemSettings.hpp>
-#include <service-db/service-db/DBNotificationMessage.hpp>
+#include <service-db/DBNotificationMessage.hpp>
#include <service-desktop/Constants.hpp>
#include <service-desktop/DesktopMessages.hpp>
#include <service-desktop/DeveloperModeMessage.hpp>
A products/PurePhone/services/db/CMakeLists.txt => products/PurePhone/services/db/CMakeLists.txt +19 -0
@@ 0,0 1,19 @@
+add_library(db STATIC)
+
+target_sources(db
+ PRIVATE
+ ServiceDB.cpp
+ PUBLIC
+ include/db/ServiceDB.hpp
+)
+
+target_include_directories(db
+ PUBLIC
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
+)
+
+target_link_libraries(db
+ PRIVATE
+ module-db
+ service-db
+)
R module-services/service-db/ServiceDB.cpp => products/PurePhone/services/db/ServiceDB.cpp +40 -85
@@ 1,54 1,30 @@
-// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
+// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
-#include "ServiceDB.hpp"
-
-#include "service-db/DBCalllogMessage.hpp"
-#include "service-db/DBContactMessage.hpp"
-#include "service-db/DBNotificationMessage.hpp"
-#include "service-db/DBServiceMessage.hpp"
-#include "service-db/QueryMessage.hpp"
-#include "service-db/DatabaseAgent.hpp"
-#include "agents/quotes/QuotesAgent.cpp"
-#include "agents/settings/SettingsAgent.hpp"
-
-#include <AlarmsRecord.hpp>
-#include <CalllogRecord.hpp>
-#include <ContactRecord.hpp>
-#include <CountryCodeRecord.hpp>
-#include <Database/Database.hpp>
-#include <Databases/AlarmsDB.hpp>
-#include <Databases/CalllogDB.hpp>
-#include <Databases/ContactsDB.hpp>
-#include <Databases/CountryCodesDB.hpp>
-#include <Databases/EventsDB.hpp>
-#include <Databases/NotesDB.hpp>
-#include <Databases/NotificationsDB.hpp>
-#include <Databases/SmsDB.hpp>
-#include <MessageType.hpp>
-#include <NotesRecord.hpp>
-#include <NotificationsRecord.hpp>
+#include <db/ServiceDB.hpp>
+
+#include <module-db/Databases/AlarmsDB.hpp>
+#include <module-db/Databases/CountryCodesDB.hpp>
+#include <module-db/Databases/EventsDB.hpp>
+#include <module-db/Databases/NotificationsDB.hpp>
+#include <module-db/Databases/NotificationsDB.hpp>
+#include <module-db/Interface/AlarmEventRecord.hpp>
+#include <module-db/Interface/AlarmsRecord.hpp>
+#include <module-db/Interface/CalllogRecord.hpp>
+#include <module-db/Interface/CountryCodeRecord.hpp>
+#include <module-db/Interface/NotesRecord.hpp>
+#include <module-db/Interface/NotificationsRecord.hpp>
+#include <module-db/Interface/SMSRecord.hpp>
+#include <module-db/Interface/SMSTemplateRecord.hpp>
#include <purefs/filesystem_paths.hpp>
-#include <SMSRecord.hpp>
-#include <SMSTemplateRecord.hpp>
-#include <Tables/Record.hpp>
-#include <ThreadRecord.hpp>
-#include <log.hpp>
+#include <service-db/DBCalllogMessage.hpp>
+#include <service-db/DBContactMessage.hpp>
+#include <service-db/DBServiceMessage.hpp>
+#include <service-db/QueryMessage.hpp>
+#include <service-db/agents/file_indexer/FileIndexerAgent.hpp>
+#include <service-db/agents/settings/SettingsAgent.hpp>
#include <time/ScopedTime.hpp>
-
-#include <cassert>
-#include <cinttypes>
-#include <cstdint>
-#include <optional>
-#include <utility>
-#include <vector>
-
-static const auto service_db_stack = 1024 * 24;
-
-ServiceDB::ServiceDB() : sys::Service(service::name::db, "", service_db_stack, sys::ServicePriority::Idle)
-{
- LOG_INFO("[ServiceDB] Initializing");
-}
+#include <service-db/agents/quotes/QuotesAgent.hpp>
ServiceDB::~ServiceDB()
{
@@ 94,11 70,12 @@ db::Interface *ServiceDB::getInterface(db::Interface::Name interface)
return nullptr;
}
-// Invoked upon receiving data message
sys::MessagePointer ServiceDB::DataReceivedHandler(sys::DataMessage *msgl, sys::ResponseMessage *resp)
{
-
- std::shared_ptr<sys::ResponseMessage> responseMsg;
+ auto responseMsg = std::static_pointer_cast<sys::ResponseMessage>(ServiceDBCommon::DataReceivedHandler(msgl, resp));
+ if (!responseMsg) {
+ return responseMsg;
+ }
auto type = static_cast<MessageType>(msgl->messageType);
switch (type) {
@@ 118,7 95,7 @@ sys::MessagePointer ServiceDB::DataReceivedHandler(sys::DataMessage *msgl, sys::
auto time = utils::time::Scoped("DBContactGetByID");
DBContactMessage *msg = reinterpret_cast<DBContactMessage *>(msgl);
auto ret = (msg->withTemporary ? contactRecordInterface->GetByIdWithTemporary(msg->record.ID)
- : contactRecordInterface->GetByID(msg->record.ID));
+ : contactRecordInterface->GetByID(msg->record.ID));
auto records = std::make_unique<std::vector<ContactRecord>>();
records->push_back(ret);
responseMsg = std::make_shared<DBContactResponseMessage>(
@@ 238,8 215,8 @@ sys::MessagePointer ServiceDB::DataReceivedHandler(sys::DataMessage *msgl, sys::
sys::ReturnCodes ServiceDB::InitHandler()
{
- if (const auto isSuccess = Database::initialize(); !isSuccess) {
- return sys::ReturnCodes::Failure;
+ if (const auto returnCode = ServiceDBCommon::InitHandler(); returnCode != sys::ReturnCodes::Success) {
+ return returnCode;
}
// Create databases
@@ 254,18 231,18 @@ sys::ReturnCodes ServiceDB::InitHandler()
quotesDB = std::make_unique<Database>((purefs::dir::getUserDiskPath() / "quotes.db").c_str());
// Create record interfaces
- alarmEventRecordInterface = std::make_unique<AlarmEventRecordInterface>(eventsDB.get());
- contactRecordInterface = std::make_unique<ContactRecordInterface>(contactsDB.get());
- smsRecordInterface = std::make_unique<SMSRecordInterface>(smsDB.get(), contactsDB.get());
- threadRecordInterface = std::make_unique<ThreadRecordInterface>(smsDB.get(), contactsDB.get());
- smsTemplateRecordInterface = std::make_unique<SMSTemplateRecordInterface>(smsDB.get());
- alarmsRecordInterface = std::make_unique<AlarmsRecordInterface>(alarmsDB.get());
- notesRecordInterface = std::make_unique<NotesRecordInterface>(notesDB.get());
- calllogRecordInterface = std::make_unique<CalllogRecordInterface>(calllogDB.get(), contactsDB.get());
- countryCodeRecordInterface = std::make_unique<CountryCodeRecordInterface>(countryCodesDB.get());
+ alarmEventRecordInterface = std::make_unique<AlarmEventRecordInterface>(eventsDB.get());
+ contactRecordInterface = std::make_unique<ContactRecordInterface>(contactsDB.get());
+ smsRecordInterface = std::make_unique<SMSRecordInterface>(smsDB.get(), contactsDB.get());
+ threadRecordInterface = std::make_unique<ThreadRecordInterface>(smsDB.get(), contactsDB.get());
+ smsTemplateRecordInterface = std::make_unique<SMSTemplateRecordInterface>(smsDB.get());
+ alarmsRecordInterface = std::make_unique<AlarmsRecordInterface>(alarmsDB.get());
+ notesRecordInterface = std::make_unique<NotesRecordInterface>(notesDB.get());
+ calllogRecordInterface = std::make_unique<CalllogRecordInterface>(calllogDB.get(), contactsDB.get());
+ countryCodeRecordInterface = std::make_unique<CountryCodeRecordInterface>(countryCodesDB.get());
notificationsRecordInterface =
std::make_unique<NotificationsRecordInterface>(notificationsDB.get(), contactRecordInterface.get());
- quotesRecordInterface = std::make_unique<Quotes::QuotesAgent>(quotesDB.get());
+ quotesRecordInterface = std::make_unique<Quotes::QuotesAgent>(quotesDB.get());
databaseAgents.emplace(std::make_unique<SettingsAgent>(this));
databaseAgents.emplace(std::make_unique<FileIndexerAgent>(this));
@@ 278,28 255,6 @@ sys::ReturnCodes ServiceDB::InitHandler()
return sys::ReturnCodes::Success;
}
-sys::ReturnCodes ServiceDB::DeinitHandler()
-{
- return sys::ReturnCodes::Success;
-}
-
-void ServiceDB::ProcessCloseReason(sys::CloseReason closeReason)
-{
- sendCloseReadyMessage(this);
-}
-
-sys::ReturnCodes ServiceDB::SwitchPowerModeHandler(const sys::ServicePowerMode mode)
-{
- LOG_FATAL("[%s] PowerModeHandler: %s", this->GetName().c_str(), c_str(mode));
- return sys::ReturnCodes::Success;
-}
-
-void ServiceDB::sendUpdateNotification(db::Interface::Name interface, db::Query::Type type)
-{
- auto notificationMessage = std::make_shared<db::NotificationMessage>(interface, type);
- bus.sendMulticast(notificationMessage, sys::BusChannel::ServiceDBNotifications);
-}
-
bool ServiceDB::StoreIntoBackup(const std::filesystem::path &backupPath)
{
if (eventsDB->storeIntoFile(backupPath / std::filesystem::path(eventsDB->getName()).filename()) == false) {
R module-services/service-db/ServiceDB.hpp => products/PurePhone/services/db/include/db/ServiceDB.hpp +11 -46
@@ 1,34 1,10 @@
-// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
+// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#pragma once
-#include "agents/file_indexer/FileIndexerAgent.hpp"
-#include "agents/settings/SettingsAgent.hpp"
-#include "service-db/DatabaseAgent.hpp"
-#include "service-db/DBNotificationMessage.hpp"
-#include "service-db/DBServiceName.hpp"
-
-#include "service-fileindexer/Constants.hpp"
-
-#include <Common/Query.hpp>
-#include <Interface/AlarmEventRecord.hpp>
-#include <Interface/AlarmsRecord.hpp>
-#include <Interface/BaseInterface.hpp>
-#include <Interface/CalllogRecord.hpp>
-#include <Interface/ContactRecord.hpp>
-#include <Interface/CountryCodeRecord.hpp>
-#include <Interface/NotesRecord.hpp>
-#include <Interface/SMSRecord.hpp>
-#include <Interface/SMSTemplateRecord.hpp>
-#include <Interface/ThreadRecord.hpp>
-#include <Service/Common.hpp>
-#include <Service/Message.hpp>
-#include <Service/Service.hpp>
-
-#include <memory>
-#include <set>
-#include <string>
+#include <service-db/DBServiceName.hpp>
+#include <service-db/ServiceDBCommon.hpp>
class AlarmsDB;
class AlarmEventRecordInterface;
@@ 48,6 24,7 @@ class NotificationsRecordInterface;
class SMSRecordInterface;
class SMSTemplateRecordInterface;
class SettingsDB;
+
class SmsDB;
class ThreadRecordInterface;
namespace Quotes
@@ 55,8 32,13 @@ namespace Quotes
class QuotesAgent;
}
-class ServiceDB : public sys::Service
+class ServiceDB : public ServiceDBCommon
{
+ public:
+ ~ServiceDB() override;
+
+ bool StoreIntoBackup(const std::filesystem::path &backupPath);
+
private:
std::unique_ptr<EventsDB> eventsDB;
std::unique_ptr<SmsDB> smsDB;
@@ 80,26 62,9 @@ class ServiceDB : public sys::Service
std::unique_ptr<NotificationsRecordInterface> notificationsRecordInterface;
std::unique_ptr<Quotes::QuotesAgent> quotesRecordInterface;
- protected:
- db::Interface *getInterface(db::Interface::Name interface);
- std::set<std::unique_ptr<DatabaseAgent>> databaseAgents;
-
- public:
- ServiceDB();
- ~ServiceDB() override;
-
+ db::Interface *getInterface(db::Interface::Name interface) override;
sys::MessagePointer DataReceivedHandler(sys::DataMessage *msgl, sys::ResponseMessage *resp) override;
-
sys::ReturnCodes InitHandler() override;
-
- sys::ReturnCodes DeinitHandler() override;
-
- void ProcessCloseReason(sys::CloseReason closeReason) override;
-
- sys::ReturnCodes SwitchPowerModeHandler(const sys::ServicePowerMode mode) final;
-
- bool StoreIntoBackup(const std::filesystem::path &backupPath);
- void sendUpdateNotification(db::Interface::Name interface, db::Query::Type type);
};
namespace sys
M products/PurePhone/test/test-settings/CMakeLists.txt => products/PurePhone/test/test-settings/CMakeLists.txt +1 -0
@@ 6,6 6,7 @@ add_catch2_executable(
main.cpp
test-service-db-settings-api.cpp
LIBS
+ db
evtmgr
module-audio
module-cellular
M products/PurePhone/test/test-settings/Database.cpp => products/PurePhone/test/test-settings/Database.cpp +1 -1
@@ 12,7 12,7 @@
#include <cstring>
#include <memory>
-#include <module-services/service-db/agents/settings/Settings_queries.hpp>
+#include <service-db/agents/settings/Settings_queries.hpp>
#include <map>
#include <string>
M products/PurePhone/test/test-settings/test-service-db-settings-api.cpp => products/PurePhone/test/test-settings/test-service-db-settings-api.cpp +13 -1
@@ 8,8 8,8 @@
#include <functional>
#include <thread> // for Message_t, ResponseMessage, DataMessage, Message
+#include <db/ServiceDB.hpp>
#include <evtmgr/EventManager.hpp>
-#include <module-services/service-db/ServiceDB.hpp>
#include <module-sys/SystemManager/SystemManagerCommon.hpp>
#include <service-evtmgr/Constants.hpp>
@@ 19,6 19,18 @@
#include "test-service-db-settings-testapps.hpp"
#include "Database.cpp"
+#include <module-db/Databases/AlarmsDB.hpp>
+#include <module-db/Databases/CountryCodesDB.hpp>
+#include <module-db/Databases/EventsDB.hpp>
+#include <module-db/Databases/NotesDB.hpp>
+#include <module-db/Databases/NotificationsDB.hpp>
+#include <module-db/Interface/AlarmEventRecord.hpp>
+#include <module-db/Interface/AlarmsRecord.hpp>
+#include <module-db/Interface/CountryCodeRecord.hpp>
+#include <module-db/Interface/NotesRecord.hpp>
+#include <module-db/Interface/NotificationsRecord.hpp>
+#include <service-db/agents/quotes/QuotesAgent.hpp>
+
TEST_CASE("SettingsApi")
{
SECTION("variable/profile/mode register/set/get/unregister")