d3d717deb3d447a3448cab34c9ea5d04e77eb556
[framework/system/dynamic-analysis-probe.git] / probe_event / da_event.c
1 /*
2  *  DA probe
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: 
7  *
8  * Jaewon Lim <jaewon81.lim@samsung.com>
9  * Woojin Jung <woojin2.jung@samsung.com>
10  * Juyoung Kim <j0.kim@samsung.com>
11  * 
12  * This library is free software; you can redistribute it and/or modify it under
13  * the terms of the GNU Lesser General Public License as published by the
14  * Free Software Foundation; either version 2.1 of the License, or (at your option)
15  * any later version.
16  * 
17  * This library is distributed in the hope that it will be useful, but WITHOUT ANY
18  * WARRANTY; without even the implied warranty of MERCHANTABILITY or
19  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
20  * License for more details.
21  *
22  * You should have received a copy of the GNU Lesser General Public License
23  * along with this library; if not, write to the Free Software Foundation, Inc., 51
24  * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
25  *
26  * Contributors:
27  * - S-Core Co., Ltd
28  * 
29  */
30
31 #include <appfw/app.h>
32 #include <runtime_info.h>
33
34 #include <Ecore.h>
35 #include <Eina.h>
36 #include <Ecore_X.h>
37
38 #include "daprobe.h"
39 #include "dahelper.h"
40 #include "da_event.h"
41
42 static int external_angle = 0;
43 static int internal_angle = 0;
44
45 // ===================================================================
46 // orientation related functions
47 // ===================================================================
48
49 static int convert_angle(int angle)
50 {
51         int os = _OS_NONE;
52
53         switch(angle)
54         {
55         case 0:
56                 os = _OS_PORTRAIT;
57                 break;
58         case 90:
59                 os = _OS_LANDSCAPE_REVERSE;
60                 break;
61         case 180:
62                 os = _OS_PORTRAIT_REVERSE;
63                 break;
64         case 270:
65                 os = _OS_LANDSCAPE;
66                 break;
67         default:
68                 break;
69         }
70
71         return os;
72 }
73
74 void on_orientation_changed(int angle, bool capi)
75 {
76         DECLARE_COMMON_VARIABLE;
77         bool autoRotation = true;
78
79         probeBlockStart();
80
81         internal_angle = angle;
82         runtime_info_get_value_bool(
83                         RUNTIME_INFO_KEY_AUTO_ROTATION_ENABLED, &autoRotation);
84
85         if(autoRotation)        // rotation is not locked
86         {
87                 external_angle = internal_angle;
88
89                 if(isOptionEnabled(OPT_EVENT))
90                 {
91                         setProbePoint(&probeInfo);
92                         INIT_LOG;
93                         APPEND_LOG_BASIC_NAME(LC_UIEVENT, "OrientationChanged");
94                         APPEND_LOG_COMMON_NONE(0);
95                         log.length += sprintf(log.data + log.length, "`,%d`,`,`,`,%d`,",
96                                         _EVENT_ORIENTATION, convert_angle(external_angle));
97                         printLog(&log, MSG_LOG);
98                 }
99
100                 SCREENSHOT_SET();
101 //              if(!capi)
102 //              {
103 //                      SCREENSHOT_DONE();
104 //              }
105         }
106         else { }        // do nothing
107
108         probeBlockEnd();
109 }
110
111 int getOrientation()
112 {
113         return external_angle;
114 }
115
116 // ====================================================================
117 // initialize and finalize event
118 // ====================================================================
119
120 int initialize_event()
121 {
122         external_angle = internal_angle = app_get_device_orientation();
123         return 0;
124 }
125
126 int finalize_event()
127 {
128         return 0;
129 }
130
131