Bump version to 0.127
[platform/framework/web/tizen-extensions-crosswalk.git] / power / power_event_source_tizen.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 #ifndef POWER_POWER_EVENT_SOURCE_TIZEN_H_
6 #define POWER_POWER_EVENT_SOURCE_TIZEN_H_
7
8 #include <power.h>
9 #include <list>
10
11 class PowerEventListener {
12  public:
13   virtual void OnPowerStateChanged(power_state_e state) = 0;
14  protected:
15   // We don't use listener interface to destroy them, so protected and
16   // non-virtual destructor is fine.
17   ~PowerEventListener() {}
18 };
19
20 // Track power changed events from Tizen native library. The library supports
21 // only one callback, so this class multiplexes to the different instances that
22 // maybe listening for event changes.
23 class PowerEventSource {
24  public:
25   PowerEventSource();
26   ~PowerEventSource();
27
28   void AddListener(PowerEventListener* listener);
29   void RemoveListener(PowerEventListener* listener);
30
31  private:
32   // Handler for callback in power.h library.
33   static void OnPowerChangedCallback(power_state_e state, void* user_data);
34
35   void DispatchEvent(power_state_e state);
36
37   std::list<PowerEventListener*> listeners_;
38 };
39
40 #endif  // POWER_POWER_EVENT_SOURCE_TIZEN_H_