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;
43 * Defines the package types.
49 PACKAGE_TYPE_TPK, /**< TIZEN Native package */
50 PACKAGE_TYPE_WGT, /**< TIZEN %Web package */
51 PACKAGE_TYPE_RPM, /**< TIZEN Core package */
55 * @class PackageManager
56 * @brief This class gets the information of packages and manages package installation or uninstallation.
60 * @final This class is not intended for extension.
62 * The %PackageManager class provides methods to install or uninstall the packages, retrieves the information of the packages that are installed on the device.
64 * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/app/package_namespace.htm">Package Management</a>.
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.
90 * @privilege %http://tizen.org/privilege/package.info
92 * @return An error code
93 * @param[in] listener The package installation event listener
94 * @exception E_SUCCESS The method is successful.
95 * @exception E_OBJ_ALREADY_EXIST The listener is already added.
96 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
98 result AddPackageInstallationEventListener(IPackageInstallationEventListener& listener);
101 * Removes a package installation event listener.
105 * @privilege %http://tizen.org/privilege/package.info
107 * @return An error code
108 * @param[in] listener The package installation event listener
109 * @exception E_SUCCESS The method is successful.
110 * @exception E_OBJ_NOT_FOUND The listener is not added or is already removed.
111 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
113 result RemovePackageInstallationEventListener(IPackageInstallationEventListener& listener);
116 * Gets a package information with the specific package ID.
120 * @privilege %http://tizen.org/privilege/package.info
122 * @return A pointer to PackageInfo
123 * @param[in] packageId The package ID
124 * @exception E_SUCCESS The method is successful.
125 * @exception E_INVALID_ARG The specified input parameter is invalid.
126 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
127 * @exception E_PKG_NOT_INSTALLED The package is not installed.
128 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
129 * @remarks The specific error code can be accessed using the GetLastResult() method.
131 PackageInfo* GetPackageInfoN(const PackageId& packageId) const;
134 * Gets the application information with the specific application ID.
138 * @privilege %http://tizen.org/privilege/package.info
140 * @return A pointer to PackageAppInfo
141 * @param[in] appId The application ID
142 * @exception E_SUCCESS The method is successful.
143 * @exception E_INVALID_ARG The specified input parameter is invalid.
144 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
145 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
146 * @remarks The specific error code can be accessed using the GetLastResult() method.
148 PackageAppInfo* GetPackageAppInfoN(const AppId& appId) const;
151 * Gets the package information list.
155 * @privilege %http://tizen.org/privilege/package.info
157 * @return A pointer to the list of the PackageInfo instances, @n
158 * else @c null if it fails
159 * @exception E_SUCCESS The method is successful.
160 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
161 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
162 * @remarks The specific error code can be accessed using the GetLastResult() method.
164 Tizen::Base::Collection::IList* GetPackageInfoListN(void) const;
167 * Checks whether a package is installed.
171 * @privilege %http://tizen.org/privilege/package.info
173 * @return @c true if a package is installed, @n
175 * @param[in] packageId The package ID
176 * @exception E_SUCCESS The method is successful.
177 * @exception E_INVALID_ARG The specified input parameter is invalid.
178 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
179 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
180 * @remarks The specific error code can be accessed using the GetLastResult() method.
182 bool IsPackageInstalled(const PackageId& packageId) const;
185 * Installs a package. @n
186 * 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.
189 * @privlevel platform
190 * @privilege %http://tizen.org/privilege/packagemanager.install
192 * @return An error code
193 * @param[in] packageId The package ID
194 * @param[in] packagePath The package path
195 * @param[in] pListener The response listener
196 * @exception E_SUCCESS The method is successful.
197 * @exception E_INVALID_ARG A specified input parameter is invalid.
198 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
199 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
200 * @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.
201 * @see IPackageInstallationResponseListener
203 result InstallPackage(const PackageId& packageId, const Tizen::Base::String& packagePath, IPackageInstallationResponseListener* pListener);
206 * Uninstalls a package with the specified package ID. @n
207 * 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.
210 * @privlevel platform
211 * @privilege %http://tizen.org/privilege/packagemanager.install
213 * @return An error code
214 * @param[in] packageId The package ID
215 * @param[in] pListener The response listener
216 * @exception E_SUCCESS The method is successful.
217 * @exception E_INVALID_ARG A specified input parameter is invalid.
218 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
219 * @exception E_PKG_NOT_INSTALLED The package is not installed.
220 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
221 * @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.
222 * @see IPackageUninstallationResponseListener
224 result UninstallPackage(const PackageId& packageId, IPackageUninstallationResponseListener* pListener);
227 * Moves a package with the specified package ID to an external storage.
230 * @privlevel platform
231 * @privilege %http://tizen.org/privilege/packagemanager.setting
233 * @return An error code
234 * @param[in] packageId The package ID
235 * @exception E_SUCCESS The method is successful.
236 * @exception E_INVALID_ARG The specified input parameter is invalid.
237 * @exception E_INVALID_OPERATION The package is already installed in an external storage.
238 * @exception E_STORAGE_FULL The storage is full.
239 * @exception E_PKG_NOT_INSTALLED The package is not installed.
240 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
241 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
243 result MoveToExternalStorage(const PackageId& packageId);
246 * Moves a package with the specified package ID to an internal storage.
249 * @privlevel platform
250 * @privilege %http://tizen.org/privilege/packagemanager.setting
252 * @return An error code
253 * @param[in] packageId The package ID
254 * @exception E_SUCCESS The method is successful.
255 * @exception E_INVALID_ARG The specified input parameter is invalid.
256 * @exception E_INVALID_OPERATION The package is already installed in an internal storage.
257 * @exception E_STORAGE_FULL The storage is full.
258 * @exception E_PKG_NOT_INSTALLED The package is not installed.
259 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
260 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
262 result MoveToInternalStorage(const PackageId& packageId);
265 * Gets a package information from the specific file. The supported file extensions are tpk and wgt.
268 * @privlevel platform
269 * @privilege %http://tizen.org/privilege/packagemanager.info
271 * @return A pointer to the %PackageInfo instance, @n
272 * else @c null if it fails
273 * @param[in] filePath The package file path
274 * @exception E_SUCCESS The method is successful.
275 * @exception E_INVALID_ARG A specified input parameter is invalid.
276 * @exception E_FILE_NOT_FOUND The specified file cannot be found or accessed.
277 * @exception E_UNSUPPORTED_FORMAT The specified format is invalid or not supported.
278 * @exception E_PARSING_FAILED The method has failed to parse the package file or xml file(s) inside the package.
279 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
280 * @remarks The specific error code can be accessed using the GetLastResult() method.
282 PackageInfo* GetPackageInfoFromFileN(const Tizen::Base::String& filePath) const;
285 * Gets the package information list with the package filter.
289 * @privilege %http://tizen.org/privilege/package.info
291 * @return A pointer to the list of the %PackageInfo instances, @n
292 * else @c null if it fails
293 * @param[in] packageFilterMap The predefined key(Tizen::Base::String)-value(Tizen::Base::Boolean) pairs for the package filter @n
294 * For more information on the predefined key-value pairs for package filter,
295 * see <a href="../org.tizen.native.appprogramming/html/guide/app/packagefilter.htm">the predefined key-value pairs for package filter</a>.
296 * @exception E_SUCCESS The method is successful.
297 * @exception E_INVALID_ARG A specified input parameter is invalid.
298 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
299 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
300 * @remarks The specific error code can be accessed using the GetLastResult() method.
302 Tizen::Base::Collection::IList* GetPackageInfoListN(const Tizen::Base::Collection::IMap& packageFilterMap) const;
305 * Gets the application information list with the package app filter.
309 * @privilege %http://tizen.org/privilege/package.info
311 * @return A pointer to the list of the %PackageAppInfo instances, @n
312 * else @c null if it fails
313 * @param[in] packageAppFilterMap The predefined key(Tizen::Base::String)-value(Tizen::Base::String or Tizen::Base::Boolean) pairs for the package app filter @n
314 * For more information on the predefined key-value pairs for package app filter,
315 * see <a href="../org.tizen.native.appprogramming/html/guide/app/packageappfilter.htm">the predefined key-value pairs for package app filter</a>.
316 * @exception E_SUCCESS The method is successful.
317 * @exception E_INVALID_ARG A specified input parameter is invalid.
318 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
319 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
320 * @remarks The specific error code can be accessed using the GetLastResult() method.
322 Tizen::Base::Collection::IList* GetPackageAppInfoListN(const Tizen::Base::Collection::IMap& packageAppFilterMap) const;
325 * Gets the application information list with the package filter and package app filter.
329 * @privilege %http://tizen.org/privilege/package.info
331 * @return A pointer to the list of the %PackageAppInfo instances, @n
332 * else @c null if it fails
333 * @param[in] packageFilterMap The predefined key(Tizen::Base::String)-value(Tizen::Base::Boolean) pairs for the package filter @n
334 * @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
335 * The user defined key-value pairs can be added in <Metadata> of manifest.xml.
337 * For more information on the predefined key-value pairs for package filter,
338 * see <a href="../org.tizen.native.appprogramming/html/guide/app/packagefilter.htm">the predefined key-value pairs for package filter</a>.
339 * For more information on the predefined key-value pairs for package app filter,
340 * see <a href="../org.tizen.native.appprogramming/html/guide/app/packageappfilter.htm">the predefined key-value pairs for package app filter</a>.
342 * @exception E_SUCCESS The method is successful.
343 * @exception E_INVALID_ARG A specified input parameter is invalid.
344 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
345 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
346 * @remarks The specific error code can be accessed using the GetLastResult() method.
348 Tizen::Base::Collection::IList* GetPackageAppInfoListN(const Tizen::Base::Collection::IMap& packageFilterMap, const Tizen::Base::Collection::IMap& packageAppFilterMap) const;
351 * Gets the package manager instance.
355 * @return A pointer to the %PackageManager instance, @n
357 * @remarks The specific error code can be accessed using the GetLastResult() method.
359 static PackageManager* GetInstance(void);
363 * This default constructor is intentionally declared as private to implement the %Singleton semantic.
367 PackageManager(void);
370 * This destructor is intentionally declared as private to implement the %Singleton semantic.
374 virtual ~PackageManager(void);
377 * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
381 PackageManager(const PackageManager& rhs);
384 * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
388 PackageManager& operator =(const PackageManager& rhs);
391 class _PackageManagerImpl* __pPackageManagerImpl;
392 friend class _PackageManagerImpl;
396 } } } // Tizen::App::Package
398 #endif // _FAPP_PKG_PACKAGE_MANAGER_H_