wrt-plugins-tizen_0.4.23
[framework/web/wrt-plugins-tizen.git] / src / Alarm / JSAlarmManager.cpp
old mode 100755 (executable)
new mode 100644 (file)
index eef8a6a..d4ae5e7
@@ -124,7 +124,7 @@ JSContextRef JSAlarmManager::gContext = NULL;
 void JSAlarmManager::initialize(JSContextRef ctx, JSObjectRef object) 
 {
     gContext = ctx;
-    LogInfo("GContext = " << gContext);
+    LoggerI("GContext = " << gContext);
 }
 
 void JSAlarmManager::finalize(JSObjectRef object) 
@@ -156,7 +156,7 @@ JSValueRef JSAlarmManager::add(JSContextRef ctx, JSObjectRef object, JSObjectRef
                
                // applicationId
                std::string appId = validator.toString(1);
-               LogDebug("appId:[" << appId << "]");
+               LoggerD("appId:[" << appId << "]");
 
                // alarm
         JSObjectRef alarmObj = validator.toObject(0);
@@ -195,7 +195,7 @@ JSValueRef JSAlarmManager::add(JSContextRef ctx, JSObjectRef object, JSObjectRef
                        int err = ALARM_ERROR_NONE;
                        if(alarmType == AbsoluteRecurrence::ByDayValue) {
                                int bydayValue = converter.toNativeAlarmValue(alarmPtr->getByDayRecurrence());
-                               LogInfo("Native bydayValue = " << bydayValue);
+                               LoggerI("Native bydayValue = " << bydayValue);
                                err = alarm_schedule_with_recurrence_week_flag(service, &startDate, bydayValue, &alarm_id);
                        } else if(alarmType == AbsoluteRecurrence::Interval) {
                                int interval = alarmPtr->getInterval();
@@ -250,7 +250,7 @@ JSValueRef JSAlarmManager::add(JSContextRef ctx, JSObjectRef object, JSObjectRef
                        }
 
                } else {
-                       LogError("First parameter is not a Alarm object");
+                       LoggerE("First parameter is not a Alarm object");
                        throw TypeMismatchException("First parameter is not a Alarm object");
                }
                TIME_TRACER_ITEM_END(__FUNCTION__, 0);
@@ -279,7 +279,7 @@ JSValueRef JSAlarmManager::add(JSContextRef ctx, JSObjectRef object, JSObjectRef
                 ThrowMsg(InvalidArgumentException, "Wrong application id.");
             }
                        applicationId = converter.toString(arguments[1]);
-                       LogDebug("package:[" << applicationId << "]");
+                       LoggerD("package:[" << applicationId << "]");
                }
 
                if(JSValueIsObjectOfClass(ctx, arguments[0], JSAlarmAbsolute::getClassRef())) {
@@ -313,7 +313,7 @@ JSValueRef JSAlarmManager::add(JSContextRef ctx, JSObjectRef object, JSObjectRef
                                service_set_operation(service, SERVICE_OPERATION_DEFAULT);
                        }
 
-                       LogDebug("applicationId:[" << applicationId << "]");
+                       LoggerD("applicationId:[" << applicationId << "]");
                        service_set_app_id(service, applicationId.c_str());
 
                        AbsoluteRecurrence::Type alarmType = alarmPtr->getRecurrenceType();
@@ -321,7 +321,7 @@ JSValueRef JSAlarmManager::add(JSContextRef ctx, JSObjectRef object, JSObjectRef
                        int err = ALARM_ERROR_NONE;
                        if(alarmType == AbsoluteRecurrence::ByDayValue) {
                                int bydayValue = converter.toNativeAlarmValue(alarmPtr->getByDayRecurrence());
-                               LogInfo("Native bydayValue = " << bydayValue);
+                               LoggerI("Native bydayValue = " << bydayValue);
                                err = alarm_schedule_with_recurrence_week_flag(service, &startDate, bydayValue, &alarm_id);
                        } else if(alarmType == AbsoluteRecurrence::Interval) {
                                int interval = alarmPtr->getInterval();
@@ -333,7 +333,7 @@ JSValueRef JSAlarmManager::add(JSContextRef ctx, JSObjectRef object, JSObjectRef
                        if(err == ALARM_ERROR_NONE) {
                                alarmPtr->setId(alarm_id);
                        }else{
-                               LogDebug("err:[" << err << "]");
+                               LoggerD("err:[" << err << "]");
                                ThrowMsg(PlatformException, "Alarm scheduling failed.");
                        }
                } else if(JSValueIsObjectOfClass(ctx, arguments[0], JSAlarmRelative::getClassRef())) {
@@ -368,7 +368,7 @@ JSValueRef JSAlarmManager::add(JSContextRef ctx, JSObjectRef object, JSObjectRef
                                service_set_operation(service, SERVICE_OPERATION_DEFAULT);
                        }
 
-                       LogDebug("applicationId:[" << applicationId << "]");
+                       LoggerD("applicationId:[" << applicationId << "]");
                        service_set_app_id(service, applicationId.c_str());
 
                        int err = alarm_schedule_after_delay(service, delay, interval, &alarm_id);
@@ -376,22 +376,22 @@ JSValueRef JSAlarmManager::add(JSContextRef ctx, JSObjectRef object, JSObjectRef
                        if(err == ALARM_ERROR_NONE) {
                                alarmPtr->setId(alarm_id);
                        }else{
-                               LogDebug("err:[" << err << "]");
+                               LoggerD("err:[" << err << "]");
                        }
                } else {
                        ThrowMsg(ConversionException, "Wrong first parameter type.");
                }
        } Catch(ConversionException) {
-               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+               LoggerW("Exception: "<<_rethrown_exception.GetMessage());
                return JSTizenExceptionFactory::postException(ctx, exception, JSTizenException::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage());
        } Catch(UnsupportedException) {
-               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+               LoggerW("Exception: "<<_rethrown_exception.GetMessage());
                return JSTizenExceptionFactory::postException(ctx, exception, JSTizenException::NOT_SUPPORTED_ERROR, _rethrown_exception.GetMessage());
        } Catch(InvalidArgumentException) {
-               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+               LoggerW("Exception: "<<_rethrown_exception.GetMessage());
                return JSTizenExceptionFactory::postException(ctx, exception, JSTizenException::INVALID_VALUES_ERROR, _rethrown_exception.GetMessage());
        } Catch(Exception) {
-               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+               LoggerW("Exception: "<<_rethrown_exception.GetMessage());
                return JSTizenExceptionFactory::postException(ctx, exception, JSTizenException::UNKNOWN_ERROR, _rethrown_exception.GetMessage());
        }
        return JSValueMakeUndefined(ctx);
@@ -415,7 +415,7 @@ JSValueRef JSAlarmManager::remove(JSContextRef ctx, JSObjectRef object, JSObject
                std::stringstream(id) >> alarmId;
 
                if (alarmId <= 0) {
-                       LogError("id is wrong : " << alarmId);
+                       LoggerE("id is wrong : " << alarmId);
                        throw InvalidValuesException("Invalid ID");
                }
 
@@ -448,7 +448,7 @@ JSValueRef JSAlarmManager::removeAll(JSContextRef ctx, JSObjectRef object, JSObj
        TIME_TRACER_ITEM_END("(removeAll)alarm_cancel_all", 0);
 
        if (ALARM_ERROR_NONE != returnVal) {
-               LogInfo("Error while removing all alarms: "<<returnVal);
+               LoggerI("Error while removing all alarms: "<<returnVal);
        }
 
        TIME_TRACER_ITEM_END(__FUNCTION__, 0);
@@ -472,7 +472,7 @@ JSValueRef JSAlarmManager::get(JSContextRef ctx, JSObjectRef object, JSObjectRef
                std::stringstream(id) >> alarmId;       
 
                if (alarmId <= 0) {
-                       LogError("id is wrong : " << alarmId);
+                       LoggerE("id is wrong : " << alarmId);
                        throw InvalidValuesException("Invalid ID");
                }
 
@@ -486,7 +486,7 @@ JSValueRef JSAlarmManager::get(JSContextRef ctx, JSObjectRef object, JSObjectRef
                
                ret = service_get_extra_data(service, ALARM_TYPE_KEY, &alarmType);
                if (ret != SERVICE_ERROR_NONE) {
-                       LogError("Getting data failed: " << ret);
+                       LoggerE("Getting data failed: " << ret);
                        service_destroy(service);
                        throw UnknownException("Unknown error occurred.");
                }
@@ -536,10 +536,10 @@ JSValueRef JSAlarmManager::getAll(JSContextRef ctx, JSObjectRef object, JSObject
                
         int error = alarm_foreach_registered_alarm(alarm_iterate_callback, &alarmIds);
         if (error == ALARM_ERROR_CONNECTION_FAIL) {
-            LogWarning("Alarm system may not be ready yet.");
+            LoggerW("Alarm system may not be ready yet.");
             alarmIds.clear();
         } else if(error != ALARM_ERROR_NONE) {
-            LogInfo("Error occurred while getting all alarms: "<<error);
+            LoggerI("Error occurred while getting all alarms: "<<error);
             throw UnknownException("Unknown error occurred.");
         }
 
@@ -555,23 +555,23 @@ JSValueRef JSAlarmManager::getAll(JSContextRef ctx, JSObjectRef object, JSObject
                        
             error = alarm_get_service(alarmIds.at(i), &handle);
             if(error != ALARM_ERROR_NONE) {
-                LogInfo("Getting service failed: " << error);
+                LoggerI("Getting service failed: " << error);
                 throw NotFoundException("Alarm not found");
             }
 
             error = service_get_extra_data(handle, ALARM_TYPE_KEY, &alarmType);
             if(error != SERVICE_ERROR_NONE) {
-                LogInfo("Getting data failed: " << error);
+                LoggerI("Getting data failed: " << error);
                 service_destroy(handle);
                 throw UnknownException("Unknown error occurred.");
             }
 
-            LogInfo("Alarm id: " << alarmIds.at(i));
-            LogInfo("Alarm Type: " << alarmType);
+            LoggerI("Alarm id: " << alarmIds.at(i));
+            LoggerI("Alarm Type: " << alarmType);
 
                        JSValueRef obj = NULL;
                        if (strcmp(alarmType, ALARM_TYPE_ABSOLUTE_VALUE) == 0) {
-                               LogInfo("Enter getAll Natvie alarm id = " << alarmIds.at(i));
+                               LoggerI("Enter getAll Natvie alarm id = " << alarmIds.at(i));
                                AlarmAbsolutePtr privateData = AlarmAbsolutePtr(new AlarmAbsolute(handle));
 
                                if(!converter.toAlarmAbsolutePtr(alarmIds.at(i), handle, privateData)) {
@@ -629,7 +629,7 @@ JSValueRef JSAlarmManager::getProperty(JSContextRef context,
             return JSUtil::toJSValueRef(context, (long)604800);
         }
     } catch (const BasePlatformException &err) {
-        LogWarning("Getting property is failed. %s", err.getMessage().c_str());
+        LoggerW("Getting property is failed. %s", err.getMessage().c_str());
     }
 
     return NULL;