Revert "Clean up author_id parameter and shared_dirs API"
[platform/core/appfw/app-installers.git] / src / common / shared_dirs.h
1 // Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
2 // Use of this source code is governed by an apache-2.0 license that can be
3 // found in the LICENSE file.
4
5 #ifndef COMMON_SHARED_DIRS_H_
6 #define COMMON_SHARED_DIRS_H_
7
8 #include <boost/filesystem/path.hpp>
9 #include <pkgmgrinfo_basic.h>
10
11 #include <string>
12 #include <vector>
13
14 namespace common_installer {
15
16 struct PkgInfo {
17   PkgInfo(std::string pkg_id_, std::string api_version_, std::string author_)
18     : pkg_id(pkg_id_),
19       api_version(api_version_),
20       author_id(author_) {}
21
22   std::string pkg_id;
23   std::string api_version;
24   std::string author_id;
25 };
26
27 using PkgList = std::vector<PkgInfo>;
28
29 /**
30  * \brief Performs a creation of directories for specific user in internal storage
31  *
32  * \param pkgid id of package
33  * \param trusted is package trusted
34  * \param create_skel_directories flag
35  *
36  * \return true if succeed, false otherwise
37  */
38 bool PerformInternalDirectoryCreationForUser(uid_t uid,
39                                              const std::string& pkgid,
40                                              bool trusted);
41
42 /**
43  * \brief Performs a creation of directories for specific user in external storage
44  *
45  * \param pkgid id of package
46  * \param create_skel_directories flag
47  *
48  * \return true if succeed, false otherwise
49  *
50  */
51 bool PerformExternalDirectoryCreationForUser(uid_t uid,
52                                              const std::string& pkgid);
53
54 /**
55  * \brief Performs a removal of directories for specific user in external storage
56  * \param user id of user
57  * \param pkgid id of package
58  *
59  * \return true if succeed, false otherwise
60  */
61 bool PerformExternalDirectoryDeletionForUser(uid_t user,
62                                             const std::string& pkgid);
63
64 /**
65  * \brief Performs a creation of directories in internal storage
66  *
67  * \param pkgid id of package
68  * \param trusted is package trusted
69  * \param create_skel_directories flag
70  *
71  * \return true if succeed, false otherwise
72  *
73  */
74 bool PerformInternalDirectoryCreationForAllUsers(const std::string& pkgid,
75                                                  bool trusted);
76
77 /**
78  * \brief Performs a creation of directories in external storage (eg. SD card)
79  *
80  * \param pkgid id of package
81  * \param create_skel_directories flag
82  *
83  * \return true if succeed, false otherwise
84  *
85  */
86 bool PerformExternalDirectoryCreationForAllUsers(const std::string& pkgid);
87
88 /**
89  * \brief Performs a removal of directories in external storage (eg. SD card)
90  * \param pkgid id of package
91  *
92  * \return true if succeed, false otherwise
93  */
94 bool PerformExternalDirectoryDeletionForAllUsers(const std::string& pkgid);
95
96 /**
97  * \brief Helper function fetching information about packages
98  *
99  * \param pkgs  list of packages requested to fetch information about. If list
100  *              is empty, all possible pkg id's are considered.
101  *
102  * \return pkg_list list containing information about requested packages
103  *
104  */
105 PkgList CreatePkgInformationList(uid_t uid = getuid(),
106                                  const std::vector<std::string>& pkgs =
107     std::vector<std::string>());
108
109 /**
110  * \brief Create skeleton directories for package
111  *
112  * \param pkgid package id
113  *
114  * \return bool true if succeed, false otherwise
115  *
116  */
117 bool CreateSkelDirectories(const std::string& pkgid);
118
119 /**
120  * \brief Performs deletion of directories
121  *
122  * \param pkgid package id
123  *
124  * \return true if succeed, false otherwise
125  *
126  */
127 bool DeleteSkelDirectories(const std::string& pkgid);
128
129 /**
130  * \brief Delete per-user directories
131  *
132  * \param pkgid package id
133  *
134  * \return true if succeed, false otherwise
135  *
136  */
137 bool DeleteUserDirectories(const std::string& pkgid);
138
139 /**
140  * \brief Copy per-user directories
141  *
142  * \param pkgid package id
143  *
144  * \return bool true if succeed, false otherwise
145  *
146  */
147 bool CopyUserDirectories(const std::string& pkgid);
148
149 /**
150  * \brief Returns path prefix for internal storage, typically '/home'
151  *
152  * \return path prefix
153  *
154  */
155 std::string GetDirectoryPathForInternalStorage();
156
157 /**
158  * \brief Returns path prefix for external storage, typically sd card mount point
159  *
160  * \return path prefix
161  *
162  */
163 std::string GetDirectoryPathForExternalStorage();
164
165 }  // namespace common_installer
166
167 #endif  // COMMON_SHARED_DIRS_H_