0b322aecc01ab66e89846f09e366e5fa2f2ea496
[framework/web/wrt-plugins-common.git] / src / modules / tizen / Power / Backlight.h
1 /*
2  * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  *    Licensed under the Apache License, Version 2.0 (the "License");
5  *    you may not use this file except in compliance with the License.
6  *    You may obtain a copy of the License at
7  *
8  *        http://www.apache.org/licenses/LICENSE-2.0
9  *
10  *    Unless required by applicable law or agreed to in writing, software
11  *    distributed under the License is distributed on an "AS IS" BASIS,
12  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  *    See the License for the specific language governing permissions and
14  *    limitations under the License.
15  */
16 /**
17  * @file        Backlight.h
18  * @author      Shi Hezhang (hezhang.shi@samsung.com)
19  * @version     0.1
20  */
21
22 #ifndef WRTDEVICEAPIS_POWER_BACK_LIGHT_H_
23 #define WRTDEVICEAPIS_POWER_BACK_LIGHT_H_
24
25 #include <map>
26 #include <cstddef>
27 #include <dpl/mutex.h>
28 #include <Commons/EventReceiver.h>
29 #include <Power/IBacklight.h>
30 #include <Power/Enums.h>
31 #include <VConf/Key.h>
32 #include <Elementary.h>
33
34 namespace WrtDeviceApis {
35 namespace Power {
36
37 // Dummy event for asynchronous light on schedule
38 class EventLightOffTimer : public Commons::IEvent<EventLightOffTimer>
39 {
40 };
41
42 typedef DPL::SharedPtr<EventLightOffTimer> EventLightOffTimerPtr;
43 typedef Commons::EventRequestReceiver<EventLightOffTimer>
44             EventLightOffTimerReqReceiver;
45 typedef Commons::EventRequestReceiver<Api::EventLight> EventLightReqReceiver;
46
47 class Backlight : public Api::IBacklight,
48     public EventLightOffTimerReqReceiver,
49     public EventLightReqReceiver
50 {
51   private:
52     friend class Manager;
53
54   public:
55
56     explicit Backlight();
57     ~Backlight();
58
59     /**
60      * @see Api::IBacklight::changeState()
61      */
62     int changeState(Api::BacklightStatus state,
63             unsigned int timeout);
64
65     /**
66      * @see Api::IBacklight::changeState()
67      */
68     void changeState(const Api::EventLightPtr& event);
69
70   protected:
71     void OnRequestReceived(const EventLightOffTimerPtr& event);
72     void OnRequestReceived(const Api::EventLightPtr& event);
73
74   private:
75     int toLCDState(Api::BacklightStatus state) const;
76 };
77 typedef DPL::SharedPtr<Backlight> BacklightPtr;
78
79 } // Power
80 } // WrtDeviceApis
81
82 #endif /* WRTDEVICEAPIS_POWER_BATTERY_H_ */
83