From: Mu-Woong Lee Date: Tue, 8 Aug 2017 08:17:58 +0000 (+0900) Subject: Version 4.0.3: Rename ServerBase.* to MainLoop.* by following the Tizen naming rules X-Git-Tag: submit/tizen/20170904.032954^2~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F44%2F143044%2F2;p=platform%2Fcore%2Fcontext%2Fcontext-service.git Version 4.0.3: Rename ServerBase.* to MainLoop.* by following the Tizen naming rules Change-Id: Ib0ff13737207bd4c93536392d73c0a62e947122c Signed-off-by: Mu-Woong Lee --- diff --git a/packaging/context-service.spec b/packaging/context-service.spec index 176a5d5..8b54afa 100644 --- a/packaging/context-service.spec +++ b/packaging/context-service.spec @@ -1,6 +1,6 @@ Name: context-service Summary: Tizen Contextual Service Framework -Version: 4.0.2 +Version: 4.0.3 Release: 1 Group: Service/Context License: Apache-2.0 diff --git a/src/agent/AgentMain.cpp b/src/agent/AgentMain.cpp index fd271be..eba8448 100644 --- a/src/agent/AgentMain.cpp +++ b/src/agent/AgentMain.cpp @@ -18,7 +18,7 @@ #include #include -#include +#include #include "AgentDBus.h" #include "AgentUtil.h" #include "PluginLoader.h" diff --git a/src/server/ServerMain.cpp b/src/server/ServerMain.cpp index ae62b7c..9274f8b 100644 --- a/src/server/ServerMain.cpp +++ b/src/server/ServerMain.cpp @@ -20,7 +20,7 @@ #include #include -#include +#include #include "DBusConnector.h" #include "ServiceLoader.h" #include "ActiveUserMonitor.h" diff --git a/src/shared/MainLoop.cpp b/src/shared/MainLoop.cpp new file mode 100644 index 0000000..faef344 --- /dev/null +++ b/src/shared/MainLoop.cpp @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include "MainLoop.h" + +#define NEW_FAIL_LIMIT 3 + +using namespace ctx; + +static void __on_terminate() +{ + try { + auto unknown = std::current_exception(); + if (unknown) { + std::rethrow_exception(unknown); + } + } catch (const std::exception& e) { + _E(RED("Unexpected exception: %s"), e.what()); + } catch (...) { + _E(RED("Unknown exception")); + } +} + +static void __on_new_failed() +{ + static unsigned failCount = 0; + _E_ALLOC; + failCount += 1; + if (failCount >= NEW_FAIL_LIMIT) + throw std::bad_alloc(); +} + +MainLoop::MainLoop() : + __mainLoop(NULL) +{ + std::set_terminate(__on_terminate); + std::set_new_handler(__on_new_failed); +} + +bool MainLoop::start() +{ + __mainLoop = g_main_loop_new(NULL, FALSE); + IF_FAIL_RETURN_TAG(__mainLoop, false, _E, E_STR_ALLOC); + + _I(CYAN("Starting...")); + g_main_loop_run(__mainLoop); + + g_main_loop_unref(__mainLoop); + __mainLoop = NULL; + + return true; +} + +void MainLoop::stop() +{ + if (__mainLoop && g_main_loop_is_running(__mainLoop)) { + _I(PURPLE("Terminating...")); + g_main_loop_quit(__mainLoop); + } +} diff --git a/src/shared/MainLoop.h b/src/shared/MainLoop.h new file mode 100644 index 0000000..c6e8c78 --- /dev/null +++ b/src/shared/MainLoop.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __CONEXT_SERVICE_MAIN_LOOP_H__ +#define __CONEXT_SERVICE_MAIN_LOOP_H__ + +#include + +namespace ctx { + class MainLoop { + public: + MainLoop(); + bool start(); + void stop(); + private: + GMainLoop* __mainLoop; + }; +} + +#endif diff --git a/src/shared/ServerBase.cpp b/src/shared/ServerBase.cpp deleted file mode 100644 index 2f60ced..0000000 --- a/src/shared/ServerBase.cpp +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include "ServerBase.h" - -#define NEW_FAIL_LIMIT 3 - -using namespace ctx; - -static void __on_terminate() -{ - try { - auto unknown = std::current_exception(); - if (unknown) { - std::rethrow_exception(unknown); - } - } catch (const std::exception& e) { - _E(RED("Unexpected exception: %s"), e.what()); - } catch (...) { - _E(RED("Unknown exception")); - } -} - -static void __on_new_failed() -{ - static unsigned failCount = 0; - _E_ALLOC; - failCount += 1; - if (failCount >= NEW_FAIL_LIMIT) - throw std::bad_alloc(); -} - -MainLoop::MainLoop() : - __mainLoop(NULL) -{ - std::set_terminate(__on_terminate); - std::set_new_handler(__on_new_failed); -} - -bool MainLoop::start() -{ - __mainLoop = g_main_loop_new(NULL, FALSE); - IF_FAIL_RETURN_TAG(__mainLoop, false, _E, E_STR_ALLOC); - - _I(CYAN("Starting...")); - g_main_loop_run(__mainLoop); - - g_main_loop_unref(__mainLoop); - __mainLoop = NULL; - - return true; -} - -void MainLoop::stop() -{ - if (__mainLoop && g_main_loop_is_running(__mainLoop)) { - _I(PURPLE("Terminating...")); - g_main_loop_quit(__mainLoop); - } -} diff --git a/src/shared/ServerBase.h b/src/shared/ServerBase.h deleted file mode 100644 index e3bf1e4..0000000 --- a/src/shared/ServerBase.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef __CONEXT_SERVER_BASE_H__ -#define __CONEXT_SERVER_BASE_H__ - -#include - -namespace ctx { - class MainLoop { - public: - MainLoop(); - bool start(); - void stop(); - private: - GMainLoop* __mainLoop; - }; -} - -#endif