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