tizen 2.4 release
[framework/context/context-common.git] / include / timer_mgr.h
1 /*
2  * Copyright (c) 2015 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 #ifndef __CONTEXT_TIMER_MANAGER_H__
18 #define __CONTEXT_TIMER_MANAGER_H__
19
20 namespace ctx {
21         /* Forward Declaration */
22         class timer_listener_iface;
23
24         namespace timer_manager {
25
26                 enum day_of_week_e {
27                         SUN = 0x01,
28                         MON = 0x02,
29                         TUE = 0x04,
30                         WED = 0x08,
31                         THU = 0x10,
32                         FRI = 0x20,
33                         SAT = 0x40,
34                         WEEKDAY = MON | TUE | WED | THU | FRI,
35                         WEEKEND = SAT | SUN,
36                         EVERYDAY = SUN | MON | TUE | WED | THU | FRI | SAT,
37                 };
38
39                 /**
40                  * @brief               Sets a repeated timer for a given interval of time (s).
41                  * @details             It is recommended to minize the number of timers initiated, to reduce battery consumptions.
42                  *                              If it is possible to share a timer for multiple purposes, please do that.
43                  * @param[in]   interval        Timer interval. The first timer will be expired after @c interval minutes,
44                  *                                                      and will be repeated until the listener returns @c false.
45                  * @param[in]   listener        A listner object to be notified.
46                  * @return              Timer ID. A negative integer if failed to set a timer.
47                  */
48                 int set_for(int interval, timer_listener_iface* listener, void* user_data = NULL);
49
50                 /**
51                  * @brief               Sets a timer that will be expired at a specific time, at designated days of week.
52                  * @details             It is recommended to minize the number of timers initiated, to reduce battery consumptions.
53                  *                              If it is possible to share a timer for multiple purposes, please do that.
54                  * @param[in]   hour            Hour
55                  * @param[in]   min                     Minute
56                  * @param[in]   day_of_week     The timer will expire at hour:min:00, at every day(s) of week designated here.
57                  * @param[in]   listener        Listener object.
58                  * @return              Timer ID. A negative integer if failed to set a timer.
59                  */
60                 int set_at(int hour, int min, int day_of_week, timer_listener_iface* listener, void* user_data = NULL);
61
62                 /**
63                  * @brief               Removes the timer specified by @c timer_id.
64                  */
65                 void remove(int timer_id);
66         }
67 }       /* namespace ctx */
68
69 #endif  /* __CONTEXT_TIMER_MANAGER_H__ */