Merge "fix: use EINA_* booleans instread of TRUE/FALSE" into tizen
[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 <memory>
20 #include <dpl/application.h>
21 #include <dpl/generic_event.h>
22 #include <dpl/event/controller.h>
23 #include <dpl/type_list.h>
24 #include <dpl/task.h>
25 #include <dpl/optional_typedefs.h>
26 #include <bundle.h>
27 #include <i_runnable_widget_object.h>
28 #include <dpl/wrt-dao-ro/widget_dao_read_only.h>
29 #include <dpl/wrt-dao-ro/common_dao_types.h>
30 #include "widget_state.h"
31 #include <launch_user_data.h>
32 #include "window_data.h"
33 #include "splash_screen_support.h"
34
35 DECLARE_GENERIC_EVENT_0(NextStepEvent)
36
37 namespace ClientModule {
38 class SubmodeSupport;
39 }
40
41 class WrtClient :
42     public DPL::Application,
43     private DPL::Event::Controller<DPL::TypeListDecl<NextStepEvent>::Type>,
44     public DPL::TaskDecl<WrtClient>
45 {
46   public:
47     WrtClient(int argc,
48               char **argv);
49     virtual ~WrtClient();
50
51     class ReturnStatus
52     {
53       public:
54         enum Type
55         {
56             Failed = -1,
57             Succeeded = 0
58         };
59     };
60
61     ReturnStatus::Type   getReturnStatus() const;
62     virtual void Quit();
63     static std::string getTizenIdFromArgument(int argc, char **argv);
64     void autoRotationSetOrientation(Evas_Object* obj);
65
66   protected:
67     virtual void OnStop();
68     virtual void OnCreate();
69     virtual void OnResume();
70     virtual void OnPause();
71     virtual void OnReset(bundle *b);
72     virtual void OnTerminate();
73
74     void setStep();
75
76   private:
77     void showHelpAndQuit();
78     void setDebugMode(bundle* b);
79     void initializeWindowModes();
80
81     // Events
82     virtual void OnEventReceived(const NextStepEvent& event);
83
84     // UI callback
85     // static Callback
86     static Eina_Bool naviframeBackButtonCallback(void* data,
87                                                  Elm_Object_Item* it);
88     static int appcoreLowMemoryCallback(void* data);
89     static int languageChangedCallback(void *data);
90     static void autoRotationCallback(void* data, Evas_Object* obj, void* event);
91     static void focusedCallback(void* data,
92                                 Evas_Object* obj,
93                                 void* eventInfo);
94     static void unfocusedCallback(void* data,
95                                   Evas_Object* obj,
96                                   void* eventInfo);
97
98     //view-mode
99     void setInitialViewMode();
100
101     //orientation
102     void setWindowOrientation(int angle);
103     void setWindowInitialOrientation();
104     void unsetWindowOrientation();
105     void setEwkInitialOrientation();
106
107     //ctxpopup
108     void setCtxpopupItem();
109     void ctxpopupShare();
110     void ctxpopupReload();
111     void ctxpopupLaunchBrowser();
112
113     // hwkey
114     void hwkeyCallback(const std::string& key);
115
116     // launching steps
117     void initStep();
118     void launchStep();
119     void shutdownStep();
120     void loadFinishCallback(Evas_Object* webview);
121     void resetCallback(bool result);
122     void progressStartedCallback();
123     void loadProgressCallback(Evas_Object* webview, double value);
124     void progressFinishCallback();
125     void webkitExitCallback();
126     void webCrashCallback();
127     void enterFullscreenCallback(Evas_Object* obj);
128     void exitFullscreenCallback(Evas_Object* obj);
129     void setLayout(Evas_Object* newBuffer);
130     void unsetLayout(Evas_Object* currentBuffer);
131
132     // Private data
133     std::string m_tizenId;
134
135     bool m_launched;
136     bool m_initializing;
137     bool m_initialized;
138     bool m_debugMode;
139     ReturnStatus::Type m_returnStatus;
140     WRT::RunnableWidgetObjectPtr m_widget;
141     WrtDB::WidgetDAOReadOnlyPtr m_dao;
142     WidgetSettingListPtr m_settingList;
143     WidgetState m_widgetState;
144     std::unique_ptr<WindowData> m_windowData;
145     std::unique_ptr<SplashScreenSupport> m_splashScreen;
146     std::string m_initialViewMode;
147     std::string m_currentViewMode;
148     bool m_isWebkitFullscreen;
149
150     std::unique_ptr<ClientModule::SubmodeSupport> m_submodeSupport;
151 };
152
153 #endif // WRT_CLIENT_H