2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.1 (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://floralicense.org/license/
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.
19 * @brief Keeps implementation of UiApp derived class.
24 #include "HmHomeApp.h"
25 #include "HmHomeForm.h"
26 #include "HmMainFrame.h"
27 #include "HmHomePresentationModel.h"
29 using namespace Tizen::App;
30 using namespace Tizen::Base;
31 using namespace Tizen::Base::Collection;
32 using namespace Tizen::System;
33 using namespace Tizen::Ui;
34 using namespace Tizen::Ui::Controls;
37 HomeApp::HomeApp(void)
38 : __presentationModelInitialized(false)
40 , __pPresentationModel(null)
42 //No implementation needed
45 HomeApp::~HomeApp(void)
47 //No implementation needed
51 HomeApp::CreateInstance(void)
53 // Create the instance through the constructor.
54 return new (std::nothrow) HomeApp();
58 HomeApp::OnAppInitialized(void)
61 MainFrame* pMainFrame = null;
65 pMainFrame = new (std::nothrow) MainFrame();
66 r = pMainFrame->Construct();
67 TryCatch(r == E_SUCCESS, retVal = false, " pHmMainFrame.>Construct() failed with error %s", GetErrorMessage(r));
68 r = AddFrame(*pMainFrame);
69 TryCatch(r == E_SUCCESS, retVal = false;
71 pMainFrame = null, "AddFrame(*pHmMainFrame. failed with error %s", GetErrorMessage(r));
73 __pHomeForm = new (std::nothrow) HomeForm();
74 __pHomeForm->Initialize();
75 // Add the form to the frame
76 r = pMainFrame->AddControl(__pHomeForm);
77 TryCatch(r == E_SUCCESS, retVal = false, "pHmMainFrame.>AddControl(__pHomeForm) failed with error %s", GetErrorMessage(r));
78 // Set the current form
79 pMainFrame->SetCurrentForm(__pHomeForm);
84 if (__presentationModelInitialized)
86 __pHomeForm->InitializePageControls(__pPresentationModel);
93 if (__pHomeForm != null)
99 if (pMainFrame != null)
110 HomeApp::OnAppInitializing(AppRegistry& appRegistry)
112 __pPresentationModel = new (std::nothrow) HomePresentationModel();
113 __pPresentationModel->Construct();
118 HomeApp::OnAppWillTerminate(void)
126 HomeApp::OnAppTerminating(AppRegistry& appRegistry, bool forcedTermination)
128 // Deallocate resources allocated by this App for termination.
129 // The App's permanent data and context can be saved via appRegistry.
134 HomeApp::OnForeground(void)
136 if (__pHomeForm != null)
138 __pHomeForm->UpdateAllPages();
145 HomeApp::OnBackground(void)
148 // Stop drawing when the application is moved to the background.
153 HomeApp::OnLowMemory(void)
156 // Free unused resources or close the application.
161 HomeApp::OnBatteryLevelChanged(BatteryLevel batteryLevel)
164 // Handle any changes in battery level here.
165 // Stop using multimedia features(camera, mp3 etc.) if the battery level is CRITICAL.
170 HomeApp::OnScreenOn(void)
173 // Get the released resources or resume the operations that were paused or stopped in OnScreenOff().
178 HomeApp::OnScreenOff(void)
181 // Unless there is a strong reason to do otherwise, release resources (such as 3D, media, and sensors) to allow the device
182 // to enter the sleep mode to save the battery.
183 // Invoking a lengthy asynchronous method within this listener method can be risky, because it is not guaranteed to invoke a
184 // callback before the device enters the sleep mode.
185 // Similarly, do not perform lengthy operations in this listener method. Any operation must be a quick one.
190 HomeApp::OnUserEventReceivedN(RequestId requestId, IList* pArgs)
194 case MODEL_REQUEST_INITIALIZE:
196 __presentationModelInitialized = true;
198 if (__pHomeForm != null)
200 __pHomeForm->InitializePageControls(__pPresentationModel);
207 //no implementation required
215 pArgs->RemoveAll(true);