2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
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
9 // http://www.apache.org/licenses/LICENSE-2.0
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.
19 * @file FAppPkgPackageManager.h
20 * @brief This is the header file for the %PackageManager class.
22 * This header file contains the declarations of the %PackageManager class.
25 #ifndef _FAPP_PKG_PACKAGE_MANAGER_H_
26 #define _FAPP_PKG_PACKAGE_MANAGER_H_
29 #include <FAppTypes.h>
31 namespace Tizen { namespace App { namespace Package
36 class IPackageInstallationEventListener;
37 class IPackageInstallationResponseListener;
38 class IPackageUninstallationResponseListener;
41 * @if VISPARTNER-MANUFACTURER
44 * Defines the package types.
47 * @visibility partner-manufacturer
52 PACKAGE_TYPE_TPK, /**< TIZEN Native package */
53 PACKAGE_TYPE_WGT, /**< TIZEN %Web package */
54 PACKAGE_TYPE_RPM, /**< TIZEN Core package */
58 * @class PackageManager
59 * @brief This class gets the information of packages and manages package installation or uninstallation.
63 * @final This class is not intended for extension.
65 * The %PackageManager class provides methods to install or uninstall the packages, retrieves the information of the packages that are installed on the device.
67 class _OSP_EXPORT_ PackageManager
68 : public Tizen::Base::Object
72 * Gets the package ID from the application ID.
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.
83 static PackageId GetPackageIdByAppId(const AppId& appId);
86 * Adds a package installation event listener.
89 * @privilege %http://tizen.org/privilege/packageinfo
91 * @return An error code
92 * @param[in] listener The package installation event listener
93 * @exception E_SUCCESS The method is successful.
94 * @exception E_OBJ_ALREADY_EXIST The listener is already added.
95 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
97 result AddPackageInstallationEventListener(IPackageInstallationEventListener& listener);
100 * Removes a package installation event listener.
103 * @privilege %http://tizen.org/privilege/packageinfo
105 * @return An error code
106 * @param[in] listener The package installation event listener
107 * @exception E_SUCCESS The method is successful.
108 * @exception E_OBJ_NOT_FOUND The listener is not added or is already removed.
109 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
111 result RemovePackageInstallationEventListener(IPackageInstallationEventListener& listener);
114 * Gets a package information with the specific package ID.
117 * @privilege %http://tizen.org/privilege/packageinfo
119 * @return A pointer to PackageInfo
120 * @param[in] packageId The package ID
121 * @exception E_SUCCESS The method is successful.
122 * @exception E_INVALID_ARG The specified input parameter is invalid.
123 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
124 * @exception E_PKG_NOT_INSTALLED The package is not installed.
125 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
126 * @remarks The specific error code can be accessed using the GetLastResult() method.
128 Tizen::App::Package::PackageInfo* GetPackageInfoN(const PackageId& packageId) const;
131 * Gets the application information with the specific application ID.
134 * @privilege %http://tizen.org/privilege/packageinfo
136 * @return A pointer to PackageAppInfo
137 * @param[in] appId The application ID
138 * @exception E_SUCCESS The method is successful.
139 * @exception E_INVALID_ARG The specified input parameter is invalid.
140 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
141 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
142 * @remarks The specific error code can be accessed using the GetLastResult() method.
144 Tizen::App::Package::PackageAppInfo* GetPackageAppInfoN(const AppId& appId) const;
147 * Gets the package information list.
150 * @privilege %http://tizen.org/privilege/packageinfo
152 * @return A pointer to the list of the PackageInfo instances, @n
153 * else @c null if it fails
154 * @exception E_SUCCESS The method is successful.
155 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
156 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
157 * @remarks The specific error code can be accessed using the GetLastResult() method.
159 Tizen::Base::Collection::IList* GetPackageInfoListN(void) const;
162 * Checks whether a package is installed.
165 * @privilege %http://tizen.org/privilege/packageinfo
167 * @return @c true if a package is installed, @n
169 * @param[in] packageId The package ID
170 * @exception E_SUCCESS The method is successful.
171 * @exception E_INVALID_ARG The specified input parameter is invalid.
172 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
173 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
174 * @remarks The specific error code can be accessed using the GetLastResult() method.
176 bool IsPackageInstalled(const PackageId& packageId) const;
179 * @if VISPARTNER-OPERATOR
180 * Installs a package. @n
181 * 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.
184 * @visibility partner-operator
185 * @privilege %http://tizen.org/privilege/packagemanager.install
187 * @return An error code
188 * @param[in] packageId The package ID
189 * @param[in] packagePath The package path
190 * @param[in] pListener The response listener
191 * @exception E_SUCCESS The method is successful.
192 * @exception E_INVALID_ARG A specified input parameter is invalid.
193 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
194 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
195 * @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.
196 * @see IPackageInstallationResponseListener
199 result InstallPackage(const PackageId& packageId, const Tizen::Base::String& packagePath, IPackageInstallationResponseListener* pListener);
202 * @if VISPARTNER-OPERATOR
203 * Uninstalls a package with the specified package ID. @n
204 * 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.
207 * @visibility partner-operator
208 * @privilege %http://tizen.org/privilege/packagemanager.install
210 * @return An error code
211 * @param[in] packageId The package ID
212 * @param[in] pListener The response listener
213 * @exception E_SUCCESS The method is successful.
214 * @exception E_INVALID_ARG A specified input parameter is invalid.
215 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
216 * @exception E_PKG_NOT_INSTALLED The package is not installed.
217 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
218 * @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.
219 * @see IPackageUninstallationResponseListener
222 result UninstallPackage(const PackageId& packageId, IPackageUninstallationResponseListener* pListener);
225 * @if VISPARTNER-MANUFACTURER
226 * Moves a package with the specified package ID to an external storage.
229 * @visibility partner-manufacturer
230 * @privilege %http://tizen.org/privilege/packagesetting
232 * @return An error code
233 * @param[in] packageId The package ID
234 * @exception E_SUCCESS The method is successful.
235 * @exception E_INVALID_ARG The specified input parameter is invalid.
236 * @exception E_INVALID_OPERATION The package is already installed in an external storage.
237 * @exception E_STORAGE_FULL The storage is full.
238 * @exception E_PKG_NOT_INSTALLED The package is not installed.
239 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
240 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
243 result MoveToExternalStorage(const PackageId& packageId);
246 * @if VISPARTNER-MANUFACTURER
247 * Moves a package with the specified package ID to an internal storage.
250 * @visibility partner-manufacturer
251 * @privilege %http://tizen.org/privilege/packagesetting
253 * @return An error code
254 * @param[in] packageId The package ID
255 * @exception E_SUCCESS The method is successful.
256 * @exception E_INVALID_ARG The specified input parameter is invalid.
257 * @exception E_INVALID_OPERATION The package is already installed in an internal storage.
258 * @exception E_STORAGE_FULL The storage is full.
259 * @exception E_PKG_NOT_INSTALLED The package is not installed.
260 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
261 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
264 result MoveToInternalStorage(const PackageId& packageId);
267 * Gets the package manager instance.
271 * @return A pointer to the %PackageManager instance, @n
273 * @remarks The specific error code can be accessed using the GetLastResult() method.
275 static PackageManager* GetInstance(void);
279 * This default constructor is intentionally declared as private to implement the %Singleton semantic.
283 PackageManager(void);
286 * This destructor is intentionally declared as private to implement the %Singleton semantic.
290 virtual ~PackageManager(void);
293 * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
297 PackageManager(const PackageManager& rhs);
300 * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
304 PackageManager& operator =(const PackageManager& rhs);
307 class _PackageManagerImpl* __pPackageManagerImpl;
308 friend class _PackageManagerImpl;
312 } } } // Tizen::App::Package
314 #endif // _FAPP_PKG_PACKAGE_MANAGER_H_