Beta merge 2
[profile/ivi/wrt-plugins-tizen.git] / src / standards / Tizen / Alarm / JSAlarmRecurrence.h
1 /*
2  * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
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 _JS_TIZEN_ALARMRECURRENCE
18 #define _JS_TIZEN_ALARMRECURRENCE
19
20 #include <JavaScriptCore/JavaScript.h>
21 #include "AlarmRecurrence.h"
22
23 namespace TizenApis {
24 namespace Tizen1_0 {
25 namespace Alarm {
26
27 using namespace TizenApis::Api::Alarm;
28
29 typedef WrtDeviceApis::CommonsJavaScript::PrivateObject<AlarmRecurrencePtr, WrtDeviceApis::CommonsJavaScript::NoOwnership> JSAlarmRecurrencePriv;
30
31
32 #define TIZEN_ALARM_PROPERTY_MINUTELY_RECURRENCE    "MINUTELY"
33 #define TIZEN_ALARM_PROPERTY_HOURLY_RECURRENCE   "HOURLY"
34 #define TIZEN_ALARM_PROPERTY_DAILY_RECURRENCE    "DAILY"
35 #define TIZEN_ALARM_PROPERTY_WEEKLY_RECURRENCE   "WEEKLY"
36
37 class JSAlarmRecurrence {
38 public:
39     static const JSClassDefinition* getClassInfo();
40     static const JSClassRef getClassRef();
41     static JSObjectRef createJSObject(JSContextRef context, std::vector<std::string> daysOfTheWeek);
42     static JSObjectRef createJSObject(JSContextRef context, AlarmRecurrence::alarm_frequency_e frequency, int interval);
43     
44
45 protected:
46     static void initialize(JSContextRef context, JSObjectRef object);
47     static void finalize(JSObjectRef object);
48     static bool hasInstance(JSContextRef context, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception);
49     static JSObjectRef constructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
50     
51 private:
52     static AlarmRecurrencePtr getPrivData(JSObjectRef object);
53     static JSValueRef getFrequency(JSContextRef context,
54                                         JSObjectRef object,
55                                         JSStringRef propertyName,
56                                         JSValueRef* exception);
57
58     static bool setFrequency(JSContextRef context,
59                                         JSObjectRef object,
60                                         JSStringRef propertyName,
61                                         JSValueRef value,
62                                         JSValueRef* exception);
63     
64     static JSValueRef getInterval(JSContextRef context,
65                                         JSObjectRef object,
66                                         JSStringRef propertyName,
67                                         JSValueRef* exception);
68     
69     static bool setInterval(JSContextRef context,
70                                         JSObjectRef object,
71                                         JSStringRef propertyName,
72                                         JSValueRef value,
73                                         JSValueRef* exception);
74     
75     static JSValueRef getDaysOfTheWeek(JSContextRef context,
76                                         JSObjectRef object,
77                                         JSStringRef propertyName,
78                                         JSValueRef* exception);
79     
80     static bool setDaysOfTheWeek(JSContextRef context,
81                                         JSObjectRef object,
82                                         JSStringRef propertyName,
83                                         JSValueRef value,
84                                         JSValueRef* exception);
85
86     static JSClassDefinition m_jsClassInfo;
87     static JSClassRef m_jsClassRef;
88     static JSStaticValue m_property[];
89 };
90
91 }// Alarm
92 } // Tizen1_0
93 } // TizenApis
94
95 #endif