[Release] wrt_0.8.251
[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     void autoRotationSetOrientation(Evas_Object* obj);
60
61   protected:
62     virtual void OnStop();
63     virtual void OnCreate();
64     virtual void OnResume();
65     virtual void OnPause();
66     virtual void OnReset(bundle *b);
67     virtual void OnTerminate();
68
69     void setStep();
70
71   private:
72     void showHelpAndQuit();
73     void setDebugMode(bundle* b);
74     void initializeWindowModes();
75
76     // Events
77     virtual void OnEventReceived(const NextStepEvent& event);
78
79     // static Callback
80     static Eina_Bool naviframeBackButtonCallback(void* data,
81                                                  Elm_Object_Item* it);
82     static int appcoreLowMemoryCallback(void* data);
83     static int languageChangedCallback(void *data);
84     static void autoRotationCallback(void* data, Evas_Object* obj, void* event);
85     static void focusedCallback(void* data,
86                                 Evas_Object* obj,
87                                 void* eventInfo);
88     static void unfocusedCallback(void* data,
89                                   Evas_Object* obj,
90                                   void* eventInfo);
91
92     //view-mode
93     void setInitialViewMode();
94
95     //orientation
96     void setWindowOrientation(int angle);
97     void setWindowInitialOrientation();
98     void unsetWindowOrientation();
99     void setEwkInitialOrientation();
100
101     //ctxpopup
102     void setCtxpopupItem();
103     void ctxpopupShare();
104     void ctxpopupReload();
105     void ctxpopupLaunchBrowser();
106
107     // hwkey
108     void hwkeyCallback(const std::string& key);
109
110     // launching steps
111     void initStep();
112     void launchStep();
113     void shutdownStep();
114     void loadFinishCallback(Evas_Object* webview);
115     void resetCallback(bool result);
116     void progressStartedCallback();
117     void loadProgressCallback(Evas_Object* webview, double value);
118     void progressFinishCallback();
119     void webkitExitCallback();
120     void webCrashCallback();
121     void enterFullscreenCallback(Evas_Object* obj, bool isFullscreenByPlatform);
122     void exitFullscreenCallback(Evas_Object* obj);
123     void setLayout(Evas_Object* newBuffer);
124     void unsetLayout(Evas_Object* currentBuffer);
125
126     // Private data
127     std::string m_tizenId;
128     DPL::OptionalUInt m_appControlIndex;
129
130     bool m_launched;
131     bool m_initializing;
132     bool m_initialized;
133     bool m_debugMode;
134     ReturnStatus::Type m_returnStatus;
135     WRT::RunnableWidgetObjectPtr m_widget;
136     WrtDB::WidgetDAOReadOnlyPtr m_dao;
137     WidgetSettingListPtr m_settingList;
138     WidgetState m_widgetState;
139     std::unique_ptr<WindowData> m_windowData;
140     std::unique_ptr<SplashScreenSupport> m_splashScreen;
141     std::string m_initialViewMode;
142     std::string m_currentViewMode;
143     bool m_isWebkitFullscreen;
144     bool m_isFullscreenByPlatform;
145 };
146
147 #endif // WRT_CLIENT_H