Implement WatchApplication class
[platform/core/uifw/dali-adaptor.git] / adaptors / common / 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 <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()
40   :mImpl(NULL)
41 {
42 }
43
44 WatchTime::WatchTime(void *time_handle)
45 {
46   mImpl = new Impl(time_handle);
47 }
48
49 WatchTime::~WatchTime()
50 {
51   if( mImpl )
52   {
53     delete mImpl;
54     mImpl = NULL;
55   }
56 }
57
58 #ifdef APPCORE_WATCH_AVAILABLE
59
60 int WatchTime::GetHour() const
61 {
62   int hour;
63
64   watch_time_get_hour(reinterpret_cast<watch_time_h>(mImpl->mTimeHandle), &hour);
65   return hour;
66 }
67
68 int WatchTime::GetHour24() const
69 {
70   int hour24;
71
72   watch_time_get_hour24(reinterpret_cast<watch_time_h>(mImpl->mTimeHandle), &hour24);
73   return hour24;
74 }
75
76 int WatchTime::GetMinute() const
77 {
78   int minute;
79
80   watch_time_get_minute(reinterpret_cast<watch_time_h>(mImpl->mTimeHandle), &minute);
81   return minute;
82 }
83
84 int WatchTime::GetSecond() const
85 {
86   int second;
87
88   watch_time_get_second(reinterpret_cast<watch_time_h>(mImpl->mTimeHandle), &second);
89   return second;
90 }
91
92 #else
93
94 int WatchTime::GetHour() const
95 {
96   return 0;
97 }
98
99 int WatchTime::GetHour24() const
100 {
101   return 0;
102 }
103
104 int WatchTime::GetMinute() const
105 {
106   return 0;
107 }
108
109 int WatchTime::GetSecond() const
110 {
111   return 0;
112 }
113
114 #endif
115
116 } // namespace Dali