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
#include <cstdlib>
#include <systemd/sd-daemon.h>
-#include <ServerBase.h>
+#include <MainLoop.h>
#include "AgentDBus.h"
#include "AgentUtil.h"
#include "PluginLoader.h"
#include <ContextTypes.h>
#include <ServerUtil.h>
-#include <ServerBase.h>
+#include <MainLoop.h>
#include "DBusConnector.h"
#include "ServiceLoader.h"
#include "ActiveUserMonitor.h"
--- /dev/null
+/*
+ * 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 <new>
+#include <exception>
+#include <stdexcept>
+#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);
+ }
+}
--- /dev/null
+/*
+ * 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 <ContextTypes.h>
+
+namespace ctx {
+ class MainLoop {
+ public:
+ MainLoop();
+ bool start();
+ void stop();
+ private:
+ GMainLoop* __mainLoop;
+ };
+}
+
+#endif
+++ /dev/null
-/*
- * 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 <new>
-#include <exception>
-#include <stdexcept>
-#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);
- }
-}
+++ /dev/null
-/*
- * 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 <ContextTypes.h>
-
-namespace ctx {
- class MainLoop {
- public:
- MainLoop();
- bool start();
- void stop();
- private:
- GMainLoop* __mainLoop;
- };
-}
-
-#endif