[FIX] scenemanager: too small buffer
[platform/core/system/swap-probe.git] / probe_event / da_event.c
1 /*
2  *  DA probe
3  *
4  * Copyright (c) 2000 - 2013 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  * Anastasia Lyupa <a.lyupa@samsung.com>
12  *
13  * This library is free software; you can redistribute it and/or modify it under
14  * the terms of the GNU Lesser General Public License as published by the
15  * Free Software Foundation; either version 2.1 of the License, or (at your option)
16  * any later version.
17  *
18  * This library is distributed in the hope that it will be useful, but WITHOUT ANY
19  * WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
21  * License for more details.
22  *
23  * You should have received a copy of the GNU Lesser General Public License
24  * along with this library; if not, write to the Free Software Foundation, Inc., 51
25  * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
26  *
27  * Contributors:
28  * - S-Core Co., Ltd
29  * - Samsung RnD Institute Russia
30  *
31  */
32
33 #include <appfw/app.h>
34 #include <runtime_info.h>
35
36 #include <Ecore.h>
37 #include <Eina.h>
38 #include <Ecore_X.h>
39
40 #include "daprobe.h"
41 #include "dahelper.h"
42 #include "da_event.h"
43
44 #include "binproto.h"
45
46 static int external_angle = 0;
47 static int internal_angle = 0;
48
49 // ===================================================================
50 // orientation related functions
51 // ===================================================================
52
53 static int convert_angle(int angle)
54 {
55         int os = _OS_NONE;
56
57         switch(angle)
58         {
59         case 0:
60                 os = _OS_PORTRAIT;
61                 break;
62         case 90:
63                 os = _OS_LANDSCAPE_REVERSE;
64                 break;
65         case 180:
66                 os = _OS_PORTRAIT_REVERSE;
67                 break;
68         case 270:
69                 os = _OS_LANDSCAPE;
70                 break;
71         default:
72                 break;
73         }
74
75         return os;
76 }
77
78 void on_orientation_changed(int angle, bool capi)
79 {
80         probeInfo_t     probeInfo;
81         bool autoRotation = true;
82
83         probeBlockStart();
84
85         internal_angle = angle;
86         if(runtime_info_get_value_bool(
87                         RUNTIME_INFO_KEY_AUTO_ROTATION_ENABLED, &autoRotation) < 0)
88         {
89                 PRINTMSG("ERROR: could not get auto rotation value!\n");
90         }
91
92         if(autoRotation)        // rotation is not locked
93         {
94                 external_angle = internal_angle;
95
96                 if(isOptionEnabled(OPT_EVENT))
97                 {
98                         setProbePoint(&probeInfo);
99
100                         PREPARE_LOCAL_BUF();
101                         PACK_COMMON_BEGIN(MSG_PROBE_UIEVENT,
102                                           API_ID_on_orientation_changed,
103                                           "dd", angle, (uint32_t)capi);
104                         PACK_COMMON_END('v', 0, 0, 0);
105                         PACK_UIEVENT(_EVENT_ORIENTATION, 0, 0, 0, "", convert_angle(external_angle));
106                         FLUSH_LOCAL_BUF();
107                 }
108
109                 SCREENSHOT_SET();
110 //              if(!capi)
111 //              {
112 //                      SCREENSHOT_DONE();
113 //              }
114         }
115         else { }        // do nothing
116
117         probeBlockEnd();
118 }
119
120 int getOrientation()
121 {
122         return external_angle;
123 }
124
125 // ====================================================================
126 // initialize and finalize event
127 // ====================================================================
128
129 int initialize_event()
130 {
131         external_angle = internal_angle = app_get_device_orientation();
132         return 0;
133 }
134
135 int finalize_event()
136 {
137         return 0;
138 }
139
140