Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / xwalk / tizen / mobile / sensor / tizen_platform_sensor.h
1 // Copyright (c) 2013 Intel Corporation. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 //
5 // Part of codes are copied from libslp-sensor with original copyright
6 // and license as below.
7 //
8 // Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
9 //
10 // Licensed under the Apache License, Version 2.0 (the "License");
11 // you may not use this file except in compliance with the License.
12 // You may obtain a copy of the License at
13 //
14 // http://www.apache.org/licenses/LICENSE-2.0
15
16 #ifndef XWALK_TIZEN_MOBILE_SENSOR_TIZEN_PLATFORM_SENSOR_H_
17 #define XWALK_TIZEN_MOBILE_SENSOR_TIZEN_PLATFORM_SENSOR_H_
18
19 #include <sensor.h>
20 #include <vconf.h>
21
22 #include "base/native_library.h"
23 #include "base/threading/thread.h"
24 #include "xwalk/tizen/mobile/sensor/sensor_provider.h"
25
26 namespace xwalk {
27
28 class TizenPlatformSensor : public SensorProvider {
29  public:
30   TizenPlatformSensor();
31   virtual ~TizenPlatformSensor();
32
33   virtual bool Initialize() OVERRIDE;
34   virtual void Finish() OVERRIDE;
35
36  private:
37   bool auto_rotation_enabled_;
38   int accel_handle_;
39   int gyro_handle_;
40
41   static void OnEventReceived(unsigned int event_type,
42       sensor_event_data_t* event_data, void* udata);
43   static void OnAutoRotationEnabledChanged(keynode_t* node, void* udata);
44
45   void ConnectSensor();
46
47   scoped_ptr<base::Thread> sensor_thread_;
48
49   DISALLOW_COPY_AND_ASSIGN(TizenPlatformSensor);
50 };
51
52 }  // namespace xwalk
53
54 #endif  // XWALK_TIZEN_MOBILE_SENSOR_TIZEN_PLATFORM_SENSOR_H_