Update change log and spec for wrt-plugins-tizen_0.4.9
[platform/framework/web/wrt-plugins-tizen.git] / src / Application / AppManagerWrapper.h
1 //
2 // Tizen Web Device API
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
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
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
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.
16 //
17
18 #ifndef TIZENAPIS_PLATFORM_APPLICATION_APP_MANAGER_WRAPPER_H_
19 #define TIZENAPIS_PLATFORM_APPLICATION_APP_MANAGER_WRAPPER_H_
20
21 #include <string>
22 #include <map>
23 #include <set>
24 #include <dpl/shared_ptr.h>
25 #include <dpl/singleton.h>
26
27 #include <app_manager.h>
28 #include <package-manager.h>
29 #include "ApplicationInformation.h"
30
31 // To get app size and installed time
32 #include <pkgmgr-info.h>
33
34 namespace DeviceAPI {
35 namespace Application {
36
37
38 class IAppManagerAppListChangedCallbacks
39 {
40 public:
41     friend class AppManagerWrapper;
42
43         IAppManagerAppListChangedCallbacks() {}
44         ~IAppManagerAppListChangedCallbacks() {}
45
46 protected:
47         virtual void onAppManagerEventInstalled(const char *appId) = 0;
48         virtual void onAppManagerEventUninstalled(const char *appId) = 0;
49         virtual void onAppManagerEventUpdated(const char *appId) = 0;
50 };
51
52 class AppManagerWrapper
53 {
54 public:
55         AppManagerWrapper();
56         virtual ~AppManagerWrapper();
57
58         // Can throw InvalidArgumentException or PlatformException
59         void registerAppListChangedCallbacks(IAppManagerAppListChangedCallbacks *callbacks);
60
61         // No throws
62         void unregisterAppListChangedCallbacks(IAppManagerAppListChangedCallbacks *callbacks);
63
64         long getWatchIdAndInc();
65
66         bool initializeAppInfo(ApplicationInformationPtr &appInfo);
67
68 private:
69         // callback for app_manager_set_app_list_changed_cb
70         static void appListChangedCallback(app_manger_event_type_e event_type,
71                                            const char *package,
72                                            void *user_data);
73
74         void appListChangedCallback(app_manger_event_type_e event_type,
75                                     const char *package);
76
77         void appListAppInstalled(const char *appId);
78         void appListAppUninstalled(const char *appId);
79         void appListAppUpdated(const char *appId);
80
81         void registerAppListChangedCallbacks();
82         void unregisterAppListChangedCallbacks();
83
84         typedef std::set<IAppManagerAppListChangedCallbacks *> AppListChangedCallbacksSet;
85         AppListChangedCallbacksSet m_callbacks;
86         bool m_registeredCallback;
87
88         long m_watchIdAcc;
89
90 public:
91         friend class DPL::Singleton<AppManagerWrapper>;
92 };
93
94 typedef DPL::Singleton<AppManagerWrapper> AppManagerWrapperSingleton;
95
96 } // Application
97 } // DeviceAPI
98
99 #endif // TIZENAPIS_PLATFORM_APPLICATION_APP_MANAGER_WRAPPER_H_