Popup removal
[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_INSTALLER_H
22 #define WRT_INSTALLER_H
23
24 #include <dpl/application.h>
25 #include <dpl/generic_event.h>
26 #include <dpl/event/controller.h>
27 #include <dpl/task.h>
28 #include <dpl/string.h>
29 #include <string>
30 #include <wrt_installer_api.h>
31
32 namespace WRTInstallerNS { //anonymous
33 DECLARE_GENERIC_EVENT_0(QuitEvent)
34 DECLARE_GENERIC_EVENT_0(NextStepEvent)
35 DECLARE_GENERIC_EVENT_0(InstallPluginEvent)
36 }
37
38 typedef void (*ShowResultCallback)(void *data, Evas_Object *obj,
39                                    void *event_info);
40
41 enum ReturnValue
42 {
43     RE_SUCCESS,
44     RE_FAIL
45 };
46
47 class WrtInstaller :
48     public DPL::Application,
49     private DPL::Event::Controller<DPL::TypeListDecl<
50                                        WRTInstallerNS::QuitEvent,
51                                        WRTInstallerNS::NextStepEvent,
52                                        WRTInstallerNS::InstallPluginEvent>::
53                                        Type>,
54     public DPL::TaskDecl<WrtInstaller>
55 {
56   public:
57     WrtInstaller(int argc,
58                  char **argv);
59     virtual ~WrtInstaller();
60
61     int getReturnStatus() const;
62
63   protected:
64     virtual void OnStop();
65     virtual void OnCreate();
66     virtual void OnReset(bundle *b);
67     virtual void OnTerminate();
68
69   private:
70     void         showHelpAndQuit();
71
72     // Events
73     virtual void OnEventReceived(const WRTInstallerNS::QuitEvent &event);
74     virtual void OnEventReceived(const WRTInstallerNS::NextStepEvent& event);
75     virtual void OnEventReceived(
76         const WRTInstallerNS::InstallPluginEvent& event);
77
78     // Installation steps
79     void initStep();
80     void installStep();
81     void installPluginsStep();
82     void uninstallPkgNameStep();
83     void unistallWgtFileStep();
84     void shutdownStep();
85
86     // Static callbacks
87     static void staticWrtInitCallback(WrtErrStatus status,
88                                       void* userdata);
89     static void staticWrtStatusCallback(std::string tizenId,
90                                         WrtErrStatus status,
91                                         void* userdata);
92     static void staticWrtPluginInstallationCallback(WrtErrStatus status,
93                                                     void* userdata);
94     static void staticWrtPluginInstallProgressCb(float percent,
95                                                  const char* description,
96                                                  void* userdata);
97     static void staticWrtInstallProgressCallback(float percent,
98                                                  const char* description,
99                                                  void* userdata);
100
101     static void staticWrtUninstallProgressCallback(float percent,
102                                                    const char* description,
103                                                    void* userdata);
104
105     static void showResultCallback(void *data, Evas_Object *obj,
106                                    void *event_info);
107     static void failResultCallback(void *data, Evas_Object *obj,
108                                    void *event_info);
109
110     void installNewPlugins();
111     bool popupsEnabled() const;
112
113     // Private data
114     std::shared_ptr<PackageManager::IPkgmgrSignal> pkgmgrSignalInterface;
115     WrtInstallMode m_installMode;
116     std::string m_packagePath;
117     std::string m_name;
118     bool m_initialized;
119     size_t m_numPluginsToInstall;
120     size_t m_totalPlugins;
121     int m_returnStatus;
122     bool m_installByPkgmgr;
123     bool m_quiet;
124     bool m_startupPluginInstallation;
125
126     typedef std::list<std::string> PluginPathList;
127     DPL::Optional<PluginPathList> m_pluginsPaths;
128 };
129 #endif // WRT_INSTALLER_H