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 [moved from src/server.cpp with 50% similarity]
src/Server.h [moved from src/server.h with 82% similarity]
src/access_control/PeerCreds.cpp
src/access_control/PeerCreds.h
src/db_mgr_impl.cpp

index b3ee2b3..9c3438c 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 e9a1d77..54aa249 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 6b0bd80..fdaac2f 100644 (file)
@@ -54,7 +54,7 @@ namespace ctx {
                GDBusConnection *__connection;
                GDBusNodeInfo *__nodeInfo;
 
-               friend class server;
+               friend class Server;
 
        };      /* class ctx::DBusServer */
 
index d616947..2e1b3fe 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"
 
similarity index 50%
rename from src/server.cpp
rename to src/Server.cpp
index 671cba9..132d3a5 100644 (file)
 #include "db_mgr_impl.h"
 #include "ContextManagerImpl.h"
 #include "trigger/Trigger.h"
-#include "server.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;
+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()
+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");
+       __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()
+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();
+       __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");
-       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();
+       __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");
-       context_trigger = new(std::nothrow) ctx::trigger::Trigger();
-       IF_FAIL_CATCH_TAG(context_trigger, _E, "Memory allocation failed");
-       result = context_trigger->init(context_mgr);
+       __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;
@@ -87,53 +87,53 @@ CATCH:
        g_main_loop_quit(mainloop);
 }
 
-void ctx::server::release()
+void ctx::Server::release()
 {
        _I(CYAN("Terminating Context-Service"));
        _I("Release Context Trigger");
-       if (context_trigger)
-               context_trigger->release();
+       if (__contextTrigger)
+               __contextTrigger->release();
 
        _I("Release Analyzer Manager");
-       if (context_mgr)
-               context_mgr->release();
+       if (__contextMgr)
+               __contextMgr->release();
 
        _I("Release Dbus Connection");
-       if (dbus_handle)
-               dbus_handle->__release();
+       if (__dbusHandle)
+               __dbusHandle->__release();
 
        _I("Close the Database");
-       if (database_mgr)
-               database_mgr->release();
+       if (__databaseMgr)
+               __databaseMgr->release();
 
        g_main_loop_unref(mainloop);
 
-       delete context_trigger;
-       delete context_mgr;
-       delete dbus_handle;
-       delete database_mgr;
+       delete __contextTrigger;
+       delete __contextMgr;
+       delete __dbusHandle;
+       delete __databaseMgr;
 }
 
-static gboolean postpone_request_assignment(gpointer data)
+static gboolean __postponeRequestAssignment(gpointer data)
 {
-       ctx::server::send_request(static_cast<ctx::RequestInfo*>(data));
+       ctx::Server::sendRequest(static_cast<ctx::RequestInfo*>(data));
        return FALSE;
 }
 
-void ctx::server::send_request(ctx::RequestInfo* request)
+void ctx::Server::sendRequest(ctx::RequestInfo* request)
 {
        if (!started) {
                _W("Service not ready...");
-               g_idle_add(postpone_request_assignment, request);
+               g_idle_add(__postponeRequestAssignment, request);
                return;
        }
 
-       if (!context_trigger->assignRequest(request)) {
-               context_mgr->assignRequest(request);
+       if (!__contextTrigger->assignRequest(request)) {
+               __contextMgr->assignRequest(request);
        }
 }
 
-static void signal_handler(int signo)
+static void __signalHandler(int signo)
 {
        _I("SIGNAL %d received", signo);
 
@@ -143,22 +143,22 @@ static void signal_handler(int signo)
 
 int main(int argc, char* argv[])
 {
-       static struct sigaction signal_action;
-       signal_action.sa_handler = signal_handler;
-       sigemptyset(&signal_action.sa_mask);
+       static struct sigaction signalAction;
+       signalAction.sa_handler = __signalHandler;
+       sigemptyset(&signalAction.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);
+       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();
+       ctx::Server::initialize();
+       ctx::Server::release();
 
        return EXIT_SUCCESS;
 }
similarity index 82%
rename from src/server.h
rename to src/Server.h
index 8129079..cd93bbf 100644 (file)
  * limitations under the License.
  */
 
-#ifndef __CONTEXT_SERVER_H__
-#define __CONTEXT_SERVER_H__
+#ifndef _CONTEXT_SERVER_H_
+#define _CONTEXT_SERVER_H_
 
 namespace ctx {
 
        class RequestInfo;
 
-       class server {
+       class Server {
        public:
                static void initialize();
                static void activate();
                static void release();
-               static void send_request(RequestInfo* request);
+               static void sendRequest(RequestInfo* request);
 
        };
 
 }      /* namespace ctx */
 
-#endif /* End of __CONTEXT_SERVER_H__ */
+#endif /* End of _CONTEXT_SERVER_H_ */
index 2459862..9de5fa4 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 72634cf..15a0a8f 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 8c6a36b..eb507e8 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")