}
}
+NotificationProgressType NotificationConverter::toNotificationProgressType(const JSValueRef arg)
+{
+ std::string strType = toString(arg);
+ LogDebug("progress Type : " << strType);
+ if ( strType.compare("BYTE") == 0 )
+ {
+ return NOTI_PROGRESS_TYPE_SIZE;
+ }
+ else if ( strType.compare("PERCENTAGE") == 0 )
+ {
+ return NOTI_PROGRESS_TYPE_PERCENTAGE;
+ }
+ else
+ {
+ ThrowMsg(WrtDeviceApis::Commons::ConversionException, "notification type not supported");
+ }
+}
+
+
void NotificationConverter::NotificationConverter::toNotificationFromDict( INotificationPtr& notification, const JSValueRef arg)
{
if (JSValueIsUndefined(m_context, arg) || JSValueIsNull(m_context, arg))
const ScopedJSStringRef numberStr(JSStringCreateWithUTF8CString(NOTIFICATION_NUMBER));
const ScopedJSStringRef thumbnailsStr(JSStringCreateWithUTF8CString(NOTIFICATION_THUMBNAILS));
const ScopedJSStringRef subIconPathStr(JSStringCreateWithUTF8CString(NOTIFICATION_SUB_ICON_PATH));
+ const ScopedJSStringRef progressTypeStr(JSStringCreateWithUTF8CString(NOTIFICATION_PROGRESS_TYPE));
DeviceAPI::Filesystem::IPathPtr path;
JSValueRef numberValue = JSObjectGetProperty(m_context, dictObject, numberStr.get(), NULL);
JSValueRef thumbnailsValue = JSObjectGetProperty(m_context, dictObject, thumbnailsStr.get(), NULL);
JSValueRef subIconPathValue = JSObjectGetProperty(m_context, dictObject, subIconPathStr.get(), NULL);
+ JSValueRef progressTypeValue = JSObjectGetProperty(m_context, dictObject, progressTypeStr.get(), NULL);
if (!JSValueIsUndefined(m_context, contentValue))
{
std::string appId = toString(appIdValue);
notification->setApplicationId(appId);
}
+
+ if (!JSValueIsUndefined(m_context, progressTypeValue))
+ {
+ notification->setProgressType(toNotificationProgressType(progressTypeValue));
+ }
if (!JSValueIsUndefined(m_context, progressValue))
{
- //unsigned short value = toULong(progressValue);
- double value = toDouble(progressValue);
- LogDebug(" Progress Value : " << value);
- notification->setProgressValue(value);
+ unsigned int progressVal = toULong(progressValue);
+ NotificationProgressType progressType = notification->getProgressType();
+
+ LogDebug(" progress type = " << progressType << "progressValue = " << progressVal);
+
+ if ( NOTI_PROGRESS_TYPE_SIZE == progressType)
+ {
+ notification->setProgressValue(progressVal);
+ }
+ else if ( NOTI_PROGRESS_TYPE_PERCENTAGE == progressType)
+ {
+ //check arrang.
+ if ( progressVal > 100 )
+ {
+ progressVal = 100;
+ }
+ double percentage = (double)progressVal/(double)100;
+ LogDebug(" Percentage Value = " << percentage);
+ notification->setProgressValue(percentage);
+ }
+
+ //double value = toDouble(progressValue);
+ //LogDebug(" Progress Value : " << value);
+ //notification->setProgressValue(value);
}
if (!JSValueIsUndefined(m_context, detailInfoValue))
subIconPath = path->getFullPath();
notification->setSubIconPath(subIconPath);
}
+
}
{
return toJSValueRef("PROGRESS");
}
+ else if ( NOTI_TYPE_THUMBNAIL == arg)
+ {
+ return toJSValueRef("THUMBNAIL");
+ }
+
+ return JSValueMakeUndefined(m_context);
+}
+
+JSValueRef NotificationConverter::toJSValueRef(const NotificationProgressType &arg)
+{
+ if ( NOTI_PROGRESS_TYPE_SIZE == arg)
+ {
+ return toJSValueRef("BYTE");
+ }
+ else if ( NOTI_PROGRESS_TYPE_PERCENTAGE== arg)
+ {
+ return toJSValueRef("PERCENTAGE");
+ }
return JSValueMakeUndefined(m_context);
}