Merge "GetErrorMessage() to print the error log" into tizen_2.1
[platform/framework/native/appfw.git] / inc / FAppPkgPackageManager.h
1 //
2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17
18 /**
19  * @file        FAppPkgPackageManager.h
20  * @brief       This is the header file for the %PackageManager class.
21  *
22  * This header file contains the declarations of the %PackageManager class.
23  */
24
25 #ifndef _FAPP_PKG_PACKAGE_MANAGER_H_
26 #define _FAPP_PKG_PACKAGE_MANAGER_H_
27
28 #include <FBase.h>
29 #include <FAppTypes.h>
30
31 namespace Tizen { namespace App { namespace Package
32 {
33
34 class PackageInfo;
35 class PackageAppInfo;
36 class IPackageInstallationEventListener;
37 class IPackageInstallationResponseListener;
38 class IPackageUninstallationResponseListener;
39
40 /**
41  * @enum PackageType
42  *
43  * Defines the package types.
44   *
45  * @since       2.0
46  */
47 enum PackageType
48 {
49         PACKAGE_TYPE_TPK,                       /**< TIZEN Native package */
50         PACKAGE_TYPE_WGT,                       /**< TIZEN %Web package */
51         PACKAGE_TYPE_RPM,                       /**< TIZEN Core package */
52 };
53
54 /**
55  * @class               PackageManager
56  * @brief               This class gets the information of packages and manages package installation or uninstallation.
57  *
58  * @since       2.0
59  *
60  * @final               This class is not intended for extension.
61  *
62  * The %PackageManager class provides methods to install or uninstall the packages, retrieves the information of the packages that are installed on the device.
63  *
64  * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/app/package_namespace.htm">Package Management</a>.
65  *
66  */
67 class _OSP_EXPORT_ PackageManager
68         : public Tizen::Base::Object
69 {
70 public:
71         /**
72          * Gets the package ID from the application ID.
73          *
74          * @since       2.0
75          *
76          * @return              The package ID, @n
77          *                              else @c packageId.IsEmtpy() == true is returned if an error occurs
78          * @param[in]   appId                           The application ID
79          * @exception   E_SUCCESS                       The method is successful.
80          * @exception   E_INVALID_ARG           The specified input parameter is invalid.
81          * @remarks             The specific error code can be accessed using the GetLastResult() method.
82          */
83         static PackageId GetPackageIdByAppId(const AppId& appId);
84
85         /**
86          * Adds a package installation event listener.
87          *
88          * @since       2.0
89          * @privlevel   public
90          * @privilege   %http://tizen.org/privilege/package.info @n
91          *                                       (%http://tizen.org/privilege/packageinfo is deprecated.)
92          *
93          * @return              An error code
94          * @param[in]   listener                        The package installation event listener
95          * @exception   E_SUCCESS                       The method is successful.
96          * @exception   E_OBJ_ALREADY_EXIST     The listener is already added.
97          * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
98          */
99         result AddPackageInstallationEventListener(IPackageInstallationEventListener& listener);
100
101         /**
102          * Removes a package installation event listener.
103          *
104          * @since       2.0
105          * @privlevel   public
106          * @privilege   %http://tizen.org/privilege/package.info @n
107          *                                       (%http://tizen.org/privilege/packageinfo is deprecated.)
108          *
109          * @return              An error code
110          * @param[in]   listener                        The package installation event listener
111          * @exception   E_SUCCESS                       The method is successful.
112          * @exception   E_OBJ_NOT_FOUND         The listener is not added or is already removed.
113          * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
114          */
115         result RemovePackageInstallationEventListener(IPackageInstallationEventListener& listener);
116
117         /**
118          * Gets a package information with the specific package ID.
119          *
120          * @since       2.0
121          * @privlevel   public
122          * @privilege   %http://tizen.org/privilege/package.info @n
123          *                                       (%http://tizen.org/privilege/packageinfo is deprecated.)
124          *
125          * @return              A pointer to PackageInfo
126          * @param[in]   packageId                               The package ID
127          * @exception   E_SUCCESS                       The method is successful.
128          * @exception   E_INVALID_ARG           The specified input parameter is invalid.
129          * @exception   E_SYSTEM                        The method cannot proceed due to a severe system error.
130          * @exception   E_PKG_NOT_INSTALLED             The package is not installed.
131          * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
132          * @remarks             The specific error code can be accessed using the GetLastResult() method.
133          */
134         PackageInfo* GetPackageInfoN(const PackageId& packageId) const;
135
136         /**
137          * Gets the application information with the specific application ID.
138          *
139          * @since       2.0
140          * @privlevel   public
141          * @privilege   %http://tizen.org/privilege/package.info @n
142          *                                       (%http://tizen.org/privilege/packageinfo is deprecated.)
143          *
144          * @return              A pointer to PackageAppInfo
145          * @param[in]   appId                           The application ID
146          * @exception   E_SUCCESS                       The method is successful.
147          * @exception   E_INVALID_ARG           The specified input parameter is invalid.
148          * @exception   E_SYSTEM                        The method cannot proceed due to a severe system error.
149          * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
150          * @remarks             The specific error code can be accessed using the GetLastResult() method.
151          */
152         PackageAppInfo* GetPackageAppInfoN(const AppId& appId) const;
153
154         /**
155          * Gets the package information list.
156          *
157          * @since       2.0
158          * @privlevel   public
159          * @privilege   %http://tizen.org/privilege/package.info @n
160          *                                       (%http://tizen.org/privilege/packageinfo is deprecated.)
161          *
162          * @return              A pointer to the list of the PackageInfo instances, @n
163          *                              else @c null if it fails
164          * @exception   E_SUCCESS                       The method is successful.
165          * @exception   E_SYSTEM                        The method cannot proceed due to a severe system error.
166          * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
167          * @remarks             The specific error code can be accessed using the GetLastResult() method.
168          */
169         Tizen::Base::Collection::IList* GetPackageInfoListN(void) const;
170
171         /**
172          * Checks whether a package is installed.
173          *
174          * @since       2.0
175          * @privlevel   public
176          * @privilege   %http://tizen.org/privilege/package.info @n
177          *                                       (%http://tizen.org/privilege/packageinfo is deprecated.)
178          *
179          * @return      @c true if a package is installed, @n
180          *                      else @c false
181          * @param[in]   packageId                               The package ID
182          * @exception   E_SUCCESS                       The method is successful.
183          * @exception   E_INVALID_ARG           The specified input parameter is invalid.
184          * @exception   E_SYSTEM                        The method cannot proceed due to a severe system error.
185          * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
186          * @remarks             The specific error code can be accessed using the GetLastResult() method.
187          */
188         bool IsPackageInstalled(const PackageId& packageId) const;
189
190         /**
191          * Installs a package. @n
192          * The %InstallPackage() method operates asynchronously, that is, it ends immediately without an installation response. The application is notified when the installation is completed, so the response is available through the IPackageInstallationResponseListener::OnPackageInstallationCompleted() method, if this method returns @c E_SUCCESS.
193          *
194          * @since       2.0
195          * @privlevel   platform
196          * @privilege   %http://tizen.org/privilege/packagemanager.install
197          *
198          * @return              An error code
199          * @param[in]   packageId                       The package ID
200          * @param[in]   packagePath                     The package path
201          * @param[in]   pListener                       The response listener
202          * @exception   E_SUCCESS                       The method is successful.
203          * @exception   E_INVALID_ARG           A specified input parameter is invalid.
204          * @exception   E_SYSTEM                        The method cannot proceed due to a severe system error.
205          * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
206          * @remarks             A listener instance ownership is transferred to the platform. After notifying result, the listener instance is removed automatically. A reuse of the listener instance is not allowed.
207          * @see                 IPackageInstallationResponseListener
208          */
209         result InstallPackage(const PackageId& packageId, const Tizen::Base::String& packagePath, IPackageInstallationResponseListener* pListener);
210
211         /**
212          * Uninstalls a package with the specified package ID. @n
213          * The %UninstallPackage() method operates asynchronously, that is, it ends immediately without an uninstallation response. The application is notified when the uninstallation is completed, so the response is available through the IPackageUninstallationResponseListener::OnPackageUninstallationCompleted() method, if this method returns @c true.
214          *
215          * @since       2.0
216          * @privlevel   platform
217          * @privilege   %http://tizen.org/privilege/packagemanager.install
218          *
219          * @return              An error code
220          * @param[in]   packageId                               The package ID
221          * @param[in]   pListener                               The response listener
222          * @exception   E_SUCCESS                               The method is successful.
223          * @exception   E_INVALID_ARG                   A specified input parameter is invalid.
224          * @exception   E_SYSTEM                                The method cannot proceed due to a severe system error.
225          * @exception   E_PKG_NOT_INSTALLED             The package is not installed.
226          * @exception   E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
227          * @remarks             A listener instance ownership is transferred to the platform. After notifying result, the listener instance is removed automatically. A reuse of the listener instance is not allowed.
228          * @see                 IPackageUninstallationResponseListener
229          */
230         result UninstallPackage(const PackageId& packageId, IPackageUninstallationResponseListener* pListener);
231
232         /**
233          *  Moves a package with the specified package ID to an external storage.
234          *
235          * @since       2.0
236          * @privlevel   platform
237          * @privilege   %http://tizen.org/privilege/packagemanager.setting @n
238          *                                       (%http://tizen.org/privilege/packagesetting is deprecated.)
239          *
240          * @return              An error code
241          * @param[in]   packageId                               The package ID
242          * @exception   E_SUCCESS                               The method is successful.
243          * @exception   E_INVALID_ARG                   The specified input parameter is invalid.
244          * @exception   E_INVALID_OPERATION             The package is already installed in an external storage.
245          * @exception   E_STORAGE_FULL                  The storage is full.
246          * @exception   E_PKG_NOT_INSTALLED             The package is not installed.
247          * @exception   E_SYSTEM                                The method cannot proceed due to a severe system error.
248          * @exception   E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
249          */
250         result MoveToExternalStorage(const PackageId& packageId);
251
252         /**
253          * Moves a package with the specified package ID to an internal storage.
254          *
255          * @since       2.0
256          * @privlevel   platform
257          * @privilege   %http://tizen.org/privilege/packagemanager.setting @n
258          *                                       (%http://tizen.org/privilege/packagesetting is deprecated.)
259          *
260          * @return              An error code
261          * @param[in]   packageId                               The package ID
262          * @exception   E_SUCCESS                               The method is successful.
263          * @exception   E_INVALID_ARG                   The specified input parameter is invalid.
264          * @exception   E_INVALID_OPERATION             The package is already installed in an internal storage.
265          * @exception   E_STORAGE_FULL                  The storage is full.
266          * @exception   E_PKG_NOT_INSTALLED             The package is not installed.
267          * @exception   E_SYSTEM                                The method cannot proceed due to a severe system error.
268          * @exception   E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
269          */
270         result MoveToInternalStorage(const PackageId& packageId);
271
272         /**
273         * Gets a package information from the specific file. The supported file extensions are tpk and wgt.
274         *
275         * @since         2.1
276         * @privlevel     platform
277         * @privilege     %http://tizen.org/privilege/packagemanager.info
278         *
279         * @return        A pointer to the %PackageInfo instance, @n
280         *               else @c null if it fails
281         * @param[in]    filePath                           The package file path
282         * @exception    E_SUCCESS                          The method is successful.
283         * @exception    E_INVALID_ARG                      A specified input parameter is invalid.
284         * @exception    E_FILE_NOT_FOUND                   The specified file cannot be found or accessed.
285         * @exception    E_UNSUPPORTED_FORMAT               The specified format is invalid or not supported.
286         * @exception    E_PARSING_FAILED                   The method has failed to parse the package file or xml file(s) inside the package.
287         * @exception    E_PRIVILEGE_DENIED                 The application does not have the privilege to call this method.
288         * @remarks      The specific error code can be accessed using the GetLastResult() method.
289         */
290         PackageInfo* GetPackageInfoFromFileN(const Tizen::Base::String& filePath) const;
291
292         /**
293         * Gets the package information list with the package filter.
294         *
295         * @since         2.1
296         * @privlevel     public
297         * @privilege     %http://tizen.org/privilege/package.info
298         *
299         * @return        A pointer to the list of the %PackageInfo instances, @n
300         *                else @c null if it fails
301         * @param[in]     packageFilterMap         The predefined key(Tizen::Base::String)-value(Tizen::Base::Boolean) pairs for the package filter @n
302         * For more information on the predefined key-value pairs for package filter,
303         *       see <a href="../org.tizen.native.appprogramming/html/guide/app/packagefilter.htm">the predefined key-value pairs for package filter</a>.
304         * @exception    E_SUCCESS                            The method is successful.
305         * @exception    E_INVALID_ARG                        A specified input parameter is invalid.
306         * @exception    E_SYSTEM                             The method cannot proceed due to a severe system error.
307         * @exception    E_PRIVILEGE_DENIED                   The application does not have the privilege to call this method.
308         * @remarks      The specific error code can be accessed using the GetLastResult() method.
309         */
310         Tizen::Base::Collection::IList* GetPackageInfoListN(const Tizen::Base::Collection::IMap& packageFilterMap) const;
311
312         /**
313         * Gets the application information list with the package app filter.
314         *
315         * @since         2.1
316         * @privlevel     public
317         * @privilege     %http://tizen.org/privilege/package.info
318         *
319         * @return        A pointer to the list of the %PackageAppInfo instances, @n
320         *                else @c null if it fails
321         * @param[in]     packageAppFilterMap      The predefined key(Tizen::Base::String)-value(Tizen::Base::String or Tizen::Base::Boolean) pairs for the package app filter @n
322         * For more information on the predefined key-value pairs for package app filter,
323         *       see <a href="../org.tizen.native.appprogramming/html/guide/app/packageappfilter.htm">the predefined key-value pairs for package app filter</a>.
324         * @exception    E_SUCCESS                            The method is successful.
325         * @exception    E_INVALID_ARG                        A specified input parameter is invalid.
326         * @exception    E_SYSTEM                             The method cannot proceed due to a severe system error.
327         * @exception    E_PRIVILEGE_DENIED                   The application does not have the privilege to call this method.
328         * @remarks      The specific error code can be accessed using the GetLastResult() method.
329         */
330         Tizen::Base::Collection::IList* GetPackageAppInfoListN(const Tizen::Base::Collection::IMap& packageAppFilterMap) const;
331
332         /**
333         * Gets the application information list with the package filter and package app filter.
334         *
335         * @since         2.1
336         * @privlevel     public
337         * @privilege     %http://tizen.org/privilege/package.info
338         *
339         * @return        A pointer to the list of the %PackageAppInfo instances, @n
340         *                              else @c null if it fails
341         * @param[in] packageFilterMap        The predefined key(Tizen::Base::String)-value(Tizen::Base::Boolean) pairs for the package filter @n
342         * @param[in] packageAppFilterMap     The predefined and user defined key(Tizen::Base::String)-value(Tizen::Base::String or Tizen::Base::Boolean) pairs for the package app filter @n
343         *                                    The user defined key-value pairs can be added in <Metadata> of manifest.xml.
344         *
345         * For more information on the predefined key-value pairs for package filter,
346         *              see <a href="../org.tizen.native.appprogramming/html/guide/app/packagefilter.htm">the predefined key-value pairs for package filter</a>.
347         * For more information on the predefined key-value pairs for package app filter,
348         *              see <a href="../org.tizen.native.appprogramming/html/guide/app/packageappfilter.htm">the predefined key-value pairs for package app filter</a>.
349         *
350         * @exception    E_SUCCESS                            The method is successful.
351         * @exception    E_INVALID_ARG                        A specified input parameter is invalid.
352         * @exception    E_SYSTEM                             The method cannot proceed due to a severe system error.
353         * @exception    E_PRIVILEGE_DENIED                   The application does not have the privilege to call this method.
354         * @remarks      The specific error code can be accessed using the GetLastResult() method.
355         */
356         Tizen::Base::Collection::IList* GetPackageAppInfoListN(const Tizen::Base::Collection::IMap& packageFilterMap, const Tizen::Base::Collection::IMap& packageAppFilterMap) const;
357
358         /**
359          * Gets the package manager instance.
360          *
361          * @since       2.0
362          *
363          * @return              A pointer to the %PackageManager instance, @n
364          *                              else @c null
365          * @remarks             The specific error code can be accessed using the GetLastResult() method.
366          */
367         static PackageManager* GetInstance(void);
368
369 private:
370         /**
371          * This default constructor is intentionally declared as private to implement the %Singleton semantic.
372          *
373          * @since       2.0
374          */
375         PackageManager(void);
376
377         /**
378          * This destructor is intentionally declared as private to implement the %Singleton semantic.
379          *
380          * @since       2.0
381          */
382         virtual ~PackageManager(void);
383
384         /**
385          * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
386          *
387          * @since       2.0
388          */
389         PackageManager(const PackageManager& rhs);
390
391         /**
392          * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
393          *
394          * @since       2.0
395          */
396         PackageManager& operator =(const PackageManager& rhs);
397
398 private:
399         class _PackageManagerImpl* __pPackageManagerImpl;
400         friend class _PackageManagerImpl;
401
402 }; // PackageManager
403
404 } } } // Tizen::App::Package
405
406 #endif // _FAPP_PKG_PACKAGE_MANAGER_H_