wrt-plugins-tizen_0.4.23
[framework/web/wrt-plugins-tizen.git] / src / Alarm / AlarmRelative.cpp
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
19 #include "AlarmRelative.h"
20 #include "alarm_common.h"
21 #include <JSTimeDuration.h>
22 #include <app.h>
23 #include <Logger.h>
24
25 namespace DeviceAPI {
26 namespace Alarm {
27
28 AlarmRelative::AlarmRelative()
29 {
30     m_isRecurrence = false;
31     service_create(&m_service_handle);
32     service_add_extra_data(m_service_handle, ALARM_TYPE_KEY, ALARM_TYPE_RELATIVE_VALUE);
33     m_Period = -1;
34     m_id = -1;
35 }
36
37 AlarmRelative::AlarmRelative(service_h handle)
38 {
39     service_clone(&m_service_handle, handle);
40     m_Period = -1;
41     m_id = -1;
42 }
43
44 AlarmRelative::~AlarmRelative()
45 {
46     service_destroy(m_service_handle);
47 }
48
49 int AlarmRelative::getId() const
50 {
51     return m_id;
52 }
53
54 void AlarmRelative::setId(const int id)
55 {
56     m_id = id;
57 }
58
59 bool AlarmRelative::isRecurrence()
60 {
61     return m_isRecurrence;
62 }
63
64 void AlarmRelative::setIsRecurrence(bool value)
65 {
66     m_isRecurrence = value;
67 }
68
69 void AlarmRelative::setDelay(int delay)
70 {
71     char result[12];
72     snprintf(result, sizeof(result), "%d", delay);
73     service_add_extra_data(m_service_handle, ALARM_RELATIVE_DELAY_KEY, result);
74     m_delay = delay;
75 }
76
77 int AlarmRelative::getDelay()
78 {
79     return m_delay;
80 }
81
82 void AlarmRelative::setPeriod(int value)
83 {
84     LoggerI("Param Peroid =  " << value);
85     m_Period = value;
86     LoggerI("Setted Period =  " << m_Period);
87 }
88
89 int AlarmRelative::getPeriod()
90 {
91     LoggerI("return Period =  " << m_Period);
92     return m_Period;
93 }
94
95 service_h AlarmRelative::getService() 
96 {
97     return m_service_handle;
98 }
99
100 }
101 }
102