2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 * @file security_daemon.cpp
18 * @author Lukasz Wrzosek (l.wrzosek@samsung.com)
20 * @brief This is implementation file of Security Daemon
23 #include "security_daemon.h"
25 #include <dpl/assert.h>
26 #include <dpl/foreach.h>
27 #include <dpl/log/log.h>
28 #ifdef DBUS_CONNECTION
29 #include <dpl/framework_efl.h>
32 #include <dpl/singleton_impl.h>
33 IMPLEMENT_SINGLETON(SecurityDaemon::SecurityDaemon)
35 #include <ace-dao-rw/AceDAO.h>
37 namespace SecurityDaemon {
39 SecurityDaemon::SecurityDaemon() :
46 void SecurityDaemon::initialize(int& /*argc*/, char** /*argv*/)
48 DPL::Log::LogSystemSingleton::Instance().SetTag("SECURITY_DAEMON");
49 LogDebug("Initializing");
50 Assert(!m_initialized && "Already Initialized");
52 DatabaseService::initialize();
53 FOREACH (service, m_servicesList) {
54 (*service)->initialize();
57 LogDebug("Initialized");
60 int SecurityDaemon::execute()
62 Assert(m_initialized && "Not Initialized");
63 LogDebug("Starting execute");
64 FOREACH (service, m_servicesList) {
71 void SecurityDaemon::terminate(int returnValue)
73 Assert(m_initialized && "Not Initialized");
74 Assert(!m_terminating && "Already terminating");
75 LogDebug("Terminating");
77 m_returnValue = returnValue;
80 FOREACH (service, m_servicesList) {
85 void SecurityDaemon::shutdown()
88 Assert(m_initialized && "Not Initialized");
90 DatabaseService::deinitialize();
91 FOREACH (service, m_servicesList) {
92 (*service)->deinitialize();
95 m_initialized = false;
98 namespace DatabaseService {
100 void initialize(void)
102 LogDebug("Ace/Wrt database services initializing...");
103 AceDB::AceDAO::attachToThreadRW();
106 void deinitialize(void)
108 LogDebug("Ace/Wrt database services deinitializing...");
109 AceDB::AceDAO::detachFromThread();
112 } //namespace DatabaseService
114 } //namespace SecurityDaemon