ae9a7314ecb68035fdd5e5ed82b058f22b79a472
[platform/core/security/security-manager.git] / src / server / service / installer.h
1 /*
2  *  Copyright (c) 2000 - 2014 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  *  Contact: Rafal Krypa <r.krypa@samsung.com>
5  *
6  *  Licensed under the Apache License, Version 2.0 (the "License");
7  *  you may not use this file except in compliance with the License.
8  *  You may obtain a copy of the License at
9  *
10  *      http://www.apache.org/licenses/LICENSE-2.0
11  *
12  *  Unless required by applicable law or agreed to in writing, software
13  *  distributed under the License is distributed on an "AS IS" BASIS,
14  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  *  See the License for the specific language governing permissions and
16  *  limitations under the License
17  */
18 /*
19  * @file        installer.h
20  * @author      Michal Witanowski (m.witanowski@samsung.com)
21  * @brief       Implementation of installer service for libprivilege-control encapsulation.
22  */
23
24 #ifndef _SECURITY_MANAGER_INSTALLER_
25 #define _SECURITY_MANAGER_INSTALLER_
26
27 #include <service-thread.h>
28 #include <generic-socket-manager.h>
29 #include <message-buffer.h>
30 #include <connection-info.h>
31
32 namespace SecurityManager {
33
34 class InstallerException
35 {
36 public:
37     DECLARE_EXCEPTION_TYPE(SecurityManager::Exception, Base)
38     DECLARE_EXCEPTION_TYPE(Base, InvalidAction)
39 };
40
41 class InstallerService :
42     public SecurityManager::GenericSocketService,
43     public SecurityManager::ServiceThread<InstallerService>
44 {
45 public:
46     InstallerService();
47     ServiceDescriptionVector GetServiceDescription();
48
49     DECLARE_THREAD_EVENT(AcceptEvent, accept)
50     DECLARE_THREAD_EVENT(WriteEvent, write)
51     DECLARE_THREAD_EVENT(ReadEvent, process)
52     DECLARE_THREAD_EVENT(CloseEvent, close)
53
54     void accept(const AcceptEvent &event);
55     void write(const WriteEvent &event);
56     void process(const ReadEvent &event);
57     void close(const CloseEvent &event);
58
59     static const char *const LABEL_FOR_PUBLIC_APP_PATH;
60
61 private:
62     ConnectionInfoMap m_connectionInfoMap;
63
64     /**
65      * Handle request from a client
66      *
67      * @param  conn        Socket connection information
68      * @param  buffer      Raw received data buffer
69      * @param  interfaceID identifier used to distinguish source socket
70      * @return             true on success
71      */
72     bool processOne(const ConnectionID &conn, MessageBuffer &buffer, InterfaceID interfaceID);
73
74     /**
75      * Process application installation
76      *
77      * @param  buffer Raw received data buffer
78      * @param  send   Raw data buffer to be sent
79      * @return        true on success
80      */
81     bool processAppInstall(MessageBuffer &buffer, MessageBuffer &send);
82
83     /**
84      * Process libprivilege-control action and store result in a bufer
85      *
86      * @param  buffer Raw received data buffer
87      * @param  send   Raw data buffer to be sent
88      * @return        true on success
89      */
90     bool processAppUninstall(MessageBuffer &buffer, MessageBuffer &send);
91 };
92
93 } // namespace SecurityManager
94
95 #endif // _SECURITY_MANAGER_INSTALLER_