[Release] wrt_0.8.177
[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     static std::string getTizenIdFromArgument(int argc, char **argv);
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     // Low Memory Callback
86     static int appcoreLowMemoryCallback(void* data);
87
88     //orientation
89     void setOrientationWindow();
90     void setOrientationEwk();
91
92     // launching steps
93     void initStep();
94     void launchStep();
95     void shutdownStep();
96     static int languageChangedCallback(void *data);
97     void loadFinishCallback(Evas_Object* webview);
98     void progressFinishCallback();
99     void webkitExitCallback();
100     void webCrashCallback();
101     void setLayout(Evas_Object* newBuffer);
102     void unsetLayout(Evas_Object* currentBuffer);
103
104     // Private data
105     std::string m_tizenId;
106     bool m_launched;
107     bool m_initializing;
108     bool m_initialized;
109     int m_sdkLauncherPid;
110     bool m_debugMode;
111     unsigned short m_debuggerPort;
112     ReturnStatus::Type m_returnStatus;
113     WRT::RunnableWidgetObjectPtr m_widget;
114     WrtDB::WidgetDAOReadOnlyPtr m_dao;
115     WidgetState m_widgetState;
116     std::unique_ptr<WindowData> m_windowData;
117     std::unique_ptr<SplashScreenSupport> m_splashScreen;
118 };
119
120 #endif // WRT_CLIENT_H