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 @n
91 * (%http://tizen.org/privilege/packageinfo is deprecated.)
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.
99 result AddPackageInstallationEventListener(IPackageInstallationEventListener& listener);
102 * Removes a package installation event listener.
106 * @privilege %http://tizen.org/privilege/package.info @n
107 * (%http://tizen.org/privilege/packageinfo is deprecated.)
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.
115 result RemovePackageInstallationEventListener(IPackageInstallationEventListener& listener);
118 * Gets a package information with the specific package ID.
122 * @privilege %http://tizen.org/privilege/package.info @n
123 * (%http://tizen.org/privilege/packageinfo is deprecated.)
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.
134 PackageInfo* GetPackageInfoN(const PackageId& packageId) const;
137 * Gets the application information with the specific application ID.
141 * @privilege %http://tizen.org/privilege/package.info @n
142 * (%http://tizen.org/privilege/packageinfo is deprecated.)
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.
152 PackageAppInfo* GetPackageAppInfoN(const AppId& appId) const;
155 * Gets the package information list.
159 * @privilege %http://tizen.org/privilege/package.info @n
160 * (%http://tizen.org/privilege/packageinfo is deprecated.)
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.
169 Tizen::Base::Collection::IList* GetPackageInfoListN(void) const;
172 * Checks whether a package is installed.
176 * @privilege %http://tizen.org/privilege/package.info @n
177 * (%http://tizen.org/privilege/packageinfo is deprecated.)
179 * @return @c true if a package is installed, @n
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.
188 bool IsPackageInstalled(const PackageId& packageId) const;
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.
195 * @privlevel platform
196 * @privilege %http://tizen.org/privilege/packagemanager.install
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
209 result InstallPackage(const PackageId& packageId, const Tizen::Base::String& packagePath, IPackageInstallationResponseListener* pListener);
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.
216 * @privlevel platform
217 * @privilege %http://tizen.org/privilege/packagemanager.install
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
230 result UninstallPackage(const PackageId& packageId, IPackageUninstallationResponseListener* pListener);
233 * Moves a package with the specified package ID to an external storage.
236 * @privlevel platform
237 * @privilege %http://tizen.org/privilege/packagemanager.setting @n
238 * (%http://tizen.org/privilege/packagesetting is deprecated.)
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.
250 result MoveToExternalStorage(const PackageId& packageId);
253 * Moves a package with the specified package ID to an internal storage.
256 * @privlevel platform
257 * @privilege %http://tizen.org/privilege/packagemanager.setting @n
258 * (%http://tizen.org/privilege/packagesetting is deprecated.)
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.
270 result MoveToInternalStorage(const PackageId& packageId);
273 * Gets a package information from the specific file. The supported file extensions are tpk and wgt.
276 * @privlevel platform
277 * @privilege %http://tizen.org/privilege/packagemanager.info
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.
290 PackageInfo* GetPackageInfoFromFileN(const Tizen::Base::String& filePath) const;
293 * Gets the package information list with the package filter.
297 * @privilege %http://tizen.org/privilege/package.info
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.
310 Tizen::Base::Collection::IList* GetPackageInfoListN(const Tizen::Base::Collection::IMap& packageFilterMap) const;
313 * Gets the application information list with the package app filter.
317 * @privilege %http://tizen.org/privilege/package.info
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.
330 Tizen::Base::Collection::IList* GetPackageAppInfoListN(const Tizen::Base::Collection::IMap& packageAppFilterMap) const;
333 * Gets the application information list with the package filter and package app filter.
337 * @privilege %http://tizen.org/privilege/package.info
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.
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>.
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.
356 Tizen::Base::Collection::IList* GetPackageAppInfoListN(const Tizen::Base::Collection::IMap& packageFilterMap, const Tizen::Base::Collection::IMap& packageAppFilterMap) const;
359 * Gets the package manager instance.
363 * @return A pointer to the %PackageManager instance, @n
365 * @remarks The specific error code can be accessed using the GetLastResult() method.
367 static PackageManager* GetInstance(void);
371 * This default constructor is intentionally declared as private to implement the %Singleton semantic.
375 PackageManager(void);
378 * This destructor is intentionally declared as private to implement the %Singleton semantic.
382 virtual ~PackageManager(void);
385 * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
389 PackageManager(const PackageManager& rhs);
392 * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
396 PackageManager& operator =(const PackageManager& rhs);
399 class _PackageManagerImpl* __pPackageManagerImpl;
400 friend class _PackageManagerImpl;
404 } } } // Tizen::App::Package
406 #endif // _FAPP_PKG_PACKAGE_MANAGER_H_