Merge "Change pkgname to appid for docomo request. PART1"
[framework/web/wrt-installer.git] / src / wrt-installer / wrt_installer.h
1 /*
2  * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  *    Licensed under the Apache License, Version 2.0 (the "License");
5  *    you may not use this file except in compliance with the License.
6  *    You may obtain a copy of the License at
7  *
8  *        http://www.apache.org/licenses/LICENSE-2.0
9  *
10  *    Unless required by applicable law or agreed to in writing, software
11  *    distributed under the License is distributed on an "AS IS" BASIS,
12  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  *    See the License for the specific language governing permissions and
14  *    limitations under the License.
15  */
16 /**
17  * @file    wrt_installer.h
18  * @version 1.0
19  * @brief   Implementation file for installer
20  */
21 #ifndef WRT_CLIENT_H
22 #define WRT_CLIENT_H
23
24 #include <dpl/application.h>
25 #include <dpl/generic_event.h>
26 #include <dpl/event/controller.h>
27 #include <dpl/type_list.h>
28 #include <dpl/task.h>
29 #include <dpl/log/log.h>
30 #include <dpl/string.h>
31 #include <string>
32 #include <utilX.h>
33 #include <wrt_installer_api.h>
34
35 #include <pkg-manager/pkgmgr_signal_interface.h>
36 #include <pkg-manager/pkgmgr_signal_dummy.h>
37 #include <pkg-manager/pkgmgr_signal.h>
38 #include <memory>
39
40 namespace WRTInstallerNS { //anonymous
41 DECLARE_GENERIC_EVENT_0(QuitEvent)
42 DECLARE_GENERIC_EVENT_0(NextStepEvent)
43 DECLARE_GENERIC_EVENT_0(InstallPluginEvent)
44 }
45
46 typedef void (*ShowResultCallback)(void *data, Evas_Object *obj,
47                                    void *event_info);
48
49 enum ReturnValue
50 {
51     RE_SUCCESS,
52     RE_FAIL
53 };
54
55 class WrtInstaller :
56         public DPL::Application,
57         private DPL::Event::Controller<DPL::TypeListDecl<
58             WRTInstallerNS::QuitEvent,
59             WRTInstallerNS::NextStepEvent,
60             WRTInstallerNS::InstallPluginEvent>::Type>,
61         public DPL::TaskDecl<WrtInstaller>
62 {
63   public:
64     WrtInstaller(int argc,
65               char **argv);
66     virtual ~WrtInstaller();
67
68
69     int getReturnStatus() const;
70
71     class InstallerPopup
72     {
73         public:
74             InstallerPopup();
75             virtual ~InstallerPopup();
76
77             void init();
78             Evas_Object* createWin(const char* name);
79             void showPopup(void* userdata, const DPL::String& pkgMsg,
80                            ShowResultCallback callback);
81
82             Evas_Object* m_win;
83             Evas_Object* m_popup;
84             Evas_Object* m_progressbar;
85     };
86
87   protected:
88     virtual void OnStop();
89     virtual void OnCreate();
90     virtual void OnReset(bundle *b);
91     virtual void OnTerminate();
92
93   private:
94     void         showHelpAndQuit();
95
96     // Events
97     virtual void OnEventReceived(const WRTInstallerNS::QuitEvent &event);
98     virtual void OnEventReceived(const WRTInstallerNS::NextStepEvent& event);
99     virtual void OnEventReceived(const WRTInstallerNS::InstallPluginEvent& event);
100
101     // Installation steps
102     void initStep();
103     void installStep();
104     void installNewPlugins();
105     void installPluginsStep();
106     void uninstallPkgNameStep();
107     void uninstallGuidStep();
108     void unistallWgtFileStep();
109     void shutdownStep();
110     void registerCallbackStep();
111     void queryListStep();
112
113
114     // Static callbacks
115     static void staticWrtInitCallback(WrtErrStatus status,
116                                       void* userdata);
117     static void staticWrtStatusCallback(std::string tizenId,
118                                         WrtErrStatus status,
119                                         void* userdata);
120     static void staticWrtPluginInstallationCallback(WrtErrStatus status,
121                                                     void* userdata);
122     static void staticWrtPluginInstallProgressCb(float percent,
123                                                  const char* description,
124                                                  void* userdata);
125     static void staticWrtInstallProgressCallback(float percent,
126                                                 const char* description,
127                                                 void* userdata);
128
129     static void staticWrtUninstallProgressCallback(float percent,
130                                                 const char* description,
131                                                 void* userdata);
132
133     static void showResultCallback(void *data, Evas_Object *obj,
134                                    void *event_info);
135     static void failResultCallback(void *data, Evas_Object *obj,
136                                    void *event_info);
137
138     bool popupsEnabled() const;
139
140     // Private data
141     std::shared_ptr<PackageManager::IPkgmgrSignal> pkgmgrSignalInterface;
142     wrt_widget_install_mode_e m_installPolicy;
143     std::string m_bundleValue;
144     std::string m_packagePath;
145     int m_handle;
146     std::string m_name;
147     bool m_initialized;
148     size_t m_numPluginsToInstall;
149     size_t m_totalPlugins;
150     int m_returnStatus;
151     bool m_installByPkgmgr;
152     bool m_quiet;
153     InstallerPopup *m_popup;
154     bool m_startupPluginInstallation;
155     std::string m_webAppConfig;
156     std::string m_webAppIcon;
157     bool m_preloadWidget;
158
159     typedef std::list<std::string> PluginPathList;
160     DPL::Optional<PluginPathList> m_pluginsPaths;
161 };
162 #endif // WRT_CLIENT_H