a490b49053c02d4f534bd0fc6341b08c53f5c9a1
[platform/framework/native/appfw.git] / inc / FAppUiApp.h
1 //
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
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
17 /**
18  * @file        FAppUiApp.h
19  * @brief       This is the header file for the %UiApp class.
20  *
21  * This header file contains the declarations of the %UiApp class.
22  */
23
24 #ifndef _FAPP_UI_APP_H_
25 #define _FAPP_UI_APP_H_
26
27 #include <FAppApp.h>
28
29 namespace Tizen { namespace Base { namespace Collection { class IList; } } }
30 namespace Tizen { namespace Ui { namespace Controls { class Frame; } } }
31
32 namespace Tizen { namespace App
33 {
34
35 class UiApp;
36 class IAppFrame;
37
38 typedef UiApp* (*UiAppInstanceFactory)(void);
39
40 /**
41  * @class       UiApp
42  * @brief       This class is the base class of a %Tizen native UI application.
43  *
44  * @since       2.0
45  *
46  * The %UiApp class is the base class of a %Tizen native UI application.
47  * A %Tizen native UI application must inherit from the %UiApp class. This class provides the basic features necessary to define the
48  * %Tizen native UI application.
49  * @n
50  * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/app/app_namespace.htm">App Guide</a> and <a href="../org.tizen.native.appprogramming/html/basics_tizen_programming/tizen_app_model/application_model.htm">Native Application Model</a>.
51  *
52  */
53 class _OSP_EXPORT_ UiApp
54         : public Tizen::App::App
55 {
56 public:
57         /**
58          * This destructor overrides Tizen::Base::Object::~Object().
59          *
60          * @since       2.0
61          */
62         virtual ~UiApp(void);
63
64         /**
65          * Gets the first frame in the frame list of the UI application.
66          *
67          * @since       2.0
68          *
69          * @return      A pointer to the IAppFrame interface of the frame, @n
70          *                      else @c null if it fails
71          * @exception   E_SUCCESS       The method is successful.
72          * @exception   E_INVALID_STATE The frame has not been properly initialized.
73          * @exception   E_OBJ_NOT_FOUND The frame is not found.
74          */
75         IAppFrame* GetAppFrame(void) const;
76
77         /**
78          * Adds the frame to the end of the list that is maintained by the UI application.
79          *
80          * @since       2.0
81          *
82          * @return      An error code
83          * @param[in]   frame               The frame that is added to the UI application
84          * @exception   E_SUCCESS           The method is successful.
85          * @exception   E_INVALID_ARG       The specified input parameter is invalid.
86          * @exception   E_INVALID_STATE     The application is in an invalid state.
87          * @exception   E_OBJ_ALREADY_EXIST The frame to be added is already registered with the UI application.
88          * @exception   E_OUT_OF_MEMORY     The memory is insufficient.
89          * @exception   E_MAX_EXCEEDED      The number of frames has exceeded the maximum limit.
90          * @exception   E_SYSTEM            A system error has occurred.
91          */
92         result AddFrame(const Tizen::Ui::Controls::Frame& frame);
93
94         /**
95          * Removes the specified @c frame from the UI application.
96          *
97          * @since       2.0
98          *
99          * @return      An error code
100          * @param[in]   frame           The frame to remove
101          * @exception   E_SUCCESS       The method is successful.
102          * @exception   E_OBJ_NOT_FOUND The specified @c frame cannot be found.
103          * @exception   E_SYSTEM        A system error has occurred.
104          * @remarks     The removed frame is deleted from the memory.
105          */
106         result RemoveFrame(const Tizen::Ui::Controls::Frame& frame);
107
108         /**
109          * Gets the list of the frames of the UI application.
110          *
111          * @since       2.0
112          *
113          * @return      A pointer to Tizen::Base::Collection::IList that contains Tizen::Ui::Frame instances, @n
114          *                      else @c null if it fails
115          * @exception   E_SUCCESS           The method is successful.
116          * @exception   E_INVALID_STATE     The application is in an invalid state.
117          * @remarks     The specific error code can be accessed using the GetLastResult() method.
118          */
119         Tizen::Base::Collection::IList* GetFrameList(void) const;
120
121         /**
122          * Gets the frame with the specified @c name.
123          *
124          * @since       2.0
125          *
126          * @return      A pointer to the frame having the specified @c name, @n
127          *                      else @c null if it fails
128          * @param[in]   name                The name of the frame
129          * @exception   E_SUCCESS           The method is successful.
130          * @exception   E_OBJ_NOT_FOUND     The specified @c frame cannot be found.
131          * @remarks     The specific error code can be accessed using the GetLastResult() method.
132          */
133         Tizen::Ui::Controls::Frame* GetFrame(const Tizen::Base::String& name) const;
134
135         /**
136          * Gets the frame at the specified @c index of the list.
137          *
138          * @since       2.0
139          *
140          * @return      A pointer to the frame at the specified @c index, @n
141          *                      else @c null if it fails
142          * @param[in]   index               The index of the frame
143          * @exception   E_SUCCESS           The method is successful.
144          * @exception   E_OUT_OF_RANGE      The specified @c index is outside the bounds of the frame list.
145          * @remarks     The specific error code can be accessed using the GetLastResult() method.
146          */
147         Tizen::Ui::Controls::Frame* GetFrameAt(int index) const;
148
149 /**
150          * Gets the UI state of the UI application.
151          *
152          * @since       2.0
153          *
154          * @return      The UI state of the UI application
155          * @remarks     Note that UiApp::OnBackground() is invoked when the UI state of a UI application changes
156          *          from App::APP_UI_STATE_FOREGROUND to App::APP_UI_STATE_PARTIAL_BACKGROUND or App::APP_UI_STATE_BACKGROUND.
157          * @see         AppUiState
158          */
159         AppUiState GetAppUiState(void) const;
160
161         /**
162          * Called when a UI application moves to the foreground. @n
163          * User interaction is enabled when the UI application moves to the foreground. @n
164          * A UI application moves to the foreground when:
165          *
166          * - A UI application is selected from the Task Manager.
167          * - A UI application icon in the Launcher application is pressed when it is running in the background.
168          * - A UI application is to be launched while it is running in the background.
169          * - A system pop-up, such as an incoming call, notification (for example, SMS), or a low battery warning
170          *    pop-up disappears.
171          *
172          * %OnForeground() is called when the UI application is moved to the foreground. @n
173          * When this method is invoked, the following actions are recommended:
174          *
175          * - Resume the graphic processing, such as 3D or animation, as the UI application now has the focus.
176          * - Resume the operations that stopped when the UI application is last moved to the background.
177          *
178          * @since       2.0
179          *
180          * @remarks      When the system needs to refresh a screen component, it can call this method even if the UI application is present in the foreground.
181          */
182         virtual void OnForeground(void);
183
184         /**
185          * Called when another UI application moves to the top or a system pop-up is displayed. @n
186          * User interaction is disabled when the UI application is in the background. @n
187          * A UI application moves to the background when:
188          *
189          * - A system pop-up, such as an incoming call or a low battery warning pop-up is displayed.
190          * - A device is locked.
191          * - The Home key is pressed.
192          *
193          * %OnBackground() is called when the UI application is moved to the background. @n
194          * Whenever this method is invoked, the following actions are recommended:
195          *
196          * - Stop the graphic processing, such as 3D or animation, as they will not be displayed.
197          * - Release unnecessary resources.
198          * - Stop media processing, sensor manipulations, and location updates.
199          *
200          * @since       2.0
201          *
202          * @remarks     When notification (for example, SMS) pops up, this method is not called.
203          *                      When a system pop-up is displayed, a UI application becomes partially hidden
204          *                      (App::APP_UI_STATE_PARTIAL_BACKGROUND).
205          *                      If a UI application is partially hidden, it is recommended to hold the activated
206          *                      tasks or resources instead of stopping or releasing them.
207          * @see GetAppUiState()
208          */
209         virtual void OnBackground(void);
210
211         /**
212         * Gets the %UiApp instance's pointer.
213         *
214         * @since        2.0
215         *
216         * @return       A pointer to the %UiApp instance, @n
217         *                       else @c null if it fails
218         */
219         static UiApp* GetInstance(void);
220
221         /**
222          * Executes an application implemented by inheriting this class.
223          * The %Execute() method must be called from the entry method - OspMain(), which is generated by IDE.
224          *
225          * @since       2.0
226          *
227          * @return      An error code
228          * @param[in]   pUiAppFactory         The factory method that creates this UiApp's instance
229          * @param[in]   pArguments           The launch arguments for %App
230          * @exception   E_SUCCESS           The method is successful.
231          * @exception   E_INVALID_ARG       A specified input parameter is invalid.
232          * @exception   E_OUT_OF_MEMORY     The memory is insufficient.
233          * @exception   E_INIT_FAILED       The initialization failure during OnAppInitializing().
234          * @exception   E_SYSTEM            A system error has occurred.
235          */
236         static result Execute(UiAppInstanceFactory pUiAppFactory, const Tizen::Base::Collection::IList* pArguments);
237
238 protected:
239         /**
240          * This is the default constructor for this class.
241          *
242          * @since       2.0
243          */
244         UiApp(void);
245
246         //
247         // This method is for internal use only.
248         // Using this method can cause behavioral, security-related, and consistency-related issues in the application.
249         //
250         // This method is reserved and may change its name at any time without prior notice.
251         //
252         // @since       2.0
253         //
254         virtual void UiApp_Reserved1(void) {}
255
256         //
257         // This method is for internal use only.
258         // Using this method can cause behavioral, security-related, and consistency-related issues in the application.
259         //
260         // This method is reserved and may change its name at any time without prior notice.
261         //
262         // @since       2.0
263         //
264         virtual void UiApp_Reserved2(void) {}
265
266         //
267         // This method is for internal use only.
268         // Using this method can cause behavioral, security-related, and consistency-related issues in the application.
269         //
270         // This method is reserved and may change its name at any time without prior notice.
271         //
272         // @since       2.0
273         //
274         virtual void UiApp_Reserved3(void) {}
275
276 private:
277         /**
278          * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
279          *
280          * @since       2.0
281          */
282         UiApp(const UiApp& rhs);
283
284         /**
285          * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
286          *
287          * @since       2.0
288          */
289         UiApp& operator =(const UiApp& rhs);
290
291 private:
292         class _UiAppImpl* __pUiAppImpl;
293 }; // UiApp
294
295 typedef UiApp Application;
296
297 } } //Tizen::App
298
299 #endif // _FAPP_UI_APP_H_