[Release] wrt_0.8.215
[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 <dpl/optional_typedefs.h>
25 #include <bundle.h>
26 #include <i_runnable_widget_object.h>
27 #include <dpl/wrt-dao-ro/widget_dao_read_only.h>
28 #include <dpl/wrt-dao-ro/common_dao_types.h>
29 #include "widget_state.h"
30 #include <launch_user_data.h>
31 #include "window_data.h"
32 #include "splash_screen_support.h"
33
34 DECLARE_GENERIC_EVENT_0(NextStepEvent)
35
36 class WrtClient :
37     public DPL::Application,
38     private DPL::Event::Controller<DPL::TypeListDecl<NextStepEvent>::Type>,
39     public DPL::TaskDecl<WrtClient>
40 {
41   public:
42     WrtClient(int argc,
43               char **argv);
44     virtual ~WrtClient();
45
46     class ReturnStatus
47     {
48       public:
49         enum Type
50         {
51             Failed = -1,
52             Succeeded = 0
53         };
54     };
55
56     ReturnStatus::Type   getReturnStatus() const;
57     virtual void Quit();
58     static std::string getTizenIdFromArgument(int argc, char **argv);
59
60   protected:
61     virtual void OnStop();
62     virtual void OnCreate();
63     virtual void OnResume();
64     virtual void OnPause();
65     virtual void OnReset(bundle *b);
66     virtual void OnTerminate();
67
68     void setStep();
69
70   private:
71     void showHelpAndQuit();
72     bool checkArgument();
73     void setSdkLauncherDebugData();
74     bool checkDebugMode(SDKDebugData* debugData);
75     void connectElmCallback();
76     void initializeWindowModes();
77     bool isFullscreen();
78
79     // Events
80     virtual void OnEventReceived(const NextStepEvent& event);
81
82     // static Callback
83     static void backButtonCallback(void* data,
84                                    Evas_Object* obj,
85                                    void* event_info);
86     static void naviframeBackButtonCallback(void* data,
87                                             Elm_Object_Item* it);
88     static int appcoreLowMemoryCallback(void* data);
89     static int languageChangedCallback(void *data);
90
91     //orientation
92     void setOrientationWindow();
93     void unsetOrientationWindow();
94     void setOrientationEwk();
95
96     // launching steps
97     void initStep();
98     void launchStep();
99     void shutdownStep();
100     void loadFinishCallback(Evas_Object* webview);
101     void progressStartedCallback();
102     void loadProgressCallback(Evas_Object* webview, double value);
103     void progressFinishCallback();
104     void webkitExitCallback();
105     void webCrashCallback();
106     void toggleFullscreenCallback(bool fullscreen);
107     void imeChangedCallback(bool open);
108     void setLayout(Evas_Object* newBuffer);
109     void unsetLayout(Evas_Object* currentBuffer);
110
111     // Private data
112     std::string m_tizenId;
113     DPL::OptionalUInt m_appControlIndex;
114
115     bool m_launched;
116     bool m_initializing;
117     bool m_initialized;
118     int m_sdkLauncherPid;
119     bool m_debugMode;
120     unsigned short m_debuggerPort;
121     ReturnStatus::Type m_returnStatus;
122     WRT::RunnableWidgetObjectPtr m_widget;
123     WrtDB::WidgetDAOReadOnlyPtr m_dao;
124     WidgetSettingListPtr m_settingList;
125     WidgetState m_widgetState;
126     std::unique_ptr<WindowData> m_windowData;
127     std::unique_ptr<SplashScreenSupport> m_splashScreen;
128     bool m_fullscreen;
129 };
130
131 #endif // WRT_CLIENT_H