6c60b540444baf867a280f22d0ff083d58a7dfb7
[platform/core/uifw/dali-adaptor.git] / adaptors / wearable / watch / watch-time.cpp
1 /*
2  * Copyright (c) 2016 Samsung Electronics Co., Ltd.
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
18 // CLASS HEADER
19 #include <wearable/watch/watch-time.h>
20
21 // EXTERNAL INCLUDES
22 #ifdef APPCORE_WATCH_AVAILABLE
23 #include <appcore-watch/watch_app.h>
24 #endif
25
26 namespace Dali
27 {
28
29 struct WatchTime::Impl
30 {
31   Impl(void *time_handle)
32   : mTimeHandle(time_handle)
33   {
34   }
35
36   void *mTimeHandle;
37 };
38
39 WatchTime::WatchTime(void *time_handle)
40 {
41   mImpl = new Impl(time_handle);
42 }
43
44 WatchTime::~WatchTime()
45 {
46   if( mImpl )
47   {
48     delete mImpl;
49     mImpl = NULL;
50   }
51 }
52
53 #ifdef APPCORE_WATCH_AVAILABLE
54
55 WatchTime::WatchTime()
56 {
57   watch_time_h watch_time = {0,};
58
59   watch_time_get_current_time(&watch_time);
60   mImpl = new Impl(watch_time);
61 }
62
63 int WatchTime::GetHour() const
64 {
65   int hour;
66
67   watch_time_get_hour(reinterpret_cast<watch_time_h>(mImpl->mTimeHandle), &hour);
68   return hour;
69 }
70
71 int WatchTime::GetHour24() const
72 {
73   int hour24;
74
75   watch_time_get_hour24(reinterpret_cast<watch_time_h>(mImpl->mTimeHandle), &hour24);
76   return hour24;
77 }
78
79 int WatchTime::GetMinute() const
80 {
81   int minute;
82
83   watch_time_get_minute(reinterpret_cast<watch_time_h>(mImpl->mTimeHandle), &minute);
84   return minute;
85 }
86
87 int WatchTime::GetSecond() const
88 {
89   int second;
90
91   watch_time_get_second(reinterpret_cast<watch_time_h>(mImpl->mTimeHandle), &second);
92   return second;
93 }
94
95 #else
96 WatchTime::WatchTime()
97   :mImpl(NULL)
98 {
99 }
100
101 int WatchTime::GetHour() const
102 {
103   return 0;
104 }
105
106 int WatchTime::GetHour24() const
107 {
108   return 0;
109 }
110
111 int WatchTime::GetMinute() const
112 {
113   return 0;
114 }
115
116 int WatchTime::GetSecond() const
117 {
118   return 0;
119 }
120
121 #endif
122
123 } // namespace Dali