Applying Tizen C++ coding style to Server 52/65652/1
authorSomin Kim <somin926.kim@samsung.com>
Tue, 12 Apr 2016 04:41:55 +0000 (13:41 +0900)
committerSomin Kim <somin926.kim@samsung.com>
Tue, 12 Apr 2016 04:41:55 +0000 (13:41 +0900)
Change-Id: If087f170d7958ffdd1ed3b1b6761b7a81ccb9d75
Signed-off-by: Somin Kim <somin926.kim@samsung.com>
src/ContextManagerImpl.cpp
src/DBusServer.cpp
src/DBusServer.h
src/ProviderHandler.cpp
src/Server.cpp [new file with mode: 0644]
src/Server.h [new file with mode: 0644]
src/access_control/PeerCreds.cpp
src/access_control/PeerCreds.h
src/db_mgr_impl.cpp
src/server.cpp [deleted file]
src/server.h [deleted file]

index b3ee2b30f1e9f492e1dc0049c0f1bb1d70d012ab..9c3438c3e78b2694d32b1f670f701a08199fc65a 100644 (file)
@@ -20,7 +20,7 @@
 #include <types_internal.h>
 #include <context_trigger_types_internal.h>
 #include <Json.h>
-#include "server.h"
+#include "Server.h"
 #include "access_control/Privilege.h"
 #include "Request.h"
 #include "ProviderHandler.h"
index e9a1d77bc6792fd9f953de98f1bc27071c7d75f6..54aa249d454ffcae9c952cadae10b35958a1b32b 100644 (file)
@@ -18,7 +18,7 @@
 #include <app_manager.h>
 
 #include <types_internal.h>
-#include "server.h"
+#include "Server.h"
 #include "ClientRequest.h"
 #include "access_control/PeerCreds.h"
 #include "DBusServer.h"
@@ -85,7 +85,7 @@ void DBusServer::__processRequest(const char *sender, GVariant *param, GDBusMeth
                return;
        }
 
-       server::send_request(request);
+       Server::sendRequest(request);
 }
 
 void DBusServer::__onRequestReceived(GDBusConnection *conn, const gchar *sender,
@@ -124,7 +124,7 @@ void DBusServer::__onBusAcquired(GDBusConnection *conn, const gchar *name, gpoin
 void DBusServer::__onNameAcquired(GDBusConnection *conn, const gchar *name, gpointer userData)
 {
        _SI("Dbus name acquired: %s", name);
-       server::activate();
+       Server::activate();
 }
 
 void DBusServer::__onNameLost(GDBusConnection *conn, const gchar *name, gpointer userData)
index 6b0bd806ad4f8ca918c6d5ab18f8212590c057b3..fdaac2f14bf2733984428c3bded08fd98e76db58 100644 (file)
@@ -54,7 +54,7 @@ namespace ctx {
                GDBusConnection *__connection;
                GDBusNodeInfo *__nodeInfo;
 
-               friend class server;
+               friend class Server;
 
        };      /* class ctx::DBusServer */
 
index d61694741b6abcd849c2ef233165a6df3a655ea8..2e1b3fef447906474039429dd862a1a1e6cda896 100644 (file)
@@ -18,7 +18,7 @@
 #include <types_internal.h>
 #include <Json.h>
 #include "access_control/Privilege.h"
-#include "server.h"
+#include "Server.h"
 #include "Request.h"
 #include "ProviderHandler.h"
 
diff --git a/src/Server.cpp b/src/Server.cpp
new file mode 100644 (file)
index 0000000..132d3a5
--- /dev/null
@@ -0,0 +1,164 @@
+/*
+ * Copyright (c) 2015 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 <stdlib.h>
+#include <new>
+#include <glib.h>
+#include <glib-object.h>
+
+#include <types_internal.h>
+#include "DBusServer.h"
+#include "db_mgr_impl.h"
+#include "ContextManagerImpl.h"
+#include "trigger/Trigger.h"
+#include "Server.h"
+
+static GMainLoop *mainloop = NULL;
+static bool started = false;
+
+static ctx::ContextManagerImpl *__contextMgr = NULL;
+static ctx::db_manager_impl *__databaseMgr = NULL;
+static ctx::DBusServer *__dbusHandle = NULL;
+static ctx::trigger::Trigger *__contextTrigger = NULL;
+
+/* TODO: re-organize activation & deactivation processes */
+void ctx::Server::initialize()
+{
+       _I("Init MainLoop");
+       mainloop = g_main_loop_new(NULL, FALSE);
+
+       _I("Init Dbus Connection");
+       __dbusHandle = new(std::nothrow) ctx::DBusServer();
+       IF_FAIL_VOID_TAG(__dbusHandle, _E, "Memory allocation failed");
+       IF_FAIL_VOID_TAG(__dbusHandle->__init(), _E, "Initialization Failed");
+
+       // Start the main loop
+       _I(CYAN("Launching Context-Service"));
+       g_main_loop_run(mainloop);
+}
+
+void ctx::Server::activate()
+{
+       IF_FAIL_VOID(!started);
+
+       bool result = false;
+
+       _I("Init Database Manager");
+       __databaseMgr = new(std::nothrow) ctx::db_manager_impl();
+       IF_FAIL_CATCH_TAG(__databaseMgr, _E, "Memory allocation failed");
+       db_manager::set_instance(__databaseMgr);
+       result = __databaseMgr->init();
+       IF_FAIL_CATCH_TAG(result, _E, "Initialization Failed");
+
+       _I("Init Context Manager");
+       __contextMgr = new(std::nothrow) ctx::ContextManagerImpl();
+       IF_FAIL_CATCH_TAG(__contextMgr, _E, "Memory allocation failed");
+       context_manager::setInstance(__contextMgr);
+       result = __contextMgr->init();
+       IF_FAIL_CATCH_TAG(result, _E, "Initialization Failed");
+
+       _I("Init Context Trigger");
+       __contextTrigger = new(std::nothrow) ctx::trigger::Trigger();
+       IF_FAIL_CATCH_TAG(__contextTrigger, _E, "Memory allocation failed");
+       result = __contextTrigger->init(__contextMgr);
+       IF_FAIL_CATCH_TAG(result, _E, "Initialization Failed");
+
+       started = true;
+       _I(CYAN("Context-Service Launched"));
+       return;
+
+CATCH:
+       _E(RED("Launching Failed"));
+
+       // Stop the main loop
+       g_main_loop_quit(mainloop);
+}
+
+void ctx::Server::release()
+{
+       _I(CYAN("Terminating Context-Service"));
+       _I("Release Context Trigger");
+       if (__contextTrigger)
+               __contextTrigger->release();
+
+       _I("Release Analyzer Manager");
+       if (__contextMgr)
+               __contextMgr->release();
+
+       _I("Release Dbus Connection");
+       if (__dbusHandle)
+               __dbusHandle->__release();
+
+       _I("Close the Database");
+       if (__databaseMgr)
+               __databaseMgr->release();
+
+       g_main_loop_unref(mainloop);
+
+       delete __contextTrigger;
+       delete __contextMgr;
+       delete __dbusHandle;
+       delete __databaseMgr;
+}
+
+static gboolean __postponeRequestAssignment(gpointer data)
+{
+       ctx::Server::sendRequest(static_cast<ctx::RequestInfo*>(data));
+       return FALSE;
+}
+
+void ctx::Server::sendRequest(ctx::RequestInfo* request)
+{
+       if (!started) {
+               _W("Service not ready...");
+               g_idle_add(__postponeRequestAssignment, request);
+               return;
+       }
+
+       if (!__contextTrigger->assignRequest(request)) {
+               __contextMgr->assignRequest(request);
+       }
+}
+
+static void __signalHandler(int signo)
+{
+       _I("SIGNAL %d received", signo);
+
+       // Stop the main loop
+       g_main_loop_quit(mainloop);
+}
+
+int main(int argc, char* argv[])
+{
+       static struct sigaction signalAction;
+       signalAction.sa_handler = __signalHandler;
+       sigemptyset(&signalAction.sa_mask);
+
+       sigaction(SIGINT, &signalAction, NULL);
+       sigaction(SIGHUP, &signalAction, NULL);
+       sigaction(SIGTERM, &signalAction, NULL);
+       sigaction(SIGQUIT, &signalAction, NULL);
+       sigaction(SIGABRT, &signalAction, NULL);
+
+#if !defined(GLIB_VERSION_2_36)
+       g_type_init();
+#endif
+
+       ctx::Server::initialize();
+       ctx::Server::release();
+
+       return EXIT_SUCCESS;
+}
diff --git a/src/Server.h b/src/Server.h
new file mode 100644 (file)
index 0000000..cd93bbf
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2015 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 _CONTEXT_SERVER_H_
+#define _CONTEXT_SERVER_H_
+
+namespace ctx {
+
+       class RequestInfo;
+
+       class Server {
+       public:
+               static void initialize();
+               static void activate();
+               static void release();
+               static void sendRequest(RequestInfo* request);
+
+       };
+
+}      /* namespace ctx */
+
+#endif /* End of _CONTEXT_SERVER_H_ */
index 2459862bb72ab101673c1a3a99d73bda92960602..9de5fa4a20c47f7ee7a416fc944ac6c4ae294de0 100644 (file)
 #include <types_internal.h>
 #include "PeerCreds.h"
 
-ctx::Credentials::Credentials(char *_packageId, char *_client, char *_session, char *_user) :
-       packageId(_packageId),
-       client(_client),
-       session(_session),
-       user(_user)
+ctx::Credentials::Credentials(char *pkgId, char *cli, char *sess, char *usr) :
+       packageId(pkgId),
+       client(cli),
+       session(sess),
+       user(usr)
 {
 }
 
index 72634cff9e56f48b09e1abda4697158a4c0c72eb..15a0a8f393ca7a0fb76c1d105233bd8668c04d3f 100644 (file)
@@ -29,7 +29,7 @@ namespace ctx {
                char *client;   /* default: smack label */
                char *session;
                char *user;             /* default: UID */
-               Credentials(char *_packageId, char *_client, char *_session, char *_user);
+               Credentials(char *pkgId, char *cli, char *sess, char *usr);
                ~Credentials();
        };
 
index 8c6a36b6e97c2fb508a983541d5f17eae765b0a0..eb507e88c6676080965cb95c803786e00b067568 100644 (file)
@@ -21,7 +21,7 @@
 #include <list>
 #include <tzplatform_config.h>
 #include <ScopeMutex.h>
-#include "server.h"
+#include "Server.h"
 #include "db_mgr_impl.h"
 
 #define CONTEXT_DB_PATH tzplatform_mkpath(TZ_USER_DB, ".context-service.db")
diff --git a/src/server.cpp b/src/server.cpp
deleted file mode 100644 (file)
index 671cba9..0000000
+++ /dev/null
@@ -1,164 +0,0 @@
-/*
- * Copyright (c) 2015 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 <stdlib.h>
-#include <new>
-#include <glib.h>
-#include <glib-object.h>
-
-#include <types_internal.h>
-#include "DBusServer.h"
-#include "db_mgr_impl.h"
-#include "ContextManagerImpl.h"
-#include "trigger/Trigger.h"
-#include "server.h"
-
-static GMainLoop *mainloop = NULL;
-static bool started = false;
-
-static ctx::ContextManagerImpl *context_mgr = NULL;
-static ctx::db_manager_impl *database_mgr = NULL;
-static ctx::DBusServer *dbus_handle = NULL;
-static ctx::trigger::Trigger *context_trigger = NULL;
-
-/* TODO: re-organize activation & deactivation processes */
-void ctx::server::initialize()
-{
-       _I("Init MainLoop");
-       mainloop = g_main_loop_new(NULL, FALSE);
-
-       _I("Init Dbus Connection");
-       dbus_handle = new(std::nothrow) ctx::DBusServer();
-       IF_FAIL_VOID_TAG(dbus_handle, _E, "Memory allocation failed");
-       IF_FAIL_VOID_TAG(dbus_handle->__init(), _E, "Initialization Failed");
-
-       // Start the main loop
-       _I(CYAN("Launching Context-Service"));
-       g_main_loop_run(mainloop);
-}
-
-void ctx::server::activate()
-{
-       IF_FAIL_VOID(!started);
-
-       bool result = false;
-
-       _I("Init Database Manager");
-       database_mgr = new(std::nothrow) ctx::db_manager_impl();
-       IF_FAIL_CATCH_TAG(database_mgr, _E, "Memory allocation failed");
-       db_manager::set_instance(database_mgr);
-       result = database_mgr->init();
-       IF_FAIL_CATCH_TAG(result, _E, "Initialization Failed");
-
-       _I("Init Context Manager");
-       context_mgr = new(std::nothrow) ctx::ContextManagerImpl();
-       IF_FAIL_CATCH_TAG(context_mgr, _E, "Memory allocation failed");
-       context_manager::setInstance(context_mgr);
-       result = context_mgr->init();
-       IF_FAIL_CATCH_TAG(result, _E, "Initialization Failed");
-
-       _I("Init Context Trigger");
-       context_trigger = new(std::nothrow) ctx::trigger::Trigger();
-       IF_FAIL_CATCH_TAG(context_trigger, _E, "Memory allocation failed");
-       result = context_trigger->init(context_mgr);
-       IF_FAIL_CATCH_TAG(result, _E, "Initialization Failed");
-
-       started = true;
-       _I(CYAN("Context-Service Launched"));
-       return;
-
-CATCH:
-       _E(RED("Launching Failed"));
-
-       // Stop the main loop
-       g_main_loop_quit(mainloop);
-}
-
-void ctx::server::release()
-{
-       _I(CYAN("Terminating Context-Service"));
-       _I("Release Context Trigger");
-       if (context_trigger)
-               context_trigger->release();
-
-       _I("Release Analyzer Manager");
-       if (context_mgr)
-               context_mgr->release();
-
-       _I("Release Dbus Connection");
-       if (dbus_handle)
-               dbus_handle->__release();
-
-       _I("Close the Database");
-       if (database_mgr)
-               database_mgr->release();
-
-       g_main_loop_unref(mainloop);
-
-       delete context_trigger;
-       delete context_mgr;
-       delete dbus_handle;
-       delete database_mgr;
-}
-
-static gboolean postpone_request_assignment(gpointer data)
-{
-       ctx::server::send_request(static_cast<ctx::RequestInfo*>(data));
-       return FALSE;
-}
-
-void ctx::server::send_request(ctx::RequestInfo* request)
-{
-       if (!started) {
-               _W("Service not ready...");
-               g_idle_add(postpone_request_assignment, request);
-               return;
-       }
-
-       if (!context_trigger->assignRequest(request)) {
-               context_mgr->assignRequest(request);
-       }
-}
-
-static void signal_handler(int signo)
-{
-       _I("SIGNAL %d received", signo);
-
-       // Stop the main loop
-       g_main_loop_quit(mainloop);
-}
-
-int main(int argc, char* argv[])
-{
-       static struct sigaction signal_action;
-       signal_action.sa_handler = signal_handler;
-       sigemptyset(&signal_action.sa_mask);
-
-       sigaction(SIGINT, &signal_action, NULL);
-       sigaction(SIGHUP, &signal_action, NULL);
-       sigaction(SIGTERM, &signal_action, NULL);
-       sigaction(SIGQUIT, &signal_action, NULL);
-       sigaction(SIGABRT, &signal_action, NULL);
-
-#if !defined(GLIB_VERSION_2_36)
-       g_type_init();
-#endif
-
-       ctx::server::initialize();
-       ctx::server::release();
-
-       return EXIT_SUCCESS;
-}
diff --git a/src/server.h b/src/server.h
deleted file mode 100644 (file)
index 8129079..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (c) 2015 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 __CONTEXT_SERVER_H__
-#define __CONTEXT_SERVER_H__
-
-namespace ctx {
-
-       class RequestInfo;
-
-       class server {
-       public:
-               static void initialize();
-               static void activate();
-               static void release();
-               static void send_request(RequestInfo* request);
-
-       };
-
-}      /* namespace ctx */
-
-#endif /* End of __CONTEXT_SERVER_H__ */