2 // Tizen Web Device API
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.
18 #ifndef _TIZEN_PACKAGE_MANAGER_H_
19 #define _TIZEN_PACKAGE_MANAGER_H_
23 #include <CallbackUserData.h>
24 #include <CommonsJavaScript/Converter.h>
25 #include <JavaScriptCore/JavaScript.h>
26 #include <Commons/Exception.h>
28 #include <package_manager.h>
29 #include <package-manager.h>
31 #include "PackageInformation.h"
36 using namespace WrtDeviceApis::Commons;
37 using namespace DeviceAPI::Common;
40 class PackageInfoCallbackData : public CallbackUserData
43 PackageInfoCallbackData(JSContextRef globalCtx);
44 ~PackageInfoCallbackData();
46 vector<PackageInformation> getPackageInfoList();
47 void addPackageInfo(PackageInformation pkgInfo);
49 void setExceptionCode(ExceptionCodes::Enumeration exceptionCode);
50 ExceptionCodes::Enumeration getExceptionCode() const;
53 vector<PackageInformation> m_pkgInfos;
54 ExceptionCodes::Enumeration m_exceptionCode;
58 class PackageInfoEventCallback
61 PackageInfoEventCallback(CallbackUserData* oninstalled, CallbackUserData* onupdated, CallbackUserData* onuninstalled);
62 ~PackageInfoEventCallback();
63 CallbackUserData* getOnInstalled();
64 CallbackUserData* getOnUpdated();
65 CallbackUserData* getOnUninstalled();
66 pkgmgr_client ** getEventHandler();
67 void setEventHandler(pkgmgr_client **handle_p);
70 CallbackUserData* m_oninstalled;
71 CallbackUserData* m_onupdated;
72 CallbackUserData* m_onuninstalled;
73 pkgmgr_client **m_handle_p;
76 class PackageInstallEventCallback
79 PackageInstallEventCallback(JSContextRef globalCtx, CallbackUserData* onprogress, CallbackUserData* oncomplete, CallbackUserData* onerror);
80 ~PackageInstallEventCallback();
81 CallbackUserData* getOnProgress();
82 CallbackUserData* getOnComplete();
83 CallbackUserData* getOnError();
84 JSContextRef getContext();
85 void setHandle(package_manager_request_h handle);
86 package_manager_request_h getHandle();
89 CallbackUserData* m_onprogress;
90 CallbackUserData* m_oncomplete;
91 CallbackUserData* m_onerror;
92 package_manager_request_h m_request_handle;
93 JSContextRef m_context;
100 enum InstalledStorageType
106 void install(string pkgPath, PackageInstallEventCallback* callback);
107 void uninstall(string pkgPath, PackageInstallEventCallback* callback);
108 void move(string pkgPath, string type, PackageInstallEventCallback* callback);
110 bool isInstalled(string pkgId);
111 PackageInformation* getPackageInfo(string pkgId);
112 void getPackagesInfo(PackageInfoCallbackData *user_data);
113 string getPackageIdFromAppId(string appId);
114 void setPackageInfoEventListener(PackageInfoEventCallback * eventCB);
115 void unsetPackageInfoEventListener();
117 static PackageManager* getInstance();
122 pkgmgr_client *m_manager_handle;