Update wrt_0.8.86
[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
28 DECLARE_GENERIC_EVENT_0(NextStepEvent)
29
30 class WrtClient :
31         public DPL::Application,
32         private DPL::Event::Controller<DPL::TypeListDecl<NextStepEvent>::Type>,
33         public DPL::TaskDecl<WrtClient>
34 {
35   public:
36     WrtClient(int argc,
37               char **argv);
38     virtual ~WrtClient();
39
40     class ReturnStatus
41     {
42       public:
43         enum Type
44         {
45             Failed = -1,
46             Succeeded = 0
47         };
48     };
49
50     ReturnStatus::Type   getReturnStatus() const;
51
52   protected:
53     virtual void         OnStop();
54     virtual void         OnCreate();
55     virtual void         OnResume();
56     virtual void         OnPause();
57     virtual void         OnReset(bundle *b);
58     virtual void         OnTerminate();
59
60     void                 setStep();
61
62   private:
63     void                   showHelpAndQuit();
64     bool                   checkArgument();
65     void                   setSdkLauncherDebugData();
66     bool                   checkWACTestCertififedWidget();
67     void                   localizeWidgetModel();
68
69     // Events
70     virtual void         OnEventReceived(const NextStepEvent& event);
71
72     // launching steps
73     void                 initStep();
74     void                 launchStep();
75     void                 shutdownStep();
76
77     static void          staticWrtLaunchWidgetCallback(int,
78                                               CommonError::Type,
79                                               const std::string&,
80                                               void*);
81     // Private data
82     int m_handle;
83     bool m_launched;
84     bool m_initializing;
85     bool m_initialized;
86     int m_sdkLauncherPid;
87     bool m_debugMode;
88     bundle *m_bundle;
89     unsigned short m_debuggerPort;
90     ReturnStatus::Type m_returnStatus;
91     WRT::RunnableWidgetObjectPtr m_widget;
92     WidgetState m_widgetState;
93 };
94
95 #endif // WRT_CLIENT_H