Fix to apply whitespace coding rules
[platform/core/security/krate.git] / server / packman.h
1 /*
2  *  Copyright (c) 2015 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 #ifndef __PACKMAN_H__
18 #define __PACKMAN_H__
19
20 #include <unistd.h>
21 #include <sys/types.h>
22
23 #include <string>
24 #include <vector>
25
26 #include <package-manager.h>
27 #include <pkgmgr-info.h>
28
29 class ApplicationInfo final {
30 public:
31         ApplicationInfo(const std::string& aid, uid_t uid = 0);
32         ApplicationInfo(pkgmgrinfo_appinfo_h handle);
33         ~ApplicationInfo();
34
35         const std::string& getId() const;
36         const std::string& getPackage() const;
37         const std::string& getType() const;
38         const std::string& getIcon() const;
39         const std::string& getLabel() const;
40         int getComponentType() const;
41         bool isNoDisplayed() const;
42         bool isTaskManaged() const;
43
44 private:
45         void load(pkgmgrinfo_appinfo_h handle);
46
47         std::string id;
48         std::string package;
49         std::string type;
50         std::string icon;
51         std::string label;
52         int componentType;
53         bool noDisplayed;
54         bool taskManaged;
55 };
56
57 class PackageInfo final {
58 public:
59         PackageInfo(const std::string& pkgid, uid_t uid = 0);
60         ~PackageInfo();
61
62         std::vector<ApplicationInfo> getAppList() const;
63
64         std::string getType() const;
65         std::string getIcon() const;
66         std::string getLabel() const;
67         std::string getDescription() const;
68
69         std::string getAuthorName() const;
70         std::string getAuthorEmail() const;
71         std::string getAuthorHref() const;
72
73         std::string getVersion() const;
74         std::string getApiVersion() const;
75         std::string getMainAppId() const;
76
77         bool isSystem() const;
78         bool isRemovable() const;
79         bool isPreload() const;
80
81 private:
82         uid_t user;
83         pkgmgrinfo_pkginfo_h handle;
84 };
85
86 class PackageManager final {
87 public:
88         void installPackage(const std::string& pkgpath, const uid_t user);
89         void uninstallPackage(const std::string& pkgid, const uid_t user);
90
91         std::vector<std::string> getPackageList(const uid_t user);
92         std::vector<ApplicationInfo> getAppList(const uid_t user);
93
94         void setEventCallback(pkgmgrinfo_handler callback, void* user_data);
95         void unsetEventCallback();
96
97         void setModeRestriction(int mode, uid_t user);
98         void unsetModeRestriction(int mode, uid_t user);
99         int getModeRestriction(uid_t user);
100
101         void setPackageRestriction(const std::string& pkgid, int mode, uid_t user);
102         void unsetPackageRestriction(const std::string& pkgid, int mode, uid_t user);
103         int getPackageRestriction(const std::string& pkgid, uid_t user);
104
105         static PackageManager& instance();
106
107 private:
108         PackageManager();
109         ~PackageManager();
110
111 private:
112         pkgmgr_client *nativeRequestHandle, *nativeListenHandle;
113 };
114
115 #endif // __PACKMAN_H__