Tizen 2.1 base
[sdk/ide/native-sample.git] / samples / native / cpp / Sample / Tizen C++ / FaceRecognizer / FaceRecognizer / project / src / FaceRecognizer.cpp
1 //
2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Flora License, Version 1.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.tizenopensource.org/license
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 #include "FaceRecognizer.h"
19 #include "FaceDetectionForm.h"
20
21 using namespace Osp::App;
22 using namespace Osp::Base;
23 using namespace Osp::Graphics;
24 using namespace Osp::Io;
25 using namespace Osp::System;
26 using namespace Osp::Text;
27 using namespace Osp::Ui;
28 using namespace Osp::Ui::Controls;
29
30 FaceRecognizer::FaceRecognizer()
31 {
32 }
33
34 FaceRecognizer::~FaceRecognizer()
35 {
36 }
37
38 Application*
39 FaceRecognizer::CreateInstance(void)
40 {
41         // Create the instance through the constructor.
42         return new FaceRecognizer();
43 }
44
45 bool
46 FaceRecognizer::OnAppInitializing(AppRegistry& appRegistry)
47 {
48         // Initialize UI resources and application specific data.
49         // The application's permanent data and context can be obtained from the appRegistry.
50         //
51         // If this method is successful, return true; otherwise, return false.
52         // If this method returns false, the application will be terminated.
53
54         FaceDetectionForm *pForm = new FaceDetectionForm();
55         pForm->Construct(FORM_STYLE_NORMAL | FORM_STYLE_HEADER |FORM_STYLE_INDICATOR);
56
57         // Set Header
58         Header* pHeader = pForm->GetHeader();
59         pHeader->SetTitleText(L"Face Recognizer");
60
61         result  r = GetAppFrame()->GetFrame()->AddControl(*pForm);
62         if (IsFailed(r))
63         {
64                 AppLog("Failed to attach FormMgr to the frame\n");
65                 return false;
66         }
67
68         // Uncomment the following statement to listen to the screen on/off events.
69         //PowerManager::SetScreenEventListener(*this);
70         pForm->Draw();
71
72         return true;
73 }
74
75 bool
76 FaceRecognizer::OnAppTerminating(AppRegistry& appRegistry, bool forcedTermination)
77 {
78         // Deallocate resources allocated by this application for termination.
79         // The application's permanent data and context can be saved via appRegistry.
80         return true;
81 }
82
83 void
84 FaceRecognizer::OnForeground(void)
85 {
86         // Start or resume drawing when the application is moved to the foreground.
87 }
88
89 void
90 FaceRecognizer::OnBackground(void)
91 {
92         // Stop drawing when the application is moved to the background.
93 }
94
95 void
96 FaceRecognizer::OnLowMemory(void)
97 {
98         // Free unused resources or close the application.
99 }
100
101 void
102 FaceRecognizer::OnBatteryLevelChanged(BatteryLevel batteryLevel)
103 {
104         // Handle any changes in battery level here.
105         // Stop using multimedia features(camera, mp3 etc.) if the battery level is CRITICAL.
106 }
107
108 void
109 FaceRecognizer::OnScreenOn (void)
110 {
111         // Get the released resources or resume the operations that were paused or stopped in OnScreenOff().
112 }
113
114 void
115 FaceRecognizer::OnScreenOff (void)
116 {
117         //  Unless there is a strong reason to do otherwise, release resources (such as 3D, media, and sensors) to allow the device to enter the sleep mode to save the battery.
118         // Invoking a lengthy asynchronous method within this listener method can be risky, because it is not guaranteed to invoke a callback before the device enters the sleep mode.
119         // Similarly, do not perform lengthy operations in this listener method. Any operation must be a quick one.
120 }