update wrt_0.8.107
[platform/framework/web/wrt.git] / src / wrt-client / wrt-client.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 #ifndef WRT_CLIENT_H
17 #define WRT_CLIENT_H
18
19 #include <dpl/application.h>
20 #include <dpl/generic_event.h>
21 #include <dpl/event/controller.h>
22 #include <dpl/type_list.h>
23 #include <dpl/task.h>
24 #include <bundle.h>
25 #include <i_runnable_widget_object.h>
26 #include <dpl/wrt-dao-ro/widget_dao_read_only.h>
27 #include <dpl/wrt-dao-ro/common_dao_types.h>
28 #include "widget_state.h"
29 #include <common_error.h>
30 #include <launch_user_data.h>
31 #include <widget_model.h>
32 #include "window_data.h"
33 #include "splash_screen_support.h"
34
35 DECLARE_GENERIC_EVENT_0(NextStepEvent)
36
37 class WrtClient :
38         public DPL::Application,
39         private DPL::Event::Controller<DPL::TypeListDecl<NextStepEvent>::Type>,
40         public DPL::TaskDecl<WrtClient>
41 {
42   public:
43     WrtClient(int argc,
44               char **argv);
45     virtual ~WrtClient();
46
47     class ReturnStatus
48     {
49       public:
50         enum Type
51         {
52             Failed = -1,
53             Succeeded = 0
54         };
55     };
56
57     ReturnStatus::Type   getReturnStatus() const;
58
59   protected:
60     virtual void OnStop();
61     virtual void OnCreate();
62     virtual void OnResume();
63     virtual void OnPause();
64     virtual void OnReset(bundle *b);
65     virtual void OnTerminate();
66
67     void setStep();
68
69   private:
70     void showHelpAndQuit();
71     bool checkArgument();
72     void setSdkLauncherDebugData();
73     bool checkDebugMode(SDKDebugData* debugData);
74     bool checkWACTestCertififedWidget();
75     void connectElmCallback();
76     void initializeWindowModes();
77
78     // Events
79     virtual void OnEventReceived(const NextStepEvent& event);
80
81     // UI callback
82     static void backButtonCallback(void* data,
83                                    Evas_Object* obj,
84                                    void* event_info);
85     static void backwardCallback(void* data,
86             Evas_Object* obj,
87             void* event_info);
88     static void reloadCallback(void* data,
89             Evas_Object* obj,
90             void* event_info);
91     static void forwardCallback(void* data,
92             Evas_Object* obj,
93             void* event_info);
94
95     // launching steps
96     void initStep();
97     void launchStep();
98     void shutdownStep();
99     static int languageChangedCallback(void *data);
100     void loadFinishCallback(bool success);
101     void progressFinishCallback();
102     void windowCloseCallback();
103     void webCrashCallback();
104     void setLayout(Evas_Object* newBuffer);
105     void unsetLayout(Evas_Object* currentBuffer);
106
107     // Private data
108     std::string m_tizenId;
109     bool m_launched;
110     bool m_initializing;
111     bool m_initialized;
112     int m_sdkLauncherPid;
113     bool m_debugMode;
114     bundle *m_bundle;
115     unsigned short m_debuggerPort;
116     ReturnStatus::Type m_returnStatus;
117     WRT::RunnableWidgetObjectPtr m_widget;
118     WrtDB::WidgetDAOReadOnlyPtr m_dao;
119     WidgetState m_widgetState;
120     std::unique_ptr<WindowData> m_windowData;
121     std::unique_ptr<SplashScreenSupport> m_splashScreen;
122 };
123
124 #endif // WRT_CLIENT_H