merge with master
[framework/web/wrt-installer.git] / src / wrt-installer / installer_main_thread.cpp
1 /*
2  * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
3  *
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
7  *
8  *        http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16 /*
17  * @file       installer_main_thread.cpp
18  * @author     Krzysztof Jackiewicz (k.jackiewicz@samsung.com)
19  * @version    1.0
20  */
21
22 #include "installer_main_thread.h"
23 #include <dpl/assert.h>
24 #include <dpl/wrt-dao-ro/WrtDatabase.h>
25 #include <vcore/VCore.h>
26 #include <dpl/singleton_impl.h>
27 #include <dpl/assert.h>
28 #include <installer_controller.h>
29 #include <ace_api_install.h>
30
31 IMPLEMENT_SINGLETON(InstallerMainThread)
32
33 using namespace WrtDB;
34
35 InstallerMainThread::InstallerMainThread() : m_attached(false) {}
36
37 InstallerMainThread::~InstallerMainThread()
38 {
39     Assert(!m_attached);
40 }
41
42 void InstallerMainThread::AttachDatabases()
43 {
44     Assert(!m_attached);
45     // Attach databases
46     ValidationCore::AttachToThreadRW();
47     ace_return_t ret = ace_install_initialize();
48     Assert(ACE_OK == ret); // to be changed to exception in the future
49     WrtDB::WrtDatabase::attachToThreadRW();
50     m_attached = true;
51 }
52
53 void InstallerMainThread::DetachDatabases()
54 {
55     Assert(m_attached);
56     m_attached = false;
57     // Detach databases
58     ValidationCore::DetachFromThread();
59     ace_return_t ret = ace_install_shutdown();
60     Assert(ACE_OK == ret); // to be changed to exception in the future
61     WrtDB::WrtDatabase::detachFromThread();
62 }
63
64 void InstallerMainThread::TouchArchitecture()
65 {
66     // Touch controller
67     Logic::InstallerControllerSingleton::Instance().Touch();
68 }
69
70 void InstallerMainThread::TouchArchitectureOnlyInstaller()
71 {
72     // Touch controller
73     Logic::InstallerControllerSingleton::Instance().Touch();
74 }