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";
68 // PackageFilter(internal)
69 static const wchar_t PACKAGE_FILTER_TPK[] = L"http://tizen.org/package/tpk";
72 static const wchar_t PACKAGE_APP_FILTER_MENUICON_VISIBLE[] = L"http://tizen.org/package/app/menuiconvisible";
73 static const wchar_t PACKAGE_APP_FILTER_CATEGORY_HOMEAPP[] = L"http://tizen.org/category/homeapp";
74 static const wchar_t PACKAGE_APP_FILTER_CATEGORY_LOCKAPP[] = L"http://tizen.org/category/lockapp";
75 static const wchar_t PACKAGE_APP_FILTER_CATEGORY_MENUAPP[] = L"http://tizen.org/category/menuapp";
77 enum PackageStorageType
79 PACKAGE_STORAGE_TYPE_INTERNAL,
80 PACKAGE_STORAGE_TYPE_EXTERNAL,
83 class _PackageManagerEventArg
84 : public Tizen::Base::Runtime::IEventArg
87 _PackageManagerEventArg()
92 PackageId __packageId;
93 Tizen::Base::String __eventKey;
94 Tizen::Base::String __eventValue;
98 class _PackageManagerEvent
99 : public Tizen::Base::Runtime::_Event
102 _PackageManagerEvent()
107 IPackageInstallationEventListener* __pListener;
110 result Construct(void)
112 return _Event::Initialize();
116 virtual void FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg);
119 class _OSP_EXPORT_ _PackageManagerImpl
120 : public Tizen::Base::Object
123 static PackageId GetPackageIdByAppId(const AppId& appId);
125 result AddEventListener(IPackageInstallationEventListener* pListener, int priority = 2);
126 result RemoveEventListener(IPackageInstallationEventListener* pListener);
128 PackageInfo* GetPackageInfoN(const PackageId& packageId) const;
129 PackageAppInfo* GetPackageAppInfoN(const AppId& appId) const;
130 Tizen::Base::Collection::IList* GetPackageInfoListN(void) const;
132 bool IsPackageInstalled(const PackageId& packageId) const;
134 result InstallPackage(const PackageId& packageId, const Tizen::Base::String& packagePath, IPackageInstallationResponseListener* pListener);
135 result UninstallPackage(const PackageId& packageId, IPackageUninstallationResponseListener* pListener);
137 result MoveToExternalStorage(const PackageId& packageId);
138 result MoveToInternalStorage(const PackageId& packageId);
140 static _PackageManagerImpl* GetInstance(void);
142 PackageInfo* GetPackageInfoFromFileN(const Tizen::Base::String& filePath) const;
143 Tizen::Base::Collection::IList* GetPackageInfoListN(const Tizen::Base::Collection::IMap& packageFilterMap) const;
144 Tizen::Base::Collection::IList* GetPackageAppInfoListN(const Tizen::Base::Collection::IMap& packageAppFilterMap) const;
145 Tizen::Base::Collection::IList* GetPackageAppInfoListN(const Tizen::Base::Collection::IMap& packageFilterMap, const Tizen::Base::Collection::IMap& packageAppFilterMap) const;
147 static int PackageInfoHandler(const pkgmgrinfo_pkginfo_h handle, void* pUserData);
148 static int PackageAppInfoHandler(const pkgmgrinfo_appinfo_h handle, void* pUserData);
149 static int PackageAppInfoMetadataHandler(const pkgmgrinfo_appinfo_h handle, void* pUserdata);
151 void SendPackageEvent(PackageType type, const PackageId& packageId, const char* eventKey, const char* eventValue);
153 Tizen::Base::String* GetAppIdOfDataControlN(const Tizen::Base::String& providerId);
155 PackageInfo* GetPackageInfoN(const Tizen::Base::String& providerId, const Tizen::Base::String& operationId) const;
156 PackageInfo* GetPackageInfoN(PackageType packageType, const Tizen::Base::String& packageName) const;
158 static int PackageInfoEventHandler(const pkgmgrinfo_pkginfo_h handle, void* pUser_data);
160 Tizen::Base::Collection::IList* GetFilteredAppIdListN(const Tizen::Base::String& feature, const Tizen::Base::String& value) const;
161 Tizen::Base::Collection::IList* GetDataControlInfoN(const Tizen::Base::String& providerId, const Tizen::Base::String& type) const;
162 Tizen::Base::Collection::IMap* GetUiThemeListN(const PackageId& packageId) const;
164 Tizen::Base::Collection::ArrayList* GetPackageAppInfoImplListN(const PackageId& packageId) const;
165 Tizen::Base::Collection::ArrayList* GetPackageAppFeatureListN(const PackageId& packageId, const Tizen::Base::String& executableName) const;
166 Tizen::Base::Collection::HashMapT<Tizen::Base::String, _AppFeatureInfoImpl*>* GetPackageAppFeatureMapN(const PackageId& packageId, const Tizen::Base::String& executableName) const;
167 Tizen::Base::Collection::ArrayList* GetAppLaunchConditionListN(const Tizen::Base::String& packageName) const;
169 result GetPackageName(const PackageId& packageId, const Tizen::Base::String* pName, char* pPackageName, int bufferSize);
170 Tizen::Base::String GetDefaultAppExecutableName(const PackageId& packageId);
172 static bool IsAppInstalled(const AppId& appId);
174 static Tizen::Io::DbStatement* CreateStatementN(Tizen::Io::Database& db, const Tizen::Base::String& query);
175 static Tizen::Io::DbEnumerator* ExecuteStatementN(Tizen::Io::Database& db, const Tizen::Io::DbStatement* pStmt);
178 result Construct(void);
180 _PackageManagerImpl(void);
181 virtual ~_PackageManagerImpl(void);
183 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);
184 static int InstallationEventHandler(int reqId, const char* pType, const char* pPackageId, const char* pKey, const char* pVal, const void* pMsg, void* pData);
185 static int UninstallationEventHandler(int reqId, const char* pType, const char* pPackageId, const char* pKey, const char* pVal, const void* pMsg, void* pData);
188 friend class PackageManager;
191 void* __pRequestClient;
192 void* __pListeningClient;
193 static Tizen::Base::Collection::HashMap __installationList;
194 Tizen::Base::Collection::LinkedListT <_PackageManagerEvent*> __packageEventListenerList;
196 }; // _PackageManagerImpl
198 } } } // Tizen::App::Package
200 #endif // _FAPP_PKG_INTERNAL_PACKAGE_MANAGER_IMPL_H_