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 FAppPkg_PackageManagerImpl.h
20 * @brief This is the header file for the _PackageManagerImpl class.
23 #ifndef _FAPP_PKG_INTERNAL_PACKAGE_MANAGER_IMPL_H_
24 #define _FAPP_PKG_INTERNAL_PACKAGE_MANAGER_IMPL_H_
26 #include <package-manager.h>
27 #include <pkgmgr-info.h>
29 #include <FBaseObject.h>
30 #include <FBaseString.h>
31 #include <FAppPkgPackageManager.h>
32 #include <FBaseColHashMapT.h>
33 #include <FBaseColLinkedListT.h>
34 #include <FBaseRt_Event.h>
36 #include <FApp_Types.h>
37 #include <FAppPkg_PackageAppInfoImpl.h>
39 namespace Tizen { namespace Base { namespace Runtime
44 namespace Tizen { namespace Io
51 namespace Tizen { namespace App { namespace Package
54 class _PackageInfoImpl;
55 class IPackageInstallationEventListener;
56 class IPackageInstallationResponseListener;
57 class IPackageUninstallationResponseListener;
59 static const int MAX_DATABASE_RETRY_COUNT = 30;
60 static const wchar_t PACKAGE_DATABASE_FILE_NAME[] = L"/opt/usr/dbspace/.app-package.db";
63 static const wchar_t PACKAGE_FILTER_UNINSTALLABLE[] = L"http://tizen.org/package/uninstallable";
64 static const wchar_t PACKAGE_FILTER_DOWNLOADED[] = L"http://tizen.org/package/downloaded";
65 static const wchar_t PACKAGE_FILTER_EXTERNAL_STORAGE[] = L"http://tizen.org/package/externalstorage";
66 static const wchar_t PACKAGE_FILTER_APP_SETTING[] = L"http://tizen.org/package/appsetting";
69 static const wchar_t PACKAGE_APP_FILTER_MENUICON_VISIBLE[] = L"http://tizen.org/package/app/menuiconvisible";
70 static const wchar_t PACKAGE_APP_FILTER_CATEGORY[] = L"http://tizen.org/package/app/category";
72 enum PackageStorageType
74 PACKAGE_STORAGE_TYPE_INTERNAL,
75 PACKAGE_STORAGE_TYPE_EXTERNAL,
78 class _PackageManagerEventArg
79 : public Tizen::Base::Runtime::IEventArg
82 _PackageManagerEventArg()
87 PackageId __packageId;
88 Tizen::Base::String __eventKey;
89 Tizen::Base::String __eventValue;
93 class _PackageManagerEvent
94 : public Tizen::Base::Runtime::_Event
97 _PackageManagerEvent()
102 IPackageInstallationEventListener* __pListener;
105 result Construct(void)
107 return _Event::Initialize();
111 virtual void FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg);
114 class _OSP_EXPORT_ _PackageManagerImpl
115 : public Tizen::Base::Object
118 static PackageId GetPackageIdByAppId(const AppId& appId);
120 result AddEventListener(IPackageInstallationEventListener* pListener, int priority = 2);
121 result RemoveEventListener(IPackageInstallationEventListener* pListener);
123 PackageInfo* GetPackageInfoN(const PackageId& packageId) const;
124 PackageAppInfo* GetPackageAppInfoN(const AppId& appId) const;
125 Tizen::Base::Collection::IList* GetPackageInfoListN(void) const;
127 bool IsPackageInstalled(const PackageId& packageId) const;
129 result InstallPackage(const PackageId& packageId, const Tizen::Base::String& packagePath, IPackageInstallationResponseListener* pListener);
130 result UninstallPackage(const PackageId& packageId, IPackageUninstallationResponseListener* pListener);
132 result MoveToExternalStorage(const PackageId& packageId);
133 result MoveToInternalStorage(const PackageId& packageId);
135 static _PackageManagerImpl* GetInstance(void);
137 PackageInfo* GetPackageInfoFromFileN(const Tizen::Base::String& filePath) const;
138 Tizen::Base::Collection::IList* GetPackageInfoListN(const Tizen::Base::Collection::IMap& packageFilterMap) const;
139 Tizen::Base::Collection::IList* GetPackageAppInfoListN(const Tizen::Base::Collection::IMap& packageAppFilterMap) const;
140 Tizen::Base::Collection::IList* GetPackageAppInfoListN(const Tizen::Base::Collection::IMap& packageFilterMap, const Tizen::Base::Collection::IMap& packageAppFilterMap) const;
142 static int PackageInfoHandler(const pkgmgrinfo_pkginfo_h handle, void* pUserData);
143 static int PackageAppInfoHandler(const pkgmgrinfo_appinfo_h handle, void* pUserData);
144 static int PackageAppInfoMetadataHandler(const pkgmgrinfo_appinfo_h handle, void* pUserdata);
146 void SendPackageEvent(PackageType type, const PackageId& packageId, const char* eventKey, const char* eventValue);
148 Tizen::Base::String* GetAppIdOfDataControlN(const Tizen::Base::String& providerId);
150 PackageInfo* GetPackageInfoN(const Tizen::Base::String& providerId, const Tizen::Base::String& operationId) const;
151 PackageInfo* GetPackageInfoN(PackageType packageType, const Tizen::Base::String& packageName) const;
153 static int PackageInfoEventHandler(const pkgmgrinfo_pkginfo_h handle, void* pUser_data);
155 Tizen::Base::Collection::IList* GetFilteredAppIdListN(const Tizen::Base::String& feature, const Tizen::Base::String& value) const;
156 Tizen::Base::Collection::IList* GetDataControlInfoN(const Tizen::Base::String& providerId, const Tizen::Base::String& type) const;
157 Tizen::Base::Collection::IMap* GetUiThemeListN(const PackageId& packageId) const;
159 Tizen::Base::Collection::ArrayList* GetPackageAppInfoImplListN(const PackageId& packageId) const;
160 Tizen::Base::Collection::ArrayList* GetPackageAppFeatureListN(const PackageId& packageId, const Tizen::Base::String& executableName) const;
161 Tizen::Base::Collection::HashMapT<Tizen::Base::String, _AppFeatureInfoImpl*>* GetPackageAppFeatureMapN(const PackageId& packageId, const Tizen::Base::String& executableName) const;
162 Tizen::Base::Collection::ArrayList* GetAppLaunchConditionListN(const Tizen::Base::String& packageName) const;
164 result GetPackageName(const PackageId& packageId, const Tizen::Base::String* pName, char* pPackageName, int bufferSize);
165 Tizen::Base::String GetDefaultAppExecutableName(const PackageId& packageId);
167 static bool IsAppInstalled(const AppId& appId);
169 static Tizen::Io::DbStatement* CreateStatementN(Tizen::Io::Database& db, const Tizen::Base::String& query);
170 static Tizen::Io::DbEnumerator* ExecuteStatementN(Tizen::Io::Database& db, const Tizen::Io::DbStatement* pStmt);
173 result Construct(void);
175 _PackageManagerImpl(void);
176 virtual ~_PackageManagerImpl(void);
178 static int PackageEventHandler(int req_id, const char* pkg_type, const char* pkg_name, const char* key, const char* val, const void* pmsg, void* data);
179 static int InstallationEventHandler(int reqId, const char* pType, const char* pPackageId, const char* pKey, const char* pVal, const void* pMsg, void* pData);
180 static int UninstallationEventHandler(int reqId, const char* pType, const char* pPackageId, const char* pKey, const char* pVal, const void* pMsg, void* pData);
183 friend class PackageManager;
186 void* __pRequestClient;
187 void* __pListeningClient;
188 static Tizen::Base::Collection::HashMap __installationList;
189 Tizen::Base::Collection::LinkedListT <_PackageManagerEvent*> __packageEventListenerList;
191 }; // _PackageManagerImpl
193 } } } // Tizen::App::Package
195 #endif // _FAPP_PKG_INTERNAL_PACKAGE_MANAGER_IMPL_H_