To comply a rule of webkit EFL port, ewk_init()/ewk_shutdown() api call were added.
[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 <launch_user_data.h>
30 #include "window_data.h"
31 #include "splash_screen_support.h"
32
33 DECLARE_GENERIC_EVENT_0(NextStepEvent)
34
35 class WrtClient :
36         public DPL::Application,
37         private DPL::Event::Controller<DPL::TypeListDecl<NextStepEvent>::Type>,
38         public DPL::TaskDecl<WrtClient>
39 {
40   public:
41     WrtClient(int argc,
42               char **argv);
43     virtual ~WrtClient();
44
45     class ReturnStatus
46     {
47       public:
48         enum Type
49         {
50             Failed = -1,
51             Succeeded = 0
52         };
53     };
54
55     ReturnStatus::Type   getReturnStatus() const;
56     virtual void Quit();
57
58   protected:
59     virtual void OnStop();
60     virtual void OnCreate();
61     virtual void OnResume();
62     virtual void OnPause();
63     virtual void OnReset(bundle *b);
64     virtual void OnTerminate();
65
66     void setStep();
67
68   private:
69     void showHelpAndQuit();
70     bool checkArgument();
71     void setSdkLauncherDebugData();
72     bool checkDebugMode(SDKDebugData* debugData);
73     bool checkWACTestCertififedWidget();
74     void connectElmCallback();
75     void initializeWindowModes();
76
77     // Events
78     virtual void OnEventReceived(const NextStepEvent& event);
79
80     // UI callback
81     static void backButtonCallback(void* data,
82                                    Evas_Object* obj,
83                                    void* event_info);
84     static void backwardCallback(void* data,
85             Evas_Object* obj,
86             void* event_info);
87     static void reloadCallback(void* data,
88             Evas_Object* obj,
89             void* event_info);
90     static void forwardCallback(void* data,
91             Evas_Object* obj,
92             void* event_info);
93
94     // launching steps
95     void initStep();
96     void launchStep();
97     void shutdownStep();
98     static int languageChangedCallback(void *data);
99     void loadFinishCallback(Evas_Object* webview);
100     void progressFinishCallback();
101     void webkitExitCallback();
102     void webCrashCallback();
103     void setLayout(Evas_Object* newBuffer);
104     void unsetLayout(Evas_Object* currentBuffer);
105
106     // Private data
107     std::string m_tizenId;
108     bool m_launched;
109     bool m_initializing;
110     bool m_initialized;
111     int m_sdkLauncherPid;
112     bool m_debugMode;
113     bundle *m_bundle;
114     unsigned short m_debuggerPort;
115     ReturnStatus::Type m_returnStatus;
116     WRT::RunnableWidgetObjectPtr m_widget;
117     WrtDB::WidgetDAOReadOnlyPtr m_dao;
118     WidgetState m_widgetState;
119     std::unique_ptr<WindowData> m_windowData;
120     std::unique_ptr<SplashScreenSupport> m_splashScreen;
121 };
122
123 #endif // WRT_CLIENT_H