Remove hardcoded path for multiuser support
[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
26 #include <app_manager.h>
27 #include <package-manager.h>
28 #include <package_manager.h>
29 #include <package_info.h>
30
31 #include "ApplicationInformation.h"
32
33 // To get app size and installed time
34 #include <pkgmgr-info.h>
35
36 #include <Singleton.h>
37
38 namespace DeviceAPI {
39 namespace Application {
40
41
42 class IAppManagerAppListChangedCallbacks
43 {
44 public:
45     friend class AppManagerWrapper;
46
47         IAppManagerAppListChangedCallbacks() {}
48         ~IAppManagerAppListChangedCallbacks() {}
49
50 protected:
51         virtual void onAppManagerEventInstalled(const char *appId) = 0;
52         virtual void onAppManagerEventUninstalled(const char *appId) = 0;
53         virtual void onAppManagerEventUpdated(const char *appId) = 0;
54 };
55
56 class DLL_EXPORT AppManagerWrapper
57 {
58 public:
59         AppManagerWrapper();
60         virtual ~AppManagerWrapper();
61
62         // Can throw InvalidArgumentException or PlatformException
63         void registerAppListChangedCallbacks(IAppManagerAppListChangedCallbacks *callbacks);
64
65         // No throws
66         void unregisterAppListChangedCallbacks(IAppManagerAppListChangedCallbacks *callbacks);
67
68         long getWatchIdAndInc();
69
70         bool initializeAppInfo(ApplicationInformationPtr &appInfo);
71
72         // get the current application id from WRT
73         void setCurrentAppId(std::string appId);
74         std::string getCurrentAppId() const;
75
76 private:
77
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);
81
82         void appListAppInstalled(const char *appId);
83         void appListAppUninstalled(const char *appId);
84         void appListAppUpdated(const char *appId);
85
86         void registerAppListChangedCallbacks();
87         void unregisterAppListChangedCallbacks();
88
89         typedef std::set<IAppManagerAppListChangedCallbacks *> AppListChangedCallbacksSet;
90         AppListChangedCallbacksSet m_callbacks;
91         pkgmgr_client *m_manager_handle;
92         long m_watchIdAcc;
93         std::string m_curr_app_id;
94
95 public:
96         std::vector<std::string> applist;
97
98 public:
99         friend class AppManagerWrapperSingleton;
100 };
101
102 SINGLETON_DEFINITION(AppManagerWrapper)
103
104
105 } // Application
106 } // DeviceAPI
107
108 #endif // TIZENAPIS_PLATFORM_APPLICATION_APP_MANAGER_WRAPPER_H_