Update change log and spec for wrt-plugins-tizen_0.4.46
[platform/framework/web/wrt-plugins-tizen.git] / src / Systeminfo / EventWatchSysteminfo.h
1 //
2 // Tizen Web Device API
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17
18 #ifndef WRTPLUGINS_API_SYSTEMINFO_EVENT_WATCH_SYSTEMINFO_H_
19 #define WRTPLUGINS_API_SYSTEMINFO_EVENT_WATCH_SYSTEMINFO_H_
20
21 #include <ctime>
22 #include <string>
23 #include <dpl/shared_ptr.h>
24 #include <dpl/noncopyable.h>
25 #include <Commons/IEvent.h>
26 #include <JavaScriptCore/JavaScript.h>
27 #include <CommonsJavaScript/JSCallbackManager.h>
28 #include "ISysteminfo.h"
29
30 namespace DeviceAPI {
31 namespace Systeminfo {
32 class EventWatchSysteminfo;
33
34 struct BatteryPropertyValue {
35     double  level;
36     bool    isCharging;
37 };
38
39 struct CpuPropertyValue {
40     double  load;
41 };
42
43 struct StoragePropertyValue {
44     unsigned long long      capacity;
45     unsigned long long      availableCapacity;
46     bool                    isRemovable;
47 };
48
49 struct PropertyValue {
50     BatteryPropertyValue batterInfo;
51     CpuPropertyValue     cpuInfo;
52     StoragePropertyValue storageInfo[2];
53 };
54
55 class EventWatchSysteminfo : public WrtDeviceApis::Commons::IEvent<EventWatchSysteminfo>
56 {
57   private :
58         static DPL::Atomic m_uniqId;
59
60         BasePropertyPtr m_BaseProperty;
61         WatchOption      m_WatchOption;
62         void*            m_Systeminfo;
63
64         Ecore_Timer *m_initTimer;
65         long m_id;
66         int m_watchType;
67         bool m_canceled;
68         DPL::Mutex m_mutex;
69         int m_storageCnt;
70         int m_tmpStorageCnt;
71         PropertyValue m_propertyValue;
72         bool m_setLastValue;
73
74   public :
75          EventWatchSysteminfo();
76         ~EventWatchSysteminfo();
77
78         void setWatchOption(const WatchOption& watchoption);
79         WatchOption getWatchOption();
80         WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr getCallbackManager();
81         BasePropertyPtr getBasePropertyPtr();
82         void setSysteminfoPtr(void* SysteminfoPtr);
83         void setBasePropertyPtr(const BasePropertyPtr& baseProperty);
84         const char * getProperty() const;
85         const int getWatchType() const;
86         void getWatchValue(int cnt = 1);
87         int getId() const;
88         void setId(int id);
89         void processGetValue();
90         void setTimer();
91         void removeTimer();
92         void clearWatch();
93         void timeoutWatch();
94 };
95
96 typedef DPL::SharedPtr<EventWatchSysteminfo> EventWatchSysteminfoPtr;
97 }
98 }
99
100 #endif