2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 * @file i_runnable_widget_object.h
18 * @author Przemyslaw Ciezkowski (p.ciezkowski@samsung.com)
20 * @brief File contains declaration of IRunnableWidgetObject interface.
23 #ifndef RUNNABLE_WIDGET_OBJECT_INTERFACE_H_
24 #define RUNNABLE_WIDGET_OBJECT_INTERFACE_H_
26 #include <dpl/wrt-dao-ro/wrt_db_types.h>
27 #include <dpl/fast_delegate.h>
30 #include <widget_model.h>
32 #include <dpl/exception.h>
35 typedef DPL::FastDelegate0<void> ProgressFinishCB;
36 typedef DPL::FastDelegate1<Evas_Object*, void> LoadStartCB;
37 typedef DPL::FastDelegate1<Evas_Object*, void> LoadFinishCB;
38 typedef DPL::FastDelegate0<void> WebCrashCB;
39 typedef DPL::FastDelegate2<Evas**, Evas_Object*, void> WindowCreateBeforeCB;
40 typedef DPL::FastDelegate2<Evas_Object*, Evas_Object*,
41 void> WindowCreateAfterCB;
42 typedef DPL::FastDelegate1<Evas_Object*, void> WindowCloseCB;
43 typedef DPL::FastDelegate0<void> WebkitExitCB;
44 typedef DPL::FastDelegate1<bool, void> ResumeCB;
45 typedef DPL::FastDelegate1<bool, void> SuspendCB;
46 typedef DPL::FastDelegate1<bool, void> ResetCB;
47 typedef DPL::FastDelegate1<Evas_Object*, void> BufferUnsetCB;
48 typedef DPL::FastDelegate1<Evas_Object*, void> BufferSetCB;
49 typedef DPL::FastDelegate1<bool, void> ToggleFullscreenCB;
51 typedef struct UserDelegates {
52 ProgressFinishCB progressFinish;
53 LoadStartCB loadStart;
54 LoadFinishCB loadFinish;
56 WindowCreateBeforeCB windowCreateBefore;
57 WindowCreateAfterCB windowCreateAfter;
58 WindowCloseCB windowClose;
59 WebkitExitCB webkitExit;
63 BufferUnsetCB bufferUnset;
64 BufferSetCB bufferSet;
65 ToggleFullscreenCB toggleFullscreen;
68 typedef std::shared_ptr<UserDelegates> UserDelegatesPtr;
69 typedef std::shared_ptr<WidgetModel> WidgetModelPtr;
72 * @brief The IRunnableWidgetObject class Runnable object interface
74 * Interface for managing WRT widgets runnable object.
75 * Methods should be called in approopriatte order. Check graph below.
77 * /----------->(INITIAL)
83 * | Reset() | CheckBeforeLaunch()
91 * | Suspend() | | Resume()
96 * | (any state besides INITIAL)
100 * \-------------(HIDDEN)
103 class IRunnableWidgetObject
106 // IRunnableWidgetObject base exception
107 DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
109 // Throwed by any method if it is called in wrong state
110 DECLARE_EXCEPTION_TYPE(Base, MethodInvocationForbidden)
114 * @return false when widget is already running or
115 * when security check fails
117 virtual bool CheckBeforeLaunch() = 0;
119 * Prepares view to launch. You MUST call elm_init before calling
122 * @param callbacks passed to viewLogic
124 virtual bool PrepareView(const std::string &startUrl,
125 Evas_Object *window) = 0;
127 * Shows widget asynchronously. Callback will be called when
128 * webkit generates website.
131 virtual void Show() = 0;
133 * Hides widget. To show it again Reset must be called.
135 virtual void Hide() = 0;
137 * Stops widget's javascript. If widget has set background_enabled
138 * then this method has no effect. To resume use Resume();
140 virtual void Suspend() = 0;
142 * Resumes widget's javascript after calling Suspend(). Resumes only if
143 * widget is in suspend state.
145 virtual void Resume() = 0;
147 * Resets widgets after calling Hide().
149 virtual void Reset() = 0;
151 * Reload start page on widget.
153 virtual void ReloadStartPage() = 0;
155 * Retrieve widget's top level webview
156 * @return Evas_Object*
158 virtual Evas_Object* GetCurrentWebview() = 0;
160 * Register widget's delegates
162 virtual void SetUserDelegates(const UserDelegatesPtr& cbs) = 0;
164 * Call goBack() on webkit
166 virtual void Backward() = 0;
168 * fire custom javascript event
170 virtual void FireJavascriptEvent(int event, void* data) = 0;
172 virtual ~IRunnableWidgetObject() {}
175 typedef std::shared_ptr<IRunnableWidgetObject> RunnableWidgetObjectPtr;
177 #endif /* RUNNABLE_WIDGET_OBJECT_INTERFACE_H_ */