[FIX] dastout license
[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 #include "real_functions.h"
46
47 static int external_angle = 0;
48 static int internal_angle = 0;
49
50 // ===================================================================
51 // orientation related functions
52 // ===================================================================
53
54 static int convert_angle(int angle)
55 {
56         int os = _OS_NONE;
57
58         switch(angle)
59         {
60         case 0:
61                 os = _OS_PORTRAIT;
62                 break;
63         case 90:
64                 os = _OS_LANDSCAPE_REVERSE;
65                 break;
66         case 180:
67                 os = _OS_PORTRAIT_REVERSE;
68                 break;
69         case 270:
70                 os = _OS_LANDSCAPE;
71                 break;
72         default:
73                 break;
74         }
75
76         return os;
77 }
78
79 void on_orientation_changed(int angle, bool capi)
80 {
81         probeInfo_t     probeInfo;
82
83         probeBlockStart();
84
85         internal_angle = angle;
86         external_angle = internal_angle;
87
88         if(isOptionEnabled(OPT_EVENT))
89         {
90                 setProbePoint(&probeInfo);
91
92                 PREPARE_LOCAL_BUF();
93                 PACK_COMMON_BEGIN(MSG_PROBE_UIEVENT,
94                                   API_ID_on_orientation_changed,
95                                   "dd", angle, (uint32_t)capi);
96                 PACK_COMMON_END('v', 0, 0, 0);
97                 PACK_UIEVENT(_EVENT_ORIENTATION, 0, 0, 0, "", convert_angle(external_angle));
98                 FLUSH_LOCAL_BUF();
99         }
100
101         SCREENSHOT_SET();
102 //      if(!capi)
103 //      {
104 //              SCREENSHOT_DONE();
105 //      }
106
107         probeBlockEnd();
108 }
109
110 int getOrientation()
111 {
112         return external_angle;
113 }
114
115 // ====================================================================
116 // initialize and finalize event
117 // ====================================================================
118
119 int initialize_event()
120 {
121         external_angle = internal_angle = app_get_device_orientation();
122         return 0;
123 }
124
125 int finalize_event()
126 {
127         return 0;
128 }
129
130