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