Update wrt_0.8.89
[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 "widget_state.h"
27 #include <common_error.h>
28 #include <launch_user_data.h>
29 #include <widget_model.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
57   protected:
58     virtual void         OnStop();
59     virtual void         OnCreate();
60     virtual void         OnResume();
61     virtual void         OnPause();
62     virtual void         OnReset(bundle *b);
63     virtual void         OnTerminate();
64
65     void                 setStep();
66
67   private:
68     void                 showHelpAndQuit();
69     bool                 checkArgument();
70     void                 setSdkLauncherDebugData();
71     bool                 checkDebugMode(
72                             WidgetModel* model, 
73                             SDKDebugData* debugData);
74     bool                 checkWACTestCertififedWidget();
75     void                 localizeWidgetModel();
76     void                 connectElmCallback();
77     void                 initializeWindowModes();
78
79     // Events
80     virtual void         OnEventReceived(const NextStepEvent& event);
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     static void          loadFinishCallback(bool success, void* data);
92     static void          progressFinishCallback(void* data);
93     static void          setLayout(Evas_Object* newBuffer, void* data);
94     static void          unsetLayout(Evas_Object* currentBuffer, void* data);
95     // Private data
96     int m_handle;
97     bool m_launched;
98     bool m_initializing;
99     bool m_initialized;
100     int m_sdkLauncherPid;
101     bool m_debugMode;
102     bundle *m_bundle;
103     unsigned short m_debuggerPort;
104     ReturnStatus::Type m_returnStatus;
105     WRT::RunnableWidgetObjectPtr m_widget;
106     WidgetState m_widgetState;
107     std::unique_ptr<WindowData> m_windowData;
108     std::unique_ptr<SplashScreenSupport> m_splashScreen;
109 };
110
111 #endif // WRT_CLIENT_H