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 TIZENAPIS_PLATFORM_APPLICATION_APP_MANAGER_WRAPPER_H_
19 #define TIZENAPIS_PLATFORM_APPLICATION_APP_MANAGER_WRAPPER_H_
24 #include <dpl/shared_ptr.h>
26 #include <app_manager.h>
27 #include <package-manager.h>
28 #include <package_manager.h>
29 #include <package_info.h>
31 #include "ApplicationInformation.h"
33 // To get app size and installed time
34 #include <pkgmgr-info.h>
36 #include <Singleton.h>
39 namespace Application {
42 class IAppManagerAppListChangedCallbacks
45 friend class AppManagerWrapper;
47 IAppManagerAppListChangedCallbacks() {}
48 ~IAppManagerAppListChangedCallbacks() {}
51 virtual void onAppManagerEventInstalled(const char *appId) = 0;
52 virtual void onAppManagerEventUninstalled(const char *appId) = 0;
53 virtual void onAppManagerEventUpdated(const char *appId) = 0;
56 class DLL_EXPORT AppManagerWrapper
60 virtual ~AppManagerWrapper();
62 // Can throw InvalidArgumentException or PlatformException
63 void registerAppListChangedCallbacks(IAppManagerAppListChangedCallbacks *callbacks);
66 void unregisterAppListChangedCallbacks(IAppManagerAppListChangedCallbacks *callbacks);
68 long getWatchIdAndInc();
70 bool initializeAppInfo(ApplicationInformationPtr &appInfo);
72 // get the current application id from WRT
73 void setCurrentAppId(std::string appId);
74 std::string getCurrentAppId() const;
78 static bool app_callback(package_info_app_component_type_e comp_type, const char *app_id, void *user_data);
79 void appListChangedCallback(app_manger_event_type_e event_type, const char *pkgId, void *user_data);
80 static int app_list_changed_cb_broker(int id, const char *type, const char *package, const char *key, const char *val, const void *msg, void *data);
82 void appListAppInstalled(const char *appId);
83 void appListAppUninstalled(const char *appId);
84 void appListAppUpdated(const char *appId);
86 void registerAppListChangedCallbacks();
87 void unregisterAppListChangedCallbacks();
89 typedef std::set<IAppManagerAppListChangedCallbacks *> AppListChangedCallbacksSet;
90 AppListChangedCallbacksSet m_callbacks;
91 pkgmgr_client *m_manager_handle;
93 std::string m_curr_app_id;
96 std::vector<std::string> applist;
99 friend class AppManagerWrapperSingleton;
102 SINGLETON_DEFINITION(AppManagerWrapper)
108 #endif // TIZENAPIS_PLATFORM_APPLICATION_APP_MANAGER_WRAPPER_H_