#ifndef __CONTEXT_TIMER_MANAGER_H__
#define __CONTEXT_TIMER_MANAGER_H__
+#include <timer_types.h>
+
namespace ctx {
/* Forward Declaration */
class timer_listener_iface;
namespace timer_manager {
- enum day_of_week_e {
- SUN = 0x01,
- MON = 0x02,
- TUE = 0x04,
- WED = 0x08,
- THU = 0x10,
- FRI = 0x20,
- SAT = 0x40,
- WEEKDAY = MON | TUE | WED | THU | FRI,
- WEEKEND = SAT | SUN,
- EVERYDAY = SUN | MON | TUE | WED | THU | FRI | SAT,
- };
-
/**
* @brief Sets a repeated timer for a given interval of time (s).
* @details It is recommended to minize the number of timers initiated, to reduce battery consumptions.
--- /dev/null
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __CONTEXT_TIMER_TYPES_H__
+#define __CONTEXT_TIMER_TYPES_H__
+
+#include <string>
+
+#define MAX_HOUR 24
+#define MAX_DAY 7
+
+#define TIMER_TYPES_MON "Mon"
+#define TIMER_TYPES_TUE "Tue"
+#define TIMER_TYPES_WED "Wed"
+#define TIMER_TYPES_THU "Thu"
+#define TIMER_TYPES_FRI "Fri"
+#define TIMER_TYPES_SAT "Sat"
+#define TIMER_TYPES_SUN "Sun"
+#define TIMER_TYPES_WEEKDAY "Weekday"
+#define TIMER_TYPES_WEEKEND "Weekend"
+#define TIMER_TYPES_EVERYDAY "Everyday"
+
+namespace ctx {
+
+ namespace timer_types {
+
+ enum day_of_week_e {
+ SUN = 0x01,
+ MON = 0x02,
+ TUE = 0x04,
+ WED = 0x08,
+ THU = 0x10,
+ FRI = 0x20,
+ SAT = 0x40,
+ WEEKDAY = MON | TUE | WED | THU | FRI,
+ WEEKEND = SAT | SUN,
+ EVERYDAY = SUN | MON | TUE | WED | THU | FRI | SAT,
+ };
+
+ }
+} /* namespace ctx */
+
+#endif /* __CONTEXT_TIMER_TYPES_H__ */
--- /dev/null
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __CONTEXT_TIMER_UTIL_H__
+#define __CONTEXT_TIMER_UTIL_H__
+
+#include <string>
+#include <timer_types.h>
+
+namespace ctx {
+
+ namespace timer_util {
+
+ std::string convert_day_of_week_int_to_string(int d);
+ int convert_day_of_week_string_to_int(std::string d);
+
+ }
+} /* namespace ctx */
+
+#endif /* __CONTEXT_TIMER_UTIL_H__ */
--- /dev/null
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <timer_util.h>
+
+using namespace ctx::timer_types;
+
+std::string ctx::timer_util::convert_day_of_week_int_to_string(int d)
+{
+ switch(d) {
+ case SUN:
+ return TIMER_TYPES_SUN;
+ case MON:
+ return TIMER_TYPES_MON;
+ case TUE:
+ return TIMER_TYPES_TUE;
+ case WED:
+ return TIMER_TYPES_WED;
+ case THU:
+ return TIMER_TYPES_THU;
+ case FRI:
+ return TIMER_TYPES_FRI;
+ case SAT:
+ return TIMER_TYPES_SAT;
+ case WEEKDAY:
+ return TIMER_TYPES_WEEKDAY;
+ case WEEKEND:
+ return TIMER_TYPES_WEEKEND;
+ case EVERYDAY:
+ return TIMER_TYPES_EVERYDAY;
+ default:
+ break;
+ }
+
+ return "";
+}
+
+int ctx::timer_util::convert_day_of_week_string_to_int(std::string d)
+{
+ int day = 0;
+
+ if (d.compare(TIMER_TYPES_SUN) == 0) {
+ day = SUN;
+ } else if (d.compare(TIMER_TYPES_MON) == 0) {
+ day = MON;
+ } else if (d.compare(TIMER_TYPES_TUE) == 0) {
+ day = TUE;
+ } else if (d.compare(TIMER_TYPES_WED) == 0) {
+ day = WED;
+ } else if (d.compare(TIMER_TYPES_THU) == 0) {
+ day = THU;
+ } else if (d.compare(TIMER_TYPES_FRI) == 0) {
+ day = FRI;
+ } else if (d.compare(TIMER_TYPES_SAT) == 0) {
+ day = SAT;
+ } else if (d.compare(TIMER_TYPES_WEEKDAY) == 0) {
+ day = WEEKDAY;
+ } else if (d.compare(TIMER_TYPES_WEEKEND) == 0) {
+ day = WEEKEND;
+ } else if (d.compare(TIMER_TYPES_EVERYDAY) == 0) {
+ day = EVERYDAY;
+ }
+
+ return day;
+}