[FEATURE] Osp: total remove
[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
82         probeBlockStart();
83
84         internal_angle = angle;
85         external_angle = internal_angle;
86
87         if(isOptionEnabled(OPT_EVENT))
88         {
89                 setProbePoint(&probeInfo);
90
91                 PREPARE_LOCAL_BUF();
92                 PACK_COMMON_BEGIN(MSG_PROBE_UIEVENT,
93                                   API_ID_on_orientation_changed,
94                                   "dd", angle, (uint32_t)capi);
95                 PACK_COMMON_END('v', 0, 0, 0);
96                 PACK_UIEVENT(_EVENT_ORIENTATION, 0, 0, 0, "", convert_angle(external_angle));
97                 FLUSH_LOCAL_BUF();
98         }
99
100         SCREENSHOT_SET();
101 //      if(!capi)
102 //      {
103 //              SCREENSHOT_DONE();
104 //      }
105
106         probeBlockEnd();
107 }
108
109 int getOrientation()
110 {
111         return external_angle;
112 }
113
114 // ====================================================================
115 // initialize and finalize event
116 // ====================================================================
117
118 int initialize_event()
119 {
120         external_angle = internal_angle = app_get_device_orientation();
121         return 0;
122 }
123
124 int finalize_event()
125 {
126         return 0;
127 }
128
129