2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #include <dpl/log/log.h>
21 #include <CommonsJavaScript/Converter.h>
22 #include <CommonsJavaScript/Validator.h>
23 #include <CommonsJavaScript/JSUtils.h>
24 #include <CommonsJavaScript/JSDOMExceptionFactory.h>
25 #include "AlarmRecurrence.h"
26 #include "JSAlarmRecurrence.h"
27 #include "AlarmConverter.h"
35 using namespace WrtDeviceApis::Commons;
36 using namespace WrtDeviceApis::CommonsJavaScript;
37 using namespace TizenApis::Tizen1_0::Alarm;
38 using namespace TizenApis::Api::Alarm;
40 AlarmConverter::AlarmConverter(JSContextRef context) : WrtDeviceApis::CommonsJavaScript::Converter(context)
45 AlarmConverter::~AlarmConverter()
50 AlarmRecurrence::alarm_frequency_e AlarmConverter::toRecurrenceFrequency(
51 std::string tizenValue) const
53 if (!tizenValue.compare(TIZEN_ALARM_PROPERTY_MINUTELY_RECURRENCE))
54 return AlarmRecurrence::MINUTELY_RECURRENCE;
55 else if (!tizenValue.compare(TIZEN_ALARM_PROPERTY_HOURLY_RECURRENCE))
56 return AlarmRecurrence::HOURLY_RECURRENCE;
57 else if (!tizenValue.compare(TIZEN_ALARM_PROPERTY_DAILY_RECURRENCE))
58 return AlarmRecurrence::DAILY_RECURRENCE;
59 else if (!tizenValue.compare(TIZEN_ALARM_PROPERTY_WEEKLY_RECURRENCE))
60 return AlarmRecurrence::WEEKLY_RECURRENCE;
62 return AlarmRecurrence::NO_RECURRENCE;
65 std::string AlarmConverter::toTizenValue(
66 AlarmRecurrence::alarm_frequency_e frequency ) const
69 case AlarmRecurrence::MINUTELY_RECURRENCE:
70 return TIZEN_ALARM_PROPERTY_MINUTELY_RECURRENCE;
71 case AlarmRecurrence::HOURLY_RECURRENCE:
72 return TIZEN_ALARM_PROPERTY_HOURLY_RECURRENCE;
73 case AlarmRecurrence::DAILY_RECURRENCE:
74 return TIZEN_ALARM_PROPERTY_DAILY_RECURRENCE;
75 case AlarmRecurrence::WEEKLY_RECURRENCE:
76 return TIZEN_ALARM_PROPERTY_WEEKLY_RECURRENCE;
84 int toNativeValue(std::vector<std::string> daysOfTheWeek)
88 for( unsigned int i=0; i<daysOfTheWeek.size(); i++ )
90 if( daysOfTheWeek[i]=="SU" )
91 nativeValue = nativeValue | ALARM_WEEK_FLAG_SUNDAY;
92 else if( daysOfTheWeek[i]=="MO" )
93 nativeValue = nativeValue | ALARM_WEEK_FLAG_MONDAY ;
94 else if( daysOfTheWeek[i]=="TU" )
95 nativeValue = nativeValue | ALARM_WEEK_FLAG_TUESDAY ;
96 else if( daysOfTheWeek[i]=="WE" )
97 nativeValue = nativeValue | ALARM_WEEK_FLAG_WEDNESDAY;
98 else if( daysOfTheWeek[i]=="TH" )
99 nativeValue = nativeValue | ALARM_WEEK_FLAG_THURSDAY ;
100 else if( daysOfTheWeek[i]=="FR" )
101 nativeValue = nativeValue | ALARM_WEEK_FLAG_FRIDAY ;
102 else if( daysOfTheWeek[i]=="SA" )
103 nativeValue = nativeValue | ALARM_WEEK_FLAG_SATURDAY ;
109 service_h AlarmConverter::toService(std::string id)
112 service_create(&service);
113 LogError("[ILOVEFILM] Enter AlarmConverter toService std package = " << id.c_str());
115 service_set_operation(service, SERVICE_OPERATION_DEFAULT);
116 service_set_package(service, id.c_str());
119 service_h AlarmConverter::toService(std::string id, std::string page)
122 service_create(&service);
124 LogError("[ILOVEFILM] Enter AlarmConverter toService std package = " << id.c_str());
126 service_set_operation(service, SERVICE_OPERATION_DEFAULT);
127 service_set_package(service, id.c_str());