3066457af77809afd6ec0a6546f5e109d18f0fe1
[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 void ExitCallback(void* data,
86                                    Evas_Object* obj,
87                                    void* event_info);                                  
88     // static Callback
89     static Eina_Bool naviframeBackButtonCallback(void* data,
90                                                  Elm_Object_Item* it);
91     static int appcoreLowMemoryCallback(void* data);
92     static int languageChangedCallback(void *data);
93     static void autoRotationCallback(void* data, Evas_Object* obj, void* event);
94     static void focusedCallback(void* data,
95                                 Evas_Object* obj,
96                                 void* eventInfo);
97     static void unfocusedCallback(void* data,
98                                   Evas_Object* obj,
99                                   void* eventInfo);
100
101     //view-mode
102     void setInitialViewMode();
103
104     //orientation
105     void setWindowOrientation(int angle);
106     void setWindowInitialOrientation();
107     void unsetWindowOrientation();
108     void setEwkInitialOrientation();
109
110     //ctxpopup
111     void setCtxpopupItem();
112     void ctxpopupShare();
113     void ctxpopupReload();
114     void ctxpopupLaunchBrowser();
115
116     // hwkey
117     void hwkeyCallback(const std::string& key);
118
119     // launching steps
120     void initStep();
121     void launchStep();
122     void shutdownStep();
123     void loadFinishCallback(Evas_Object* webview);
124     void resetCallback(bool result);
125     void progressStartedCallback();
126     void loadProgressCallback(Evas_Object* webview, double value);
127     void progressFinishCallback();
128     void webkitExitCallback();
129     void webCrashCallback();
130     void enterFullscreenCallback(Evas_Object* obj);
131     void exitFullscreenCallback(Evas_Object* obj);
132     void setLayout(Evas_Object* newBuffer);
133     void unsetLayout(Evas_Object* currentBuffer);
134
135     // Private data
136     std::string m_tizenId;
137
138     bool m_launched;
139     bool m_initializing;
140     bool m_initialized;
141     bool m_debugMode;
142     ReturnStatus::Type m_returnStatus;
143     WRT::RunnableWidgetObjectPtr m_widget;
144     WrtDB::WidgetDAOReadOnlyPtr m_dao;
145     WidgetSettingListPtr m_settingList;
146     WidgetState m_widgetState;
147     std::unique_ptr<WindowData> m_windowData;
148     std::unique_ptr<SplashScreenSupport> m_splashScreen;
149     std::string m_initialViewMode;
150     std::string m_currentViewMode;
151     bool m_isWebkitFullscreen;
152
153     std::unique_ptr<ClientModule::SubmodeSupport> m_submodeSupport;
154 };
155
156 #endif // WRT_CLIENT_H