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>
25 #include <dpl/singleton.h>
27 #include <app_manager.h>
28 #include <package-manager.h>
29 #include <package_manager.h>
30 #include <package_info.h>
32 #include "ApplicationInformation.h"
34 // To get app size and installed time
35 #include <pkgmgr-info.h>
38 namespace Application {
41 class IAppManagerAppListChangedCallbacks
44 friend class AppManagerWrapper;
46 IAppManagerAppListChangedCallbacks() {}
47 ~IAppManagerAppListChangedCallbacks() {}
50 virtual void onAppManagerEventInstalled(const char *appId) = 0;
51 virtual void onAppManagerEventUninstalled(const char *appId) = 0;
52 virtual void onAppManagerEventUpdated(const char *appId) = 0;
55 class AppManagerWrapper
59 virtual ~AppManagerWrapper();
61 // Can throw InvalidArgumentException or PlatformException
62 void registerAppListChangedCallbacks(IAppManagerAppListChangedCallbacks *callbacks);
65 void unregisterAppListChangedCallbacks(IAppManagerAppListChangedCallbacks *callbacks);
67 long getWatchIdAndInc();
69 bool initializeAppInfo(ApplicationInformationPtr &appInfo);
73 static bool app_callback(package_info_app_component_type_e comp_type, const char *app_id, void *user_data);
75 // callback for app_manager_set_app_list_changed_cb
76 static void appListChangedCallback(app_manger_event_type_e event_type,
80 void appListChangedCallback(app_manger_event_type_e event_type,
83 void appListAppInstalled(const char *appId);
84 void appListAppUninstalled(const char *appId);
85 void appListAppUpdated(const char *appId);
87 void registerAppListChangedCallbacks();
88 void unregisterAppListChangedCallbacks();
90 typedef std::set<IAppManagerAppListChangedCallbacks *> AppListChangedCallbacksSet;
91 AppListChangedCallbacksSet m_callbacks;
92 bool m_registeredCallback;
97 friend class DPL::Singleton<AppManagerWrapper>;
100 typedef DPL::Singleton<AppManagerWrapper> AppManagerWrapperSingleton;
105 #endif // TIZENAPIS_PLATFORM_APPLICATION_APP_MANAGER_WRAPPER_H_