Source code formating unification
[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
86     // launching steps
87     void initStep();
88     void launchStep();
89     void shutdownStep();
90     static int languageChangedCallback(void *data);
91     void loadFinishCallback(Evas_Object* webview);
92     void progressFinishCallback();
93     void webkitExitCallback();
94     void webCrashCallback();
95     void setLayout(Evas_Object* newBuffer);
96     void unsetLayout(Evas_Object* currentBuffer);
97
98     // Private data
99     std::string m_tizenId;
100     bool m_launched;
101     bool m_initializing;
102     bool m_initialized;
103     int m_sdkLauncherPid;
104     bool m_debugMode;
105     bundle *m_bundle;
106     unsigned short m_debuggerPort;
107     ReturnStatus::Type m_returnStatus;
108     WRT::RunnableWidgetObjectPtr m_widget;
109     WrtDB::WidgetDAOReadOnlyPtr m_dao;
110     WidgetState m_widgetState;
111     std::unique_ptr<WindowData> m_windowData;
112     std::unique_ptr<SplashScreenSupport> m_splashScreen;
113 };
114
115 #endif // WRT_CLIENT_H