Name: wrt-plugins-tizen
Summary: JavaScript plugins for WebRuntime
-Version: 0.4.12
-Release: 1
+Version: 0.4.13
+Release: 0
Group: Development/Libraries
License: Apache License, Version 2.0
Source0: %{name}-%{version}.tar.gz
Description: wrt-plugins-tizen-${module_name}
Version: @CMAKE_PROJECT_VERSION@
Requires: capi-appfw-application
-Libs: -L${libdir} -lwrt-plugins-tizen-${module_name} -lwrt-plugins-tizen-${module_name}-impl
+Libs: -L${libdir} -lwrt-plugins-tizen-${module_name}-impl
Cflags: -I${includedir}/${module_name}
\ No newline at end of file
Description: wrt-plugins-tizen-${module_name}
Version: @CMAKE_PROJECT_VERSION@
Requires: capi-appfw-app-manager capi-appfw-application capi-appfw-package-manager pkgmgr pkgmgr-info
-Libs: -L${libdir} -lwrt-plugins-tizen-${module_name} -lwrt-plugins-tizen-${module_name}-impl -lwrt-plugins-tizen-${module_name}-config
+Libs: -L${libdir} -lwrt-plugins-tizen-${module_name}-impl -lwrt-plugins-tizen-${module_name}-config
Cflags: -I${includedir}/${module_name}
\ No newline at end of file
Description: wrt-plugins-tizen-${module_name}
Version: @CMAKE_PROJECT_VERSION@
Requires: capi-network-bluetooth
-Libs: -L${libdir} -lwrt-plugins-tizen-${module_name} -lwrt-plugins-tizen-${module_name}-impl
+Libs: -L${libdir} -lwrt-plugins-tizen-${module_name}-impl
Cflags: -I${includedir}/${module_name}
\ No newline at end of file
Description: wrt-plugins-tizen-${module_name}
Version: @CMAKE_PROJECT_VERSION@
Requires: capi-web-favorites
-Libs: -L${libdir} -lwrt-plugins-tizen-${module_name} -lwrt-plugins-tizen-${module_name}-impl
+Libs: -L${libdir} -lwrt-plugins-tizen-${module_name}-impl
Cflags: -I${includedir}/${module_name}
\ No newline at end of file
Description: wrt-plugins-tizen-${module_name}
Version: @CMAKE_PROJECT_VERSION@
Requires: calendar-service2 icu-i18n
-Libs: -L${libdir} -lwrt-plugins-tizen-${module_name} -lwrt-plugins-tizen-${module_name}-impl
+Libs: -L${libdir} -lwrt-plugins-tizen-${module_name}-impl
Cflags: -I${includedir}/${module_name}
Description: wrt-plugins-tizen-${module_name}
Version: @CMAKE_PROJECT_VERSION@
Requires: contacts-service2 glib-2.0 libpcrecpp
-Libs: -L${libdir} -lwrt-plugins-tizen-${module_name} -lwrt-plugins-tizen-${module_name}-impl
+Libs: -L${libdir} -lwrt-plugins-tizen-${module_name}-impl
Cflags: -I${includedir}/${module_name}
\ No newline at end of file
Description: wrt-plugins-tizen-${module_name}
Version: @CMAKE_PROJECT_VERSION@
Requires: contacts-service2 libpcrecpp capi-web-url-download
-Libs: -L${libdir} -lwrt-plugins-tizen-${module_name} -lwrt-plugins-tizen-${module_name}-impl -lwrt-plugins-tizen-${module_name}-config
+Libs: -L${libdir} -lwrt-plugins-tizen-${module_name}-impl -lwrt-plugins-tizen-${module_name}-config
Cflags: -I${includedir}/${module_name}
\ No newline at end of file
Description: wrt-plugins-tizen-${module_name}
Version: @CMAKE_PROJECT_VERSION@
Requires: capi-content-media-content capi-media-metadata-extractor
-Libs: -L${libdir} -lwrt-plugins-tizen-${module_name} -lwrt-plugins-tizen-${module_name}-impl
+Libs: -L${libdir} -lwrt-plugins-tizen-${module_name}-impl
Cflags: -I${includedir}/${module_name}
\ No newline at end of file
Description: wrt-plugins-tizen-${module_name}
Version: @CMAKE_PROJECT_VERSION@
Requires: capi-appfw-application appsvc pkgmgr
-Libs: -L${libdir} -lwrt-plugins-tizen-${module_name} -lwrt-plugins-tizen-${module_name}-impl
+Libs: -L${libdir} -lwrt-plugins-tizen-${module_name}-impl
Cflags: -I${includedir}/${module_name}
\ No newline at end of file
Description: wrt-plugins-tizen-${module_name}
Version: @CMAKE_PROJECT_VERSION@
Requires: sync-agent
-Libs: -L${libdir} -lwrt-plugins-tizen-${module_name} -lwrt-plugins-tizen-${module_name}-impl
+Libs: -L${libdir} -lwrt-plugins-tizen-${module_name}-impl
Cflags: -I${includedir}/${module_name}
Description: wrt-plugins-tizen-${module_name}
Version: @CMAKE_PROJECT_VERSION@
Requires: capi-web-url-download
-Libs: -L${libdir} -lwrt-plugins-tizen-${module_name} -lwrt-plugins-tizen-${module_name}-imp
+Libs: -L${libdir} -lwrt-plugins-tizen-${module_name}-impl
Cflags: -I${includedir}/${module_name}
\ No newline at end of file
Description: wrt-plugins-tizen-${module_name}
Version: @CMAKE_PROJECT_VERSION@
Requires:
-Libs: -L${libdir} -lwrt-plugins-tizen-${module_name}
+Libs: -L${libdir} -lwrt-plugins-tizen-${module_name}-impl -lwrt-plugins-tizen-${module_name}-config
Cflags: -I${includedir}/${module_name}
\ No newline at end of file
Description: wrt-plugins-tizen-${module_name}
Version: @CMAKE_PROJECT_VERSION@
Requires: osp-appfw capi-appfw-app-manager
-Libs: -L${libdir} -lwrt-plugins-tizen-${module_name} -lwrt-plugins-tizen-${module_name}-impl
+Libs: -L${libdir} -lwrt-plugins-tizen-${module_name}-impl
Cflags: -I${includedir}/${module_name}
\ No newline at end of file
Description: wrt-plugins-tizen-${module_name}
Version: @CMAKE_PROJECT_VERSION@
Requires: msg-service email-service dbus-1
-Libs: -L${libdir} -lwrt-plugins-tizen-${module_name} -lwrt-plugins-tizen-${module_name}-impl
+Libs: -L${libdir} -lwrt-plugins-tizen-${module_name}-impl
Cflags: -I${includedir}/${module_name}
\ No newline at end of file
Description: wrt-plugins-tizen-${module_name}
Version: @CMAKE_PROJECT_VERSION@
Requires: capi-network-connection
-Libs: -L${libdir} -lwrt-plugins-tizen-${module_name}
+Libs: -L${libdir} -lwrt-plugins-tizen-${module_name}-impl
Cflags: -I${includedir}/${module_name}
\ No newline at end of file
Description: wrt-plugins-tizen-${module_name}
Version: @CMAKE_PROJECT_VERSION@
Requires: capi-network-nfc
-Libs: -L${libdir} -lwrt-plugins-tizen-${module_name} -lwrt-plugins-tizen-${module_name}-impl
+Libs: -L${libdir} -lwrt-plugins-tizen-${module_name}-impl
Cflags: -I${includedir}/${module_name}
\ No newline at end of file
Description: wrt-plugins-tizen-${module_name}
Version: @CMAKE_PROJECT_VERSION@
Requires: capi-appfw-application
-Libs: -L${libdir} -lwrt-plugins-tizen-${module_name} -lwrt-plugins-tizen-${module_name}-impl -lwrt-plugins-tizen-${module_name}-config
+Libs: -L${libdir} -lwrt-plugins-tizen-${module_name}-impl
Cflags: -I${includedir}/${module_name}
\ No newline at end of file
Description: wrt-plugins-tizen-${module_name}
Version: @CMAKE_PROJECT_VERSION@
Requires: capi-appfw-app-manager capi-appfw-package-manager wrt-deviceapis-commons wrt-deviceapis-commons-javascript pkgmgr pkgmgr-info
-Libs: -L${libdir} -lwrt-plugins-tizen-${module_name} -lwrt-plugins-tizen-${module_name}-impl -lwrt-plugins-tizen-${module_name}-config
+Libs: -L${libdir} -lwrt-plugins-tizen-${module_name}-impl
Cflags: -I${includedir}/${module_name}
\ No newline at end of file
Description: wrt-plugins-tizen-${module_name}
Version: @CMAKE_PROJECT_VERSION@
Requires: capi-system-power pmapi capi-system-device
-Libs: -L${libdir} -lwrt-plugins-tizen-${module_name} -lwrt-plugins-tizen-${module_name}-impl
+Libs: -L${libdir} -lwrt-plugins-tizen-${module_name}-impl
Cflags: -I${includedir}/${module_name}
\ No newline at end of file
Description: wrt-plugins-tizen-${module_name}
Version: @CMAKE_PROJECT_VERSION@
Requires: smartcard-service smartcard-service-common
-Libs: -L${libdir} -lwrt-plugins-tizen-${module_name} -lwrt-plugins-tizen-${module_name}-impl
+Libs: -L${libdir} -lwrt-plugins-tizen-${module_name}-impl
Cflags: -I${includedir}/${module_name}
Description: wrt-plugins-tizen-${module_name}
Version: @CMAKE_PROJECT_VERSION@
Requires: capi-telephony-sim capi-network-connection capi-system-info capi-system-runtime-info capi-system-sensor sensor
-Libs: -L${libdir} -lwrt-plugins-tizen-${module_name} -lwrt-plugins-tizen-${module_name}-impl
+Libs: -L${libdir} -lwrt-plugins-tizen-${module_name}-impl
Cflags: -I${includedir}/${module_name}
\ No newline at end of file
Description: wrt-plugins-tizen-${module_name}
Version: @CMAKE_PROJECT_VERSION@
Requires: icu-i18n icu-io icu-le icu-lx icu-uc
-Libs: -L${libdir} -lwrt-plugins-tizen-${module_name} -lwrt-plugins-tizen-${module_name}-impl
+Libs: -L${libdir} -lwrt-plugins-tizen-${module_name}-impl
Cflags: -I${includedir}/${module_name}
\ No newline at end of file
Description: wrt-plugins-tizen-${module_name}
Version: @CMAKE_PROJECT_VERSION@
Requires: wrt-plugins-plugin-manager
-Libs: -L${libdir} -lwrt-plugins-tizen-${module_name} -lwrt-plugins-tizen-${module_name}-impl -lwrt-plugins-tizen-${module_name}-config
+Libs: -L${libdir} -lwrt-plugins-tizen-${module_name}-impl -lwrt-plugins-tizen-${module_name}-config
Cflags: -I${includedir}/${module_name}
\ No newline at end of file
{
if(JSIsArrayValue(ctx, arguments[1])) {
std::vector<std::string> daysOfTheWeek = converter.toVectorOfStrings(arguments[1]);
- if(daysOfTheWeek.size() >0) {
+
+ for( int i = 0; i< daysOfTheWeek.size(); i++ )
+ {
+ if( (daysOfTheWeek[i]!="SU") && (daysOfTheWeek[i]!="MO") &&
+ (daysOfTheWeek[i]!="TU") && (daysOfTheWeek[i]!="WE") &&
+ (daysOfTheWeek[i]!="TH") && (daysOfTheWeek[i]!="FR") &&
+ (daysOfTheWeek[i]!="SA") ) {
+ ThrowMsg(ConversionException, "Invalid days of the week value.");
+ }
+ }
+
+ if(daysOfTheWeek.size() > 0) {
privateData->setByDayRecurrence(daysOfTheWeek);
}
} else {
#include "JSBluetoothClass.h"
#include "BluetoothConverter.h"
#include "plugin_config.h"
+#include "JSUtil.h"
using namespace std;
using namespace DPL;
JSStaticValue JSBluetoothDevice::m_properties[] = {
{"name", getName, NULL, kJSPropertyAttributeReadOnly},
{"address", getAddress, NULL, kJSPropertyAttributeReadOnly},
- {"deviceClass", getDeviceClass, NULL, kJSPropertyAttributeReadOnly},
{"isBonded", getBondProperty, NULL, kJSPropertyAttributeReadOnly},
{"isTrusted", getTrustProperty, NULL, kJSPropertyAttributeReadOnly},
{"isConnected", getConnectProperty, NULL, kJSPropertyAttributeReadOnly},
JSClassRef JSBluetoothDevice::m_jsClassRef = JSClassCreate(JSBluetoothDevice::getClassInfo());
-JSObjectRef JSBluetoothDevice::m_deviceClass = NULL;
-
void JSBluetoothDevice::initialize(JSContextRef context, JSObjectRef object)
{
LogDebug("initialize ");
}
else
{
- LogDebug("already exist");
+ LogDebug("already exist");
}
-
+ setAttributesIntoJSObject(context, object);
}
void JSBluetoothDevice::finalize(JSObjectRef object)
return NULL;
}
-JSValueRef JSBluetoothDevice::getDeviceClass(JSContextRef context,
- JSObjectRef object,
- JSStringRef propertyName,
- JSValueRef* exception)
-{
- LogDebug("Enter");
-
- if(m_deviceClass == NULL)
- {
- JSBluetoothDevicePriv *priv = static_cast<JSBluetoothDevicePriv*>(JSObjectGetPrivate(object));
-
- Try
- {
- if (priv == NULL)
- {
- ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is NULL.");
- }
- IBluetoothDeviceManagerPtr BluetoothDeviceManager(priv->getObject());
- BluetoothDeviceDataClass devClass = BluetoothDeviceManager->getClass();
-
- LogDebug("Major:" << std::hex << devClass.major << "Minor:" << std::hex << devClass.minor << "Service Mask:" << std::hex << devClass.majorServiceMask);
-
- m_deviceClass = JSBluetoothClass::createJSObject(priv->getContext(), devClass);
- }
- Catch(WrtDeviceApis::Commons::Exception)
- {
- LogWarning("Exception"<<_rethrown_exception.GetMessage());
- return JSValueMakeUndefined(context);
- }
- }
-
- return m_deviceClass;
-
-}
JSValueRef JSBluetoothDevice::getBondProperty(JSContextRef context,
JSObjectRef object,
JSStringRef propertyName,
return JSValueMakeUndefined(context);
}
+
+void JSBluetoothDevice::setAttributesIntoJSObject(JSContextRef context, JSObjectRef object)
+{
+ // deviceClass
+ Try
+ {
+ JSBluetoothDevicePriv *priv = static_cast<JSBluetoothDevicePriv*>(JSObjectGetPrivate(object));
+ if (priv == NULL)
+ {
+ ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is NULL.");
+ }
+ IBluetoothDeviceManagerPtr BluetoothDeviceManager(priv->getObject());
+ BluetoothDeviceDataClass devClass = BluetoothDeviceManager->getClass();
+
+ LogDebug("Major:" << std::hex << devClass.major << "Minor:" << std::hex << devClass.minor << "Service Mask:" << std::hex << devClass.majorServiceMask);
+
+ JSUtil::setProperty(context, object, "deviceClass",
+ JSBluetoothClass::createJSObject(priv->getContext(), devClass), kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete);
+ }
+ Catch(WrtDeviceApis::Commons::Exception)
+ {
+ LogWarning("Exception"<<_rethrown_exception.GetMessage());
+ }
+}
+
}
}
JSValueRef possibleInstance, JSValueRef* exception);
static JSValueRef getName(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception);
static JSValueRef getAddress(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception);
- static JSValueRef getDeviceClass(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception);
static JSValueRef getBondProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception);
static JSValueRef getTrustProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception);
static JSValueRef getConnectProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception);
static JSValueRef connectToServiceByUUID(JSContextRef context, JSObjectRef object,
JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
JSValueRef* exception);
+ /**
+ * Sets attributes into JS object.
+ */
+ static void setAttributesIntoJSObject(JSContextRef context,
+ JSObjectRef object);
+
static JSClassDefinition m_classInfo;
static JSStaticFunction m_function[];
static JSStaticValue m_properties[];
static JSClassRef m_jsClassRef;
- static JSObjectRef m_deviceClass;
};
}
#include "JSBluetoothClassDeviceMinor.h"
#include "JSBluetoothClassDeviceService.h"
#include "plugin_config.h"
+#include "JSUtil.h"
using namespace WrtDeviceApis::Commons;
using namespace DeviceAPI::Common;
namespace Bluetooth {
JSClassRef JSBluetoothManager::m_jsClassRef = NULL;
-JSObjectRef JSBluetoothManager::m_deviceMajor = NULL;
-JSObjectRef JSBluetoothManager::m_deviceMinor = NULL;
-JSObjectRef JSBluetoothManager::m_deviceService = NULL;
-
JSClassDefinition JSBluetoothManager::m_classInfo =
{
kJSClassAttributeNone,
"BluetoothManager",
NULL,
- m_properties,
+ NULL,
m_function,
initialize,
finalize,
{ 0, 0, 0 }
};
-
-JSStaticValue JSBluetoothManager::m_properties[] =
-{
- {DEVICE_MAJOR, getProperty, NULL, kJSPropertyAttributeReadOnly},
- {DEVICE_MINOR, getProperty, NULL, kJSPropertyAttributeReadOnly},
- {DEVICE_SERVICE, getProperty, NULL, kJSPropertyAttributeReadOnly},
- {0, 0, 0, 0}
-};
-
-
-
const JSClassRef JSBluetoothManager::getClassRef()
{
if (!m_jsClassRef)
}
}
-
-JSValueRef JSBluetoothManager::getProperty(JSContextRef context,
- JSObjectRef object,
- JSStringRef propertyName,
- JSValueRef* exception)
-{
- LogDebug("OK");
-
- Try
- {
- if(JSStringIsEqualToUTF8CString(propertyName, DEVICE_MAJOR))
- {
- if(!m_deviceMajor)
- m_deviceMajor = JSBluetoothClassDeviceMajor::createJSObject(context);
- return m_deviceMajor;
- }
- else if(JSStringIsEqualToUTF8CString(propertyName, DEVICE_MINOR))
- {
- if(!m_deviceMinor)
- m_deviceMinor = JSBluetoothClassDeviceMinor::createJSObject(context);
- return m_deviceMinor;
- }
- else if(JSStringIsEqualToUTF8CString(propertyName, DEVICE_SERVICE))
- {
- if(!m_deviceService)
- m_deviceService = JSBluetoothClassDeviceService::createJSObject(context);
- return m_deviceService;
- }
-
- }
- Catch (Exception)
- {
- LogWarning("Exception "<<_rethrown_exception.GetMessage());
- }
-
- return NULL;
-}
-
-
-
const JSClassDefinition* JSBluetoothManager::getClassInfo()
{
return &m_classInfo;
delete priv;
}
}
+
+ setAttributesIntoJSObject(context, object);
}
void JSBluetoothManager::finalize(JSObjectRef object)
{
return JSValueIsObjectOfClass(context, possibleInstance, getClassRef());
}
+
+void JSBluetoothManager::setAttributesIntoJSObject(JSContextRef context, JSObjectRef object)
+{
+ // deviceMajor
+ JSUtil::setProperty(context, object, DEVICE_MAJOR,
+ JSBluetoothClassDeviceMajor::createJSObject(context), kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete);
+
+ // deviceMinor
+ JSUtil::setProperty(context, object, DEVICE_MINOR,
+ JSBluetoothClassDeviceMinor::createJSObject(context), kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete);
+
+ // deviceService
+ JSUtil::setProperty(context, object, DEVICE_SERVICE,
+ JSBluetoothClassDeviceService::createJSObject(context), kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete);
+}
+
}
}
static void initialize(JSContextRef context, JSObjectRef object);
static void finalize(JSObjectRef object);
static bool hasInstance(JSContextRef context, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception);
+
+ /**
+ * Sets attributes into JS object.
+ */
+ static void setAttributesIntoJSObject(JSContextRef context,
+ JSObjectRef object);
static JSValueRef getDefaultAdapter(JSContextRef context, JSObjectRef object,
JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
JSValueRef* exception) ;
- static JSValueRef getProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception);
static JSClassDefinition m_classInfo;
static JSStaticFunction m_function[];
static JSStaticValue m_properties[];
static JSClassRef m_jsClassRef;
- static JSObjectRef m_deviceMajor;
- static JSObjectRef m_deviceMinor;
- static JSObjectRef m_deviceService;
};
}
}
#include "BluetoothConverter.h"
#include <bluetooth.h>
#include "plugin_config.h"
+#include "JSUtil.h"
using namespace std;
using namespace DPL;
{"uuid", getProperty, NULL, kJSPropertyAttributeReadOnly},
// {"protocol", getProperty, NULL, kJSPropertyAttributeReadOnly},
{"state", getProperty, NULL, kJSPropertyAttributeReadOnly},
- {"peer", getProperty, NULL, kJSPropertyAttributeReadOnly},
{"onerror", getCallback, setProperty, kJSPropertyAttributeNone},
{"onmessage", getCallback, setProperty, kJSPropertyAttributeNone},
{"onclose", getCallback, setProperty, kJSPropertyAttributeNone},
JSClassRef JSBluetoothSocket::m_jsClassRef = JSClassCreate(JSBluetoothSocket::getClassInfo());
-JSObjectRef JSBluetoothSocket::m_peer = NULL;
-
bool JSBluetoothSocket::setProperty(JSContextRef context,
JSObjectRef object,
JSStringRef propertyName,
void JSBluetoothSocket::initialize(JSContextRef context, JSObjectRef object)
{
LogDebug("JSBluetoothSocket::initialize ");
-
+ setAttributesIntoJSObject(context, object);
}
void JSBluetoothSocket::finalize(JSObjectRef object)
return JSTizenExceptionFactory::makeErrorObject(context,
JSTizenException::UNKNOWN_ERROR, "Unkown error");
}
- }
+ }
}
Try
{
- if(JSStringIsEqualToUTF8CString(propertyName, "peer") && m_peer != NULL)
- return m_peer;
-
JSBluetoothSocketPriv *priv = static_cast<JSBluetoothSocketPriv*>(JSObjectGetPrivate(object));
if (priv == NULL)
{
unsigned short int state = BluetoothSocketManager->getState();
return converter.toBluetoothStateJSValue(state);
}
- else
- {
- BluetoothDeviceData device = BluetoothSocketManager->getPeer();
- m_peer = JSBluetoothDevice::createJSObject(priv->getContext(), device);
- return m_peer;
- }
}
Catch(WrtDeviceApis::Commons::Exception)
{
}
}
+void JSBluetoothSocket::setAttributesIntoJSObject(JSContextRef context, JSObjectRef object)
+{
+ // peer
+ Try
+ {
+ JSBluetoothSocketPriv *priv = static_cast<JSBluetoothSocketPriv*>(JSObjectGetPrivate(object));
+ if (priv == NULL)
+ {
+ ThrowMsg(WrtDeviceApis::Commons::ConversionException, "private object null");
+ }
+
+ IBluetoothSocketManagerPtr BluetoothSocketManager(priv->getObject());
+ BluetoothConverter converter(priv->getContext());
+ if (BluetoothSocketManager == NULL)
+ {
+ ThrowMsg(WrtDeviceApis::Commons::UnknownException, "BluetoothManager is NULL");
+ }
+
+ BluetoothDeviceData device = BluetoothSocketManager->getPeer();
+ JSUtil::setProperty(context, object, "peer",
+ JSBluetoothDevice::createJSObject(priv->getContext(), device), kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete);
+ }
+ Catch(WrtDeviceApis::Commons::Exception)
+ {
+ LogWarning("Exception"<<_rethrown_exception.GetMessage());
+ }
+}
+
}
}
JSStringRef propertyName,
JSValueRef* exception);
+ /**
+ * Sets attributes into JS object.
+ */
+ static void setAttributesIntoJSObject(JSContextRef context,
+ JSObjectRef object);
+
static JSClassDefinition m_classInfo;
static JSStaticFunction m_function[];
static JSStaticValue m_properties[];
static JSClassRef m_jsClassRef;
- static JSObjectRef m_peer;
};
JSCalendarAttendee.cpp
JSCalendarRecurrenceRule.cpp
JSCalendarAlarm.cpp
- JSStringArray.cpp
- JSNumberArray.cpp
- JSTZDateArray.cpp
CalendarAsyncCallbackManager.cpp
CalendarListenerManager.cpp
Calendar.cpp
et.type = CALENDAR_TIME_LOCALTIME;
et.time.date = CalendarUtility::LLIToCalTime(calEvent->getTimeZone().c_str(), endDate).time.date;
} else {
- st.type = CALENDAR_TIME_UTIME;
- st.time.utime = startDate;
+ st.type = CALENDAR_TIME_UTIME;
+ st.time.utime = startDate;
- et.type = CALENDAR_TIME_UTIME;
- et.time.utime = endDate;
+ et.type = CALENDAR_TIME_UTIME;
+ et.time.utime = endDate;
}
if( true==isAllDay ) {
LogDebug("Found a valid event instance with rid: "<<recurringEventWrapper->getAbstractEvent()->getRecurrenceId());
event->addExpandedEvent(recurringEventWrapper->getAbstractEvent());
- }
+ } else {
+ LogDebug("Skip unmatched instance with event_id: "<<currentRecordIndex<<" and parent id: "<<calEvent->getId());
+ }
calendar_list_next(list);
}
#include "JSCalendarAttendee.h"
#include "JSCalendarRecurrenceRule.h"
#include "JSCalendarAlarm.h"
-#include "JSStringArray.h"
-#include "JSNumberArray.h"
-#include "JSTZDateArray.h"
#include <TimeUtilConverter.h>
#include <DurationProperties.h>
return toJSValueRef_(arg, &CalendarConverter::toJSValueRefCalendar, this);
}
-JSValueRef CalendarConverter::toJSValueRef(const StringArrayPtr &arg)
+JSValueRef CalendarConverter::toJSValueRefStringArray(const StringArrayPtr &arg)
{
- return JSStringArray::createArray(m_context, arg);
+ int size = arg->size();
+
+ JSObjectRef resultObject = JSCreateArrayObject(m_context, 0, NULL);
+ if (!resultObject) {
+ ThrowMsg(ConversionException, "Can not create an array object.");
+ }
+
+ for(int i = 0; i < size; i++) {
+ JSValueRef jsvalue = toJSValueRef(arg->at(i));
+ if (!JSSetArrayElement(m_context, resultObject, i, jsvalue)) {
+ ThrowMsg(ConversionException, "Can not add an object to array.");
+ }
+ }
+
+ return resultObject;
}
JSValueRef CalendarConverter::toJSValueRefNumberArray(const NumberArrayPtr &arg)
{
- return JSNumberArray::createArray(m_context, arg);
+ int size = arg->size();
+
+ JSObjectRef resultObject = JSCreateArrayObject(m_context, 0, NULL);
+ if (!resultObject) {
+ ThrowMsg(ConversionException, "Can not create an array object.");
+ }
+
+ for(int i = 0; i < size; i++) {
+ JSValueRef jsvalue = toJSValueRef(arg->at(i));
+ if (!JSSetArrayElement(m_context, resultObject, i, jsvalue)) {
+ ThrowMsg(ConversionException, "Can not add an object to array.");
+ }
+ }
+
+ return resultObject;
}
-JSValueRef CalendarConverter::toJSValueRefTZDateArray(const NumberArrayPtr &arg)
+JSValueRef CalendarConverter::toJSValueRefTZDateArray(const NumberArrayPtr &arg, const std::string &timeZone)
{
- return JSTZDateArray::createArray(m_context, arg);
+ int size = arg->size();
+
+ JSObjectRef resultObject = JSCreateArrayObject(m_context, 0, NULL);
+ if (!resultObject) {
+ ThrowMsg(ConversionException, "Can not create an array object.");
+ }
+
+ TimeUtilConverter timeConverter(m_context);
+ for(int i = 0; i < size; i++) {
+ JSValueRef jsvalue = timeConverter.toJSValueRefTZDate((double)((arg->at(i))*1000.0), timeZone);
+ if (!JSSetArrayElement(m_context, resultObject, i, jsvalue)) {
+ ThrowMsg(ConversionException, "Can not add an object to array.");
+ }
+ }
+
+ return resultObject;
}
StringArrayPtr CalendarConverter::toStringArray(const JSValueRef &jsValue)
{
- if(JSStringArray::isObjectOfClass(m_context, jsValue))
- return JSStringArray::getStringArray(m_context, jsValue);
-
- if(!JSIsArrayValue(m_context, jsValue))
- ThrowMsg(WrtDeviceApis::Commons::ConversionException, "StringArray is not array.");
-
StringArrayPtr result = StringArrayPtr(new StringArray());
+ if(!JSIsArrayValue(m_context, jsValue)) {
+ LogWarning("StringArray is not an array. Skip this.");
+ return result;
+ }
+
JSObjectRef jsObject = toJSObjectRef(jsValue);
for (std::size_t i = 0; i < JSGetArrayLength(m_context, jsObject); ++i) {
JSValueRef element = JSGetArrayElement(m_context, jsObject, i);
NumberArrayPtr CalendarConverter::toNumberArray(const JSValueRef &jsValue)
{
- if(JSNumberArray::isObjectOfClass(m_context, jsValue))
- return JSNumberArray::getNumberArray(m_context, jsValue);
-
- if(!JSIsArrayValue(m_context, jsValue))
- ThrowMsg(WrtDeviceApis::Commons::ConversionException, "NumberArray is not array.");
-
NumberArrayPtr result = NumberArrayPtr(new NumberArray());
+ if(!JSIsArrayValue(m_context, jsValue)) {
+ LogWarning("NumberArray is not an array. Skip this.");
+ return result;
+ }
+
JSObjectRef jsObject = toJSObjectRef(jsValue);
for (std::size_t i = 0; i < JSGetArrayLength(m_context, jsObject); ++i) {
JSValueRef element = JSGetArrayElement(m_context, jsObject, i);
result->push_back((long long int) (toLongLong(element)));
}
- LogDebug("First number: "<<result->at(0));
return result;
}
NumberArrayPtr CalendarConverter::toTZDateArray(const JSValueRef &jsValue)
{
- if(JSNumberArray::isObjectOfClass(m_context, jsValue))
- return JSNumberArray::getNumberArray(m_context, jsValue);
-
- if(!JSIsArrayValue(m_context, jsValue))
- ThrowMsg(WrtDeviceApis::Commons::ConversionException, "NumberArray is not array.");
+ NumberArrayPtr result = NumberArrayPtr(new NumberArray());
+ if(!JSIsArrayValue(m_context, jsValue)) {
+ LogWarning("TZDateArray is not an array. Skip this.");
+ return result;
+ }
TimeUtilConverter timeConverter(m_context);
- NumberArrayPtr result = NumberArrayPtr(new NumberArray());
JSObjectRef jsObject = toJSObjectRef(jsValue);
for (std::size_t i = 0; i < JSGetArrayLength(m_context, jsObject); ++i) {
JSValueRef element = JSGetArrayElement(m_context, jsObject, i);
EventRecurrenceRulePtr CalendarConverter::toEventRecurrenceRule(JSValueRef rrule)
{
EventRecurrenceRulePtr result(new EventRecurrenceRule());
+
const ScopedJSStringRef frequencyStr(JSStringCreateWithUTF8CString(TIZEN_RECURRENCE_RULE_FREQUENCY));
const ScopedJSStringRef intervalStr(JSStringCreateWithUTF8CString(TIZEN_RECURRENCE_RULE_INTERVAL));
const ScopedJSStringRef untilDateStr(JSStringCreateWithUTF8CString(TIZEN_RECURRENCE_RULE_UNTIL_DATE));
{
EventAttendeeListPtr result(new EventAttendeeList());
- std::vector<EventAttendeePtr> resultVector;
JSObjectRef objArg = toJSObjectRef(attendees);
LogDebug("array length "<<JSGetArrayLength(m_context, objArg));
for (std::size_t i = 0; i < JSGetArrayLength(m_context, objArg); i++) {
JSValueRef element = JSGetArrayElement(m_context, objArg, i);
- resultVector.push_back(toAttendee(element));
+ result->push_back(toAttendee(element));
}
- *result = resultVector;
return result;
}
{
EventAttendeeListPtr result(new EventAttendeeList());
- std::vector<EventAttendeePtr> resultVector;
JSObjectRef objArg = toJSObjectRef(attendees);
LogDebug("array length "<<JSGetArrayLength(m_context, objArg));
for (std::size_t i = 0; i < JSGetArrayLength(m_context, objArg); i++) {
JSValueRef element = JSGetArrayElement(m_context, objArg, i);
- resultVector.push_back(JSCalendarAttendee::getPrivateObject(JSValueToObject(m_context, element, NULL)));
+ if (JSValueIsObjectOfClass(m_context, element, JSCalendarAttendee::getClassRef())) {
+ result->push_back(JSCalendarAttendee::getPrivateObject(JSValueToObject(m_context, element, NULL)));
+ } else {
+ LogDebug("Invalid attendee type. Skip this with index: "<<i);
+ continue;
+ }
}
- *result = resultVector;
return result;
}
{
EventAlarmListPtr result(new EventAlarmList());
- std::vector<EventAlarmPtr> resultVector;
JSObjectRef objArg = toJSObjectRef(alarms);
LogDebug("array length "<<JSGetArrayLength(m_context, objArg));
for (std::size_t i = 0; i < JSGetArrayLength(m_context, objArg); i++) {
JSValueRef element = JSGetArrayElement(m_context, objArg, i);
- resultVector.push_back(toEventAlarm(element));
+ result->push_back(toEventAlarm(element));
}
- *result = resultVector;
return result;
}
{
EventAlarmListPtr result(new EventAlarmList());
- std::vector<EventAlarmPtr> resultVector;
JSObjectRef objArg = toJSObjectRef(alarms);
LogDebug("array length "<<JSGetArrayLength(m_context, objArg));
for (std::size_t i = 0; i < JSGetArrayLength(m_context, objArg); i++) {
JSValueRef element = JSGetArrayElement(m_context, objArg, i);
- resultVector.push_back(JSCalendarAlarm::getPrivateObject(JSValueToObject(m_context, element, NULL)));
+ if (JSValueIsObjectOfClass(m_context, element, JSCalendarAlarm::getClassRef())) {
+ result->push_back(JSCalendarAlarm::getPrivateObject(JSValueToObject(m_context, element, NULL)));
+ } else {
+ LogDebug("Invalid alarm type. Skip this with index: "<<i);
+ continue;
+ }
}
- *result = resultVector;
return result;
}
-CalendarEventPtr CalendarConverter::toEvent(const JSValueRef event)
+CalendarEventPtr CalendarConverter::toItem(const JSValueRef value, bool updateMode)
{
- CalendarEventPtr result(new CalendarEvent());
+ CalendarEventPtr result;
+ JSObjectRef arg = toJSObjectRef(value);
+
+ if(updateMode) {
+ LogDebug("Update mode.");
+ result = JSCalendarEvent::getPrivateObject(arg);
+ } else {
+ LogDebug("Constructor mode.");
+ CalendarEventPtr resultPtr(new CalendarEvent());
+ result = resultPtr;
+ }
+
const ScopedJSStringRef descriptionStr(JSStringCreateWithUTF8CString(TIZEN_CALENDAR_ITEM_DESCRIPTION));
const ScopedJSStringRef summaryStr(JSStringCreateWithUTF8CString(TIZEN_CALENDAR_ITEM_SUMMARY));
const ScopedJSStringRef startTimeStr(JSStringCreateWithUTF8CString(TIZEN_CALENDAR_ITEM_START_DATE));
const ScopedJSStringRef completedDateStr(JSStringCreateWithUTF8CString(TIZEN_CALENDAR_TASK_COMPLETED_DATE));
const ScopedJSStringRef progressStr(JSStringCreateWithUTF8CString(TIZEN_CALENDAR_TASK_PROGRESS));
- JSObjectRef arg = toJSObjectRef(event);
-
JSValueRef descriptionData = JSObjectGetProperty(m_context, arg, descriptionStr.get(), NULL);
JSValueRef summaryData = JSObjectGetProperty(m_context, arg, summaryStr.get(), NULL);
JSValueRef startTimeData = JSObjectGetProperty(m_context, arg, startTimeStr.get(), NULL);
//result->setStartTime(std::time(NULL));
}
}
-
+
if (!JSValueIsUndefined(m_context, durationData)) {
long length = timeUtilConverter.getDurationLength(durationData);
int unit = timeUtilConverter.getDurationUnit(durationData);
- LogInfo("duration length: "<<length<<", unit "<<unit);
+ LogDebug("duration length: "<<length<<", unit "<<unit);
if (length < 0) {
ThrowMsg(ConversionException, "Wrong duration length.");
}
- if( SECONDS_UNIT==unit ) {
+ if( MSECS_UNIT==unit ) {
+ result->setEndTime(result->getStartTime() + length/1000);
+ } else if( SECONDS_UNIT==unit ) {
result->setEndTime(result->getStartTime() + length);
} else if ( MINUTES_UNIT==unit ) {
result->setEndTime(result->getStartTime() + length*60);
result->setAvailability(toEventAvailability(toString(availabilityData)));
}
if (!JSValueIsUndefined(m_context, recurrenceRuleData)) {
- result->setRecurrenceRule(JSCalendarRecurrenceRule::getPrivateObject(JSValueToObject(m_context, recurrenceRuleData, NULL)));
+ if(updateMode) {
+ result->setRecurrenceRule(toEventRecurrenceRule(recurrenceRuleData));
+ } else {
+ result->setRecurrenceRule(JSCalendarRecurrenceRule::getPrivateObject(JSValueToObject(m_context, recurrenceRuleData, NULL)));
+ }
}
if (!JSValueIsUndefined(m_context, priorityData)) {
result->setPriority(toTaskPriority(toString(priorityData)));
return result;
}
-CalendarEventListPtr CalendarConverter::toVectorOfEvents(JSValueRef events)
+CalendarEventListPtr CalendarConverter::toVectorOfItems(JSValueRef events)
{
CalendarEventListPtr result(new CalendarEventList());
- std::vector<CalendarEventPtr> resultVector;
JSObjectRef objArg = toJSObjectRef(events);
LogDebug("array length "<<JSGetArrayLength(m_context, objArg));
for (std::size_t i = 0; i < JSGetArrayLength(m_context, objArg); i++) {
JSValueRef element = JSGetArrayElement(m_context, objArg, i);
- JSObjectRef arg = JSValueToObject(m_context, element, NULL);
- resultVector.push_back(JSCalendarEvent::getPrivateObject(arg));
+ if (JSValueIsObjectOfClass(m_context, element, JSCalendarEvent::getClassRef())) {
+ JSObjectRef arg = JSValueToObject(m_context, element, NULL);
+ result->push_back(JSCalendarEvent::getPrivateObject(arg));
+ } else if (JSValueIsObjectOfClass(m_context, element, JSCalendarTask::getClassRef())) {
+ JSObjectRef arg = JSValueToObject(m_context, element, NULL);
+ result->push_back(JSCalendarTask::getPrivateObject(arg));
+ } else {
+ LogDebug("Invalid item type. Skip this with index: "<<i);
+ continue;
+ }
}
- *result = resultVector;
return result;
}
-CalendarEventListPtr CalendarConverter::toVectorOfEventsFromProperty(JSValueRef events)
+CalendarEventListPtr CalendarConverter::toVectorOfItemsFromDictionary(JSValueRef events)
{
CalendarEventListPtr result(new CalendarEventList());
- std::vector<CalendarEventPtr> resultVector;
JSObjectRef objArg = toJSObjectRef(events);
LogDebug("array length "<<JSGetArrayLength(m_context, objArg));
for (std::size_t i = 0; i < JSGetArrayLength(m_context, objArg); i++) {
- resultVector.push_back(toEvent(JSGetArrayElement(m_context, objArg, i)));
+ result->push_back(toItem(JSGetArrayElement(m_context, objArg, i), true));
}
- *result = resultVector;
return result;
}
{
EventIdListPtr result(new EventIdList());
- std::vector<EventIdPtr> resultVector;
JSObjectRef objArg = toJSObjectRef(eventIds);
LogDebug("array length "<<JSGetArrayLength(m_context, objArg));
for (std::size_t i = 0; i < JSGetArrayLength(m_context, objArg); i++) {
JSValueRef element = JSGetArrayElement(m_context, objArg, i);
- EventIdPtr idPtr = JSCalendarEventId::getPrivateObject(JSValueToObject(m_context, element, NULL));
- idPtr->setCalendarType(CalendarEvent::EVENT_TYPE);
- resultVector.push_back(idPtr);
+
+ if (JSValueIsObjectOfClass(m_context, element, JSCalendarEventId::getClassRef())) {
+ EventIdPtr idPtr = JSCalendarEventId::getPrivateObject(JSValueToObject(m_context, element, NULL));
+ idPtr->setCalendarType(CalendarEvent::EVENT_TYPE);
+ result->push_back(idPtr);
+ } else {
+ LogDebug("Invalid event id type. Skip this index: "<<i);
+ continue;
+ }
}
- *result = resultVector;
return result;
}
explicit CalendarConverter(JSContextRef context, CalendarEvent::CalendarType calendarType=CalendarEvent::EVENT_TYPE);
virtual ~CalendarConverter();
- CalendarEventPtr toEvent(const JSValueRef event);
- CalendarEventListPtr toVectorOfEvents(JSValueRef events);
- CalendarEventListPtr toVectorOfEventsFromProperty(JSValueRef events);
+ CalendarEventPtr toItem(const JSValueRef value, bool updateMode=false);
+ CalendarEventListPtr toVectorOfItems(JSValueRef events);
+ CalendarEventListPtr toVectorOfItemsFromDictionary(JSValueRef events);
StringArrayPtr toCategories(JSValueRef categories);
EventAttendeePtr toAttendee(JSValueRef attendee);
EventAttendeeListPtr toVectorOfAttendeesFromDictionary(JSValueRef attendees);
JSValueRef toJSValueRefTaskArray(const CalendarEventListPtr &arg);
JSValueRef toJSValueRefCalendar(const ICalendarPtr& arg);
JSValueRef toJSValueRef(const std::vector<ICalendarPtr> &arg);
- JSValueRef toJSValueRef(const StringArrayPtr &arg);
+ JSValueRef toJSValueRefStringArray(const StringArrayPtr &arg);
JSValueRef toJSValueRefNumberArray(const NumberArrayPtr &arg);
- JSValueRef toJSValueRefTZDateArray(const NumberArrayPtr &arg);
+ JSValueRef toJSValueRefTZDateArray(const NumberArrayPtr &arg, const std::string &timeZone);
StringArrayPtr toStringArray(const JSValueRef &jsValue);
NumberArrayPtr toNumberArray(const JSValueRef &jsValue);
NumberArrayPtr toTZDateArray(const JSValueRef &jsValue);
m_status(UNDEFINED_STATUS),
m_alarms(new EventAlarmList()),
m_categories(new StringArray()),
+ m_categoriesJSRef(NULL),
m_isAllDay(false),
m_lastModifiedDate(UNDEFINED_TIME),
m_visibility(PUBLIC_VISIBILITY),
m_createdDate(UNDEFINED_TIME),
m_completedDate(UNDEFINED_TIME),
m_progress(0),
- m_calendarType(EVENT_TYPE)
+ m_calendarType(EVENT_TYPE),
+ m_context(NULL)
{
}
m_recurrence->setOccurrenceCount(original.getRecurrenceRule()->getOccurrenceCount());
m_recurrence->setDaysOfTheMonth(original.getRecurrenceRule()->getDaysOfTheMonth());
m_recurrence->setDaysOfTheWeek(original.getRecurrenceRule()->getDaysOfTheWeek());
+ m_recurrence->setDaysOfTheWeekJSRef(NULL);
m_recurrence->setDaysOfTheYear(original.getRecurrenceRule()->getDaysOfTheYear());
m_recurrence->setWeeksOfTheYear(original.getRecurrenceRule()->getWeeksOfTheYear());
m_recurrence->setSetPositions(original.getRecurrenceRule()->getSetPositions());
+ m_recurrence->setSetPositionsJSRef(NULL);
m_recurrence->setExceptions(original.getRecurrenceRule()->getExceptions());
+ m_recurrence->setExceptionsJSRef(NULL);
m_recurrence->setTimeZone(original.getRecurrenceRule()->getTimeZone());
m_status = original.getStatus();
StringArrayPtr categoriesPtr( new StringArray() );
m_categories = categoriesPtr;
*m_categories = *(original.getCategories());
+ m_categoriesJSRef = NULL;
m_isAllDay = original.getIsAllDay();
m_organizer = original.getOrganizer();
CalendarEvent::~CalendarEvent()
{
+ if(m_categoriesJSRef) {
+ LogDebug("Unprotect JS categories.");
+ JSValueUnprotect(m_context, m_categoriesJSRef);
+ }
}
int CalendarEvent::getId() const
m_categories = value;
}
+JSObjectRef CalendarEvent::getCategoriesJSRef() const
+{
+ return m_categoriesJSRef;
+}
+void CalendarEvent::setCategoriesJSRef(const JSObjectRef value)
+{
+ m_categoriesJSRef = value;
+}
+
void CalendarEvent::display() const
{
LogDebug("m_id " << m_id);
m_calendarType = type;
}
+JSContextRef CalendarEvent::getContext() const
+{
+ return m_context;
+}
+
+void CalendarEvent::setContext(const JSContextRef contextRef)
+{
+ m_context = contextRef;
+}
+
}
}
#include "EventAttendee.h"
#include "EventRecurrenceRule.h"
+#include <JavaScriptCore/JavaScript.h>
+
namespace DeviceAPI {
namespace Calendar {
StringArrayPtr getCategories() const;
void setCategories(const StringArrayPtr value);
+ JSObjectRef getCategoriesJSRef() const;
+ void setCategoriesJSRef(const JSObjectRef value);
void display() const;
bool validate() const;
CalendarType getCalendarType() const;
void setCalendarType(CalendarType type);
+ JSContextRef getContext() const;
+ void setContext(const JSContextRef contextRef);
+
protected:
int m_id;
int m_parentId; // the parent id if it's detached.
EventStatus m_status;
EventAlarmListPtr m_alarms;
StringArrayPtr m_categories;
+ JSObjectRef m_categoriesJSRef;
bool m_isAllDay;
std::string m_organizer;
long long int m_lastModifiedDate;
long long int m_completedDate;
int m_progress;
CalendarType m_calendarType;
+
+ JSContextRef m_context;
};
typedef DPL::SharedPtr<CalendarEvent> CalendarEventPtr;
m_occurrenceCount = -1;
StringArrayPtr stringArrayPtr(new StringArray());
m_daysOfTheWeek = stringArrayPtr;
+ m_daysOfTheWeekJSRef = NULL;
NumberArrayPtr numberArraySetPositionsPtr(new NumberArray());
m_setPositions = numberArraySetPositionsPtr;
+ m_setPositionsJSRef = NULL;
NumberArrayPtr numberArrayExceptionsPtr(new NumberArray());
m_exceptions = numberArrayExceptionsPtr;
+ m_exceptionsJSRef = NULL;
m_timeZone = DEFAULT_TIMEZONE;
+ m_context = NULL;
}
EventRecurrenceRule::~EventRecurrenceRule()
{
+ if(m_daysOfTheWeekJSRef) {
+ LogDebug("Unprotect JS daysOfTheWeek.");
+ JSValueUnprotect(m_context, m_daysOfTheWeekJSRef);
+ }
+ if(m_daysOfTheWeekJSRef) {
+ LogDebug("Unprotect JS setPositions.");
+ JSValueUnprotect(m_context, m_setPositionsJSRef);
+ }
+ if(m_exceptionsJSRef) {
+ LogDebug("Unprotect JS exceptions.");
+ JSValueUnprotect(m_context, m_exceptionsJSRef);
+ }
}
EventRecurrenceRule::EventRecurrence EventRecurrenceRule::getFrequency() const
m_daysOfTheWeek = value;
}
+JSObjectRef EventRecurrenceRule::getDaysOfTheWeekJSRef() const
+{
+ return m_daysOfTheWeekJSRef;
+}
+void EventRecurrenceRule::setDaysOfTheWeekJSRef(const JSObjectRef value)
+{
+ m_daysOfTheWeekJSRef = value;
+}
+
std::vector<int> EventRecurrenceRule::getDaysOfTheYear() const
{
return m_daysOfTheYear;
m_setPositions = value;
}
+JSObjectRef EventRecurrenceRule::getSetPositionsJSRef() const
+{
+ return m_setPositionsJSRef;
+}
+
+void EventRecurrenceRule::setSetPositionsJSRef(const JSObjectRef value)
+{
+ m_setPositionsJSRef = value;
+}
+
NumberArrayPtr EventRecurrenceRule::getExceptions() const
{
return m_exceptions;
m_exceptions = value;
}
+JSObjectRef EventRecurrenceRule::getExceptionsJSRef() const
+{
+ return m_exceptionsJSRef;
+}
+
+void EventRecurrenceRule::setExceptionsJSRef(const JSObjectRef value)
+{
+ m_exceptionsJSRef = value;
+}
+
std::string EventRecurrenceRule::getTimeZone() const
{
return m_timeZone;
m_timeZone = value;
}
+JSContextRef EventRecurrenceRule::getContext() const
+{
+ return m_context;
+}
+
+void EventRecurrenceRule::setContext(const JSContextRef contextRef)
+{
+ m_context = contextRef;
+}
+
}
}
#include <ctime>
#include <dpl/shared_ptr.h>
+#include <JavaScriptCore/JavaScript.h>
+
namespace DeviceAPI {
namespace Calendar {
StringArrayPtr getDaysOfTheWeek() const;
void setDaysOfTheWeek(StringArrayPtr value);
+ JSObjectRef getDaysOfTheWeekJSRef() const;
+ void setDaysOfTheWeekJSRef(const JSObjectRef value);
std::vector<int> getDaysOfTheYear() const;
void setDaysOfTheYear(std::vector<int> value);
NumberArrayPtr getSetPositions() const;
void setSetPositions(NumberArrayPtr value);
+ JSObjectRef getSetPositionsJSRef() const;
+ void setSetPositionsJSRef(const JSObjectRef value);
NumberArrayPtr getExceptions() const;
void setExceptions(NumberArrayPtr value);
+ JSObjectRef getExceptionsJSRef() const;
+ void setExceptionsJSRef(const JSObjectRef value);
std::string getTimeZone() const;
void setTimeZone(std::string value);
+ JSContextRef getContext() const;
+ void setContext(const JSContextRef contextRef);
+
protected:
EventRecurrence m_frequency;
int m_interval;
long m_occurrenceCount;
std::vector<int> m_daysOfTheMonth;
StringArrayPtr m_daysOfTheWeek;
+ JSObjectRef m_daysOfTheWeekJSRef;
std::vector<int> m_daysOfTheYear;
std::vector<int> m_weeksOfTheYear;
NumberArrayPtr m_setPositions;
+ JSObjectRef m_setPositionsJSRef;
NumberArrayPtr m_exceptions;
+ JSObjectRef m_exceptionsJSRef;
std::string m_timeZone;
+
+ JSContextRef m_context;
};
typedef DPL::SharedPtr<EventRecurrenceRule> EventRecurrenceRulePtr;
if (!JSIsArrayValue(context, arguments[0])) {
ThrowMsg(ConversionException, "Wrong first parameter type.");
}
- events = converter.toVectorOfEvents(arguments[0]);
+ events = converter.toVectorOfItems(arguments[0]);
if (!events) {
ThrowMsg(ConversionException, "First parameter conversion failed.");
}
CalendarConverter converter(context);
- JSObjectRef arg = JSValueToObject(context, arguments[0], exception);
- CalendarEventPtr item = JSCalendarEvent::getPrivateObject(arg);
+ CalendarEventPtr item = converter.toItem(arguments[0], true);
if (!item) {
ThrowMsg(ConversionException, "Parameter conversion failed.");
}
} else {
ThrowMsg(ConversionException, "Wrong parameter type.");
}
- CalendarEventListPtr events;
- events = converter.toVectorOfEvents(arguments[0]);
- if (!events) {
+ CalendarEventListPtr items;
+ items = converter.toVectorOfItemsFromDictionary(arguments[0]);
+ if (!items) {
ThrowMsg(ConversionException, "Third parameter conversion failed.");
}
LogDebug("Proceed the event to the platform.");
IEventUpdateEventsPtr dplEvent(new IEventUpdateEvents());
- dplEvent->setEvents(events);
+ dplEvent->setEvents(items);
dplEvent->setUpdateAllInstances(updateAllInstances);
dplEvent->setPrivateData(DPL::StaticPointerCast<IEventPrivateData>(cbm));
dplEvent->setForAsynchronousCall(&CalendarResponseDispatcher::getInstance());
itemIds = converter.toVectorOfEventIds(arguments[0]);
if (!itemIds) {
ThrowMsg(ConversionException, "Parameter conversion failed.");
- }
+ } else {
+ LogDebug("Array length: "<<itemIds->size());
+ }
} else if (JSValueIsString(context, element)) {
std::vector<std::string> idStrings = converter.toVectorOfStrings(arguments[0]);
EventIdListPtr result(new EventIdList());
#include "JSCalendarItemProperties.h"
#include "CalendarConverter.h"
#include "JSCalendarEventId.h"
+#include "JSCalendarRecurrenceRule.h"
#include "plugin_config.h"
#include "CalendarResponseDispatcher.h"
#include <TimeUtilConverter.h>
#include <SecurityExceptions.h>
#include "CalendarAsyncCallbackManager.h"
-
+#include <GlobalContextManager.h>
using namespace WrtDeviceApis::Commons;
using namespace WrtDeviceApis::CommonsJavaScript;
JSStaticValue JSCalendarEvent::m_property[] = {
{ TIZEN_CALENDAR_EVENT_ID, getPropertyId, NULL, kJSPropertyAttributeReadOnly },
{ TIZEN_CALENDAR_EVENT_IS_DETACHED, getPropertyIsDetached, NULL, kJSPropertyAttributeReadOnly },
+ { TIZEN_CALENDAR_EVENT_RECURRENCE_RULE, getPropertyRecurrenceRule, setPropertyRecurrenceRule, kJSPropertyAttributeNone },
{ 0, 0, 0, 0 }
};
{
Try
{
- CalendarEventPrivObject* privateObject = static_cast<CalendarEventPrivObject*>(JSObjectGetPrivate(constructor));
- JSContextRef globalContext = privateObject->getContext();
+ JSContextRef globalContext = GlobalContextManager::getInstance()->getGlobalContext(context);
CalendarConverter converter(globalContext);
CalendarEventPtr event;
CalendarEventPtr result(new CalendarEvent());
event = result;
} else if (JSValueIsObject(context, arguments[0])) {
- event = converter.toEvent(arguments[0]);
+ event = converter.toItem(arguments[0]);
if (!event) {
ThrowMsg(ConversionException, "Parameter conversion failed.");
}
{
Try
{
- CalendarEventPrivObject *privateObject =
- static_cast<CalendarEventPrivObject*>(JSObjectGetPrivate(object));
+ CalendarEventPrivObject *privateObject = static_cast<CalendarEventPrivObject*>(JSObjectGetPrivate(object));
CalendarEventPtr event = privateObject->getObject();
EventIdPtr eventId( new EventId() );
- if (UNDEFINED_ITEM_ID==event->getId()) {
- return JSValueMakeNull(context);
- } else {
- eventId->setUId(event->getUId());
- }
+ if (UNDEFINED_ITEM_ID==event->getId()) {
+ return JSValueMakeNull(context);
+ } else {
+ eventId->setUId(event->getUId());
+ }
std::stringstream ss;
std::time_t rid = event->getRecurrenceId();
return JSValueMakeUndefined(context);
}
-bool JSCalendarEvent::validate(JSContextRef ctx,
- const JSObjectRef object,
+JSValueRef JSCalendarEvent::getPropertyRecurrenceRule(JSContextRef context,
+ JSObjectRef object,
+ JSStringRef propertyName,
JSValueRef* exception)
{
- CalendarEventPrivObject *priv =
- static_cast<CalendarEventPrivObject*>(JSObjectGetPrivate(object));
- if (priv == NULL) {
- return false;
+ Try
+ {
+ CalendarItemPropertiesPrivObject *priv = static_cast<CalendarItemPropertiesPrivObject*>(JSObjectGetPrivate(object));
+
+ CalendarEventPtr event = getPrivateObject(object);
+ EventRecurrenceRulePtr rrule;
+ if (event->getIsDetached()) {
+ LogDebug("This is a detached event.");
+ return JSValueMakeUndefined(context);
+ } else {
+ rrule = event->getRecurrenceRule();
+ }
+
+ if (NULL==rrule) {
+ return JSValueMakeNull(context);
+ } else if (EventRecurrenceRule::NO_RECURRENCE==rrule->getFrequency()) {
+ return JSValueMakeUndefined(context);
+ } else {
+ return JSCalendarRecurrenceRule::createJSCalendarRecurrenceRule(priv->getContext(), rrule);
+ }
}
- CalendarEventPtr event = priv->getObject();
- if (!event) {
- return false;
+ Catch(Exception)
+ {
+ LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+ }
+ return JSValueMakeUndefined(context);
+}
+
+bool JSCalendarEvent::setPropertyRecurrenceRule(JSContextRef context,
+ JSObjectRef object,
+ JSStringRef propertyName,
+ JSValueRef value,
+ JSValueRef* exception)
+{
+ CalendarEventPtr event(NULL);
+ Try
+ {
+ event = getPrivateObject(object);
+ if (event->getIsDetached()) {
+ LogWarning("Can't set the recurrenceRule of a detached event!");
+ DeviceAPI::Common::JSTizenExceptionFactory::postException(context, exception, DeviceAPI::Common::JSTizenException::NOT_SUPPORTED_ERROR);
+ }
+
+ if (JSValueIsNull(context, value)) {
+ EventRecurrenceRulePtr rrule(NULL);
+ event->setRecurrenceRule(rrule);
+ } else if (JSValueIsUndefined(context, value)) {
+ EventRecurrenceRulePtr rrule( new EventRecurrenceRule() );
+ event->setRecurrenceRule(rrule);
+ } else {
+ event->setRecurrenceRule(JSCalendarRecurrenceRule::getPrivateObject(JSValueToObject(context, value, NULL)));
+ }
+ return true;
}
- return event->validate();
+ Catch(Exception)
+ {
+ LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+ DeviceAPI::Common::JSTizenExceptionFactory::postException(context, exception, DeviceAPI::Common::JSTizenException::TYPE_MISMATCH_ERROR);
+ }
+
+ return false;
}
}
#define TIZEN_INTERFACE_CALENDAR_EVENT "CalendarEvent"
#define TIZEN_CALENDAR_EVENT_ID "id"
-#define TIZEN_CALENDAR_EVENT_LAST_MODIFICATION_DATE "lastModificationDate"
#define TIZEN_CALENDAR_EVENT_IS_DETACHED "isDetached"
+#define TIZEN_CALENDAR_EVENT_END_DATE "endDate"
+#define TIZEN_CALENDAR_EVENT_AVAILABILITY "availability"
+#define TIZEN_CALENDAR_EVENT_RECURRENCE_RULE "recurrenceRule"
typedef WrtDeviceApis::CommonsJavaScript::PrivateObject<CalendarEventPtr,
WrtDeviceApis::CommonsJavaScript::NoOwnership> CalendarEventPrivObject;
JSContextRef ctx,
const JSObjectRef object);
- static bool validate(JSContextRef ctx,
- const JSObjectRef object,
- JSValueRef* exception);
-
static JSObjectRef createJSCalendarEvent(JSContextRef context, CalendarEventPtr event);
private:
JSObjectRef object,
JSStringRef propertyName,
JSValueRef* exception);
+ static JSValueRef getPropertyRecurrenceRule(JSContextRef context,
+ JSObjectRef object,
+ JSStringRef propertyName,
+ JSValueRef* exception);
+ static bool setPropertyRecurrenceRule(JSContextRef context,
+ JSObjectRef object,
+ JSStringRef propertyName,
+ JSValueRef value,
+ JSValueRef* exception);
};
}
#include "CalendarConverter.h"
#include "JSCalendarEventId.h"
#include "JSCalendarAlarm.h"
-#include "JSCalendarRecurrenceRule.h"
#include "JSCalendarAttendee.h"
#include "JSCalendarEvent.h"
#include "JSCalendarTask.h"
#include "plugin_config.h"
+#include <GlobalContextManager.h>
using namespace WrtDeviceApis::Commons;
using namespace WrtDeviceApis::CommonsJavaScript;
{ TIZEN_CALENDAR_ITEM_DURATION, getPropertyDuration, setPropertyDuration, kJSPropertyAttributeNone },
{ TIZEN_CALENDAR_ITEM_IS_ALL_DAY, getPropertyIsAllDay, setPropertyIsAllDay, kJSPropertyAttributeNone },
{ TIZEN_CALENDAR_ITEM_ATTENDEES, getPropertyAttendees, setPropertyAttendees, kJSPropertyAttributeNone },
- { TIZEN_CALENDAR_EVENT_RECURRENCE_RULE, getPropertyRecurrenceRule, setPropertyRecurrenceRule, kJSPropertyAttributeNone },
{ TIZEN_CALENDAR_EVENT_AVAILABILITY, getPropertyAvailability, setPropertyAvailability, kJSPropertyAttributeNone },
{ TIZEN_CALENDAR_TASK_DUE_DATE, getPropertyDueDate, setPropertyDueDate, kJSPropertyAttributeNone },
{ TIZEN_CALENDAR_TASK_COMPLETED_DATE, getPropertyCompletedDate, setPropertyCompletedDate, kJSPropertyAttributeNone },
{
Try
{
- CalendarConverter converter(context);
- CalendarEventPtr event = getPrivateObject(object);
- StringArrayPtr categories = event->getCategories();
- if (categories) {
- return converter.toJSValueRef(categories);
- }
+ CalendarEventPtr item = getPrivateObject(object);
+ JSContextRef globalContext = GlobalContextManager::getInstance()->getGlobalContext(context);
+
+ CalendarConverter converter(globalContext);
+
+ if(item->getCategoriesJSRef()) {
+ return item->getCategoriesJSRef();
+ } else {
+ LogDebug("Create a JS object for categories.");
+ StringArrayPtr categories = item->getCategories();
+ JSValueRef jsCategories = converter.toJSValueRefStringArray(categories);
+ item->setCategoriesJSRef(converter.toJSObjectRef(jsCategories));
+
+ JSValueProtect(globalContext, jsCategories);
+ item->setContext(globalContext);
+ return jsCategories;
+ }
}
Catch(Exception)
{
Try
{
CalendarEventPtr event = getPrivateObject(object);
- DeviceAPI::Tizen::SimpleCoordinatesPtr geoLocation(
- new DeviceAPI::Tizen::SimpleCoordinates(event->getLatitude(), event->getLongitude()) );
+ DeviceAPI::Tizen::SimpleCoordinatesPtr geoLocation( new DeviceAPI::Tizen::SimpleCoordinates(event->getLatitude(), event->getLongitude()) );
return DeviceAPI::Tizen::JSSimpleCoordinates::createJSObject(context, geoLocation);
}
Try
{
CalendarEventPtr event = getPrivateObject(object);
- DeviceAPI::Tizen::SimpleCoordinatesPtr geoLocation =
- DeviceAPI::Tizen::JSSimpleCoordinates::getSimpleCoordinates(context, value);
- event->setLatitude(geoLocation->getLatitude());
- event->setLongitude(geoLocation->getLongitude());
+ if (JSValueIsNull(context, value) || JSValueIsUndefined(context, value)) {
+ event->setLatitude(UNDEFINED_GEO);
+ event->setLongitude(UNDEFINED_GEO);
+ } else {
+ DeviceAPI::Tizen::SimpleCoordinatesPtr geoLocation = DeviceAPI::Tizen::JSSimpleCoordinates::getSimpleCoordinates(context, value);
+
+ event->setLatitude(geoLocation->getLatitude());
+ event->setLongitude(geoLocation->getLongitude());
+ }
return true;
}
Catch(Exception)
return false;
}
-JSValueRef JSCalendarItemProperties::getPropertyRecurrenceRule(JSContextRef context,
- JSObjectRef object,
- JSStringRef propertyName,
- JSValueRef* exception)
-{
- Try
- {
- CalendarItemPropertiesPrivObject *priv =
- static_cast<CalendarItemPropertiesPrivObject*>(JSObjectGetPrivate(object));
-
- CalendarEventPtr event = getPrivateObject(object);
- EventRecurrenceRulePtr rrule;
- if (event->getIsDetached()) {
- LogDebug("This is a detached event.");
- return JSValueMakeUndefined(context);
- } else {
- rrule = event->getRecurrenceRule();
- }
-
- if (EventRecurrenceRule::NO_RECURRENCE==rrule->getFrequency()) {
- return JSValueMakeUndefined(context);
- } else {
- return JSCalendarRecurrenceRule::createJSCalendarRecurrenceRule(priv->getContext(), rrule);
- }
- }
- Catch(Exception)
- {
- LogWarning("Exception: "<<_rethrown_exception.GetMessage());
- }
- return JSValueMakeUndefined(context);
-}
-
-bool JSCalendarItemProperties::setPropertyRecurrenceRule(JSContextRef context,
- JSObjectRef object,
- JSStringRef propertyName,
- JSValueRef value,
- JSValueRef* exception)
-{
- CalendarEventPtr event(NULL);
- Try
- {
- event = getPrivateObject(object);
- if (event->getIsDetached()) {
- LogWarning("Can't set the recurrenceRule of a detached event!");
- DeviceAPI::Common::JSTizenExceptionFactory::postException(context, exception, DeviceAPI::Common::JSTizenException::NOT_SUPPORTED_ERROR);
- }
- event->setRecurrenceRule(JSCalendarRecurrenceRule::getPrivateObject(JSValueToObject(context, value, NULL)));
- return true;
- }
- Catch(Exception)
- {
- LogWarning("Exception: "<<_rethrown_exception.GetMessage());
- DeviceAPI::Common::JSTizenExceptionFactory::postException(context, exception, DeviceAPI::Common::JSTizenException::TYPE_MISMATCH_ERROR);
- }
-
- return false;
-}
-
JSValueRef JSCalendarItemProperties::getPropertyIsAllDay(JSContextRef context,
JSObjectRef object,
JSStringRef propertyName,
return JSValueMakeUndefined(context);
}
-bool JSCalendarItemProperties::validate(JSContextRef ctx,
- const JSObjectRef object,
- JSValueRef* exception)
-{
- CalendarItemPropertiesPrivObject *priv =
- static_cast<CalendarItemPropertiesPrivObject*>(JSObjectGetPrivate(object));
- if (priv == NULL) {
- return false;
- }
- CalendarEventPtr event = priv->getObject();
- if (!event) {
- return false;
- }
- return event->validate();
-}
-
}
}
#define TIZEN_CALENDAR_ITEM_CATEGORIES "categories"
#define TIZEN_CALENDAR_ITEM_ATTENDEES "attendees"
#define TIZEN_CALENDAR_ITEM_CALENDAR_ID "calendarId"
-
-// CalendarTaskProperties
-#define TIZEN_CALENDAR_TASK_DUE_DATE "dueDate"
-#define TIZEN_CALENDAR_TASK_COMPLETED_DATE "completedDate"
-#define TIZEN_CALENDAR_TASK_PROGRESS "progress"
-
-// CalendarEventProperties
-#define TIZEN_CALENDAR_EVENT_END_DATE "endDate"
-#define TIZEN_CALENDAR_EVENT_AVAILABILITY "availability"
-#define TIZEN_CALENDAR_EVENT_RECURRENCE_RULE "recurrenceRule"
+#define TIZEN_CALENDAR_EVENT_LAST_MODIFICATION_DATE "lastModificationDate"
typedef WrtDeviceApis::CommonsJavaScript::PrivateObject<CalendarEventPtr,
WrtDeviceApis::CommonsJavaScript::NoOwnership> CalendarItemPropertiesPrivObject;
static JSObjectRef createJSCalendarItemProperties(JSContextRef context, CalendarEventPtr geo);
- static bool validate(JSContextRef ctx,
- const JSObjectRef object,
- JSValueRef* exception);
-
private:
/**
* This member variable contains the values which has to be passed when
JSStringRef propertyName,
JSValueRef value,
JSValueRef* exception);
- static JSValueRef getPropertyRecurrenceRule(JSContextRef context,
- JSObjectRef object,
- JSStringRef propertyName,
- JSValueRef* exception);
- static bool setPropertyRecurrenceRule(JSContextRef context,
- JSObjectRef object,
- JSStringRef propertyName,
- JSValueRef value,
- JSValueRef* exception);
static JSValueRef getPropertyDueDate(JSContextRef context,
JSObjectRef object,
JSStringRef propertyName,
#include <TimeUtilConverter.h>
#include <JSTZDate.h>
+#include <GlobalContextManager.h>
using namespace WrtDeviceApis::Commons;
using namespace WrtDeviceApis::CommonsJavaScript;
{
Try
{
- CalendarConverter converter(context);
+ JSContextRef globalContext = GlobalContextManager::getInstance()->getGlobalContext(context);
+ CalendarConverter converter(globalContext);
EventRecurrenceRulePtr rrule;
if (argumentCount==0) {
JSStringRef propertyName,
JSValueRef* exception)
{
- CalendarConverter converter(context);
- TimeUtilConverter timeConverter(context);
Try
{
- RecurrenceRulePrivateObject* priv =
- static_cast<RecurrenceRulePrivateObject*>(JSObjectGetPrivate(object));
- if (!priv) {
- ThrowMsg(NullPointerException, "Private object is NULL.");
- }
- EventRecurrenceRulePtr rrule = priv->getObject();
- if (!rrule) {
- ThrowMsg(NullPointerException, "recurrenceRule is NULL.");
- }
+ EventRecurrenceRulePtr rrule = getPrivateObject(object);
+ JSContextRef globalContext = GlobalContextManager::getInstance()->getGlobalContext(context);
+
+ CalendarConverter converter(globalContext);
+ TimeUtilConverter timeConverter(globalContext);
if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_RECURRENCE_RULE_FREQUENCY)) {
return converter.toJSValueRef(converter.toTizenValue(rrule->getFrequency()));
//} else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_RECURRENCE_RULE_DAYS_OF_THE_MONTH)) {
//return converter.toJSValueRef(rrule->getDaysOfTheMonth());
} else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_RECURRENCE_RULE_DAYS_OF_THE_WEEK)) {
- return converter.toJSValueRef(rrule->getDaysOfTheWeek());
+ if(rrule->getDaysOfTheWeekJSRef()) {
+ return rrule->getDaysOfTheWeekJSRef();
+ } else {
+ LogDebug("Create a JS object for daysOfTheWeek.");
+ StringArrayPtr daysOfTheWeek = rrule->getDaysOfTheWeek();
+ JSValueRef jsDaysOfTheWeek = converter.toJSValueRefStringArray(daysOfTheWeek);
+ rrule->setDaysOfTheWeekJSRef(converter.toJSObjectRef(jsDaysOfTheWeek));
+
+ JSValueProtect(globalContext, jsDaysOfTheWeek);
+ rrule->setContext(globalContext);
+ return jsDaysOfTheWeek;
+ }
//} else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_RECURRENCE_RULE_DAYS_OF_THE_YEAR)) {
//return converter.toJSValueRef(rrule->getDaysOfTheYear());
//} else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_RECURRENCE_RULE_WEEKS_OF_THE_YEAR)) {
//return converter.toJSValueRef(rrule->getWeeksOfTheYear());
} else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_RECURRENCE_RULE_SET_POSITIONS)) {
- return converter.toJSValueRefNumberArray(rrule->getSetPositions());
+ if(rrule->getSetPositionsJSRef()) {
+ return rrule->getSetPositionsJSRef();
+ } else {
+ LogDebug("Create a JS object for setPositions.");
+ NumberArrayPtr setPositions = rrule->getSetPositions();
+ JSValueRef jsSetPositions = converter.toJSValueRefNumberArray(setPositions);
+ rrule->setSetPositionsJSRef(converter.toJSObjectRef(jsSetPositions));
+
+ JSValueProtect(globalContext, jsSetPositions);
+ rrule->setContext(globalContext);
+ return jsSetPositions;
+ }
} else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_RECURRENCE_RULE_EXCEPTIONS)) {
- return converter.toJSValueRefTZDateArray(rrule->getExceptions());
+ if(rrule->getExceptionsJSRef()) {
+ return rrule->getExceptionsJSRef();
+ } else {
+ LogDebug("Create a JS object for exceptions with time zone: "<<rrule->getTimeZone());
+ NumberArrayPtr exceptions = rrule->getExceptions();
+ JSValueRef jsExceptions = converter.toJSValueRefTZDateArray(exceptions, rrule->getTimeZone());
+ rrule->setExceptionsJSRef(converter.toJSObjectRef(jsExceptions));
+
+ JSValueProtect(globalContext, jsExceptions);
+ rrule->setContext(globalContext);
+ return jsExceptions;
+ }
}
}
Catch(Exception)
#include <JSTizenException.h>
#include <JSTizenExceptionFactory.h>
+#include <GlobalContextManager.h>
using namespace WrtDeviceApis::Commons;
using namespace WrtDeviceApis::CommonsJavaScript;
{
Try
{
- CalendarConverter converter(context);
+ JSContextRef globalContext = GlobalContextManager::getInstance()->getGlobalContext(context);
+ CalendarConverter converter(globalContext);
CalendarEventPtr task;
if (argumentCount==0) {
CalendarEventPtr result(new CalendarEvent());
task = result;
} else if (JSValueIsObject(context, arguments[0])) {
- task = converter.toEvent(arguments[0]);
+ task = converter.toItem(arguments[0]);
if (!task) {
ThrowMsg(ConversionException, "Parameter conversion failed.");
}
return JSValueMakeUndefined(context);
}
-bool JSCalendarTask::validate(JSContextRef ctx,
- const JSObjectRef object,
- JSValueRef* exception)
-{
- CalendarTaskPrivObject *priv =
- static_cast<CalendarTaskPrivObject*>(JSObjectGetPrivate(object));
- if (priv == NULL) {
- return false;
- }
- CalendarEventPtr event = priv->getObject();
- if (!event) {
- return false;
- }
- return event->validate();
-}
-
}
}
#define TIZEN_INTERFACE_CALENDAR_TASK "CalendarTask"
#define TIZEN_CALENDAR_TASK_ID "id"
-#define TIZEN_CALENDAR_TASK_LAST_MODIFICATION_DATE "lastModificationDate"
+#define TIZEN_CALENDAR_TASK_DUE_DATE "dueDate"
+#define TIZEN_CALENDAR_TASK_COMPLETED_DATE "completedDate"
+#define TIZEN_CALENDAR_TASK_PROGRESS "progress"
typedef WrtDeviceApis::CommonsJavaScript::PrivateObject<CalendarEventPtr,
WrtDeviceApis::CommonsJavaScript::NoOwnership> CalendarTaskPrivObject;
JSContextRef ctx,
const JSObjectRef object);
- static bool validate(JSContextRef ctx,
- const JSObjectRef object,
- JSValueRef* exception);
-
static JSObjectRef createJSCalendarTask(JSContextRef context, CalendarEventPtr task);
private:
+++ /dev/null
-//
-// Tizen Web Device API
-// Copyright (c) 2012 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 <algorithm>
-#include <sstream>
-#include <dpl/log/log.h>
-#include <CommonsJavaScript/Converter.h>
-#include <CommonsJavaScript/ScopedJSStringRef.h>
-#include <JSTizenExceptionFactory.h>
-#include <JSTizenException.h>
-#include <CommonsJavaScript/Converter.h>
-#include "JSNumberArray.h"
-
-#define FUNCTION_CONCAT "concat"
-#define FUNCTION_JOIN "join"
-#define FUNCTION_POP "pop"
-#define FUNCTION_PUSH "push"
-#define FUNCTION_REVERSE "reverse"
-#define FUNCTION_SHIFT "shift"
-#define FUNCTION_SLICE "slice"
-#define FUNCTION_SORT "sort"
-#define FUNCTION_SPLICE "splice"
-#define FUNCTION_TOSTRING "toString"
-#define FUNCTION_UNSHIFT "unshift"
-#define FUNCTION_VALUEOF "valueOf"
-#define ARRAY "Array"
-#define ATTRIBUTE_LENGTH "length"
-
-namespace DeviceAPI {
-namespace Calendar {
-
-
-using namespace DeviceAPI::Common;
-using namespace WrtDeviceApis::CommonsJavaScript;
-
-JSClassDefinition JSNumberArray::m_classInfo = {
- 0,
- kJSClassAttributeNone,
- ARRAY,
- 0,
- m_property,
- m_function,
- initialize,
- finalize,
- hasProperty,
- getProperty,
- setProperty,
- NULL, //deleteProperty,
- getPropertyNames,
- NULL, //callAsFunction,
- NULL, //callAsConstructor,
- NULL, //hasInstance,
- NULL, //convertToType,
-};
-
-JSStaticValue JSNumberArray::m_property[] = {
- { ATTRIBUTE_LENGTH, getLength, NULL, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete },
- { 0, 0, 0, 0 }
-};
-
-JSStaticFunction JSNumberArray::m_function[] = {
- { FUNCTION_CONCAT, concat, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete },
- { FUNCTION_JOIN, join, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete },
- { FUNCTION_POP, pop, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete },
- { FUNCTION_PUSH, push, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete },
- { FUNCTION_REVERSE, reverse, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete },
- { FUNCTION_SHIFT, shift, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete },
- { FUNCTION_SLICE, slice, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete },
- { FUNCTION_SORT, sort, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete },
- { FUNCTION_SPLICE, splice, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete },
- { FUNCTION_TOSTRING, toString, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete },
- { FUNCTION_UNSHIFT, unshift, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete },
- { FUNCTION_VALUEOF, valueOf, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete },
- { 0, 0, 0 }
-};
-
-JSClassRef JSNumberArray::m_jsClassRef = JSClassCreate(
- JSNumberArray::getClassInfo());
-
-JSValueRef JSNumberArray::getLength(JSContextRef context,
- JSObjectRef object,
- JSStringRef propertyName,
- JSValueRef* exception)
-{
- Try
- {
- JSNumberArrayPriv* priv =
- static_cast<JSNumberArrayPriv*>(JSObjectGetPrivate(object));
- if (!priv) {
- Throw(WrtDeviceApis::Commons::NullPointerException);
- }
- NumberArrayPtr numbers = priv->getObject();
- if (numbers) {
- WrtDeviceApis::CommonsJavaScript::BasicConverter converter =
- WrtDeviceApis::CommonsJavaScript::BasicConverterFactory::getConverter(context);
- return converter->toJSValueRef(numbers->size());
- }
- }
- Catch(WrtDeviceApis::Commons::Exception)
- {
- LogError("invalid conversion");
- }
- return JSValueMakeUndefined(context);
-}
-
-JSObjectRef JSNumberArray::createArray(JSContextRef context,
- const NumberArrayPtr &numbers)
-{
- JSNumberArrayPriv *priv = new JSNumberArrayPriv(context, numbers);
- return JSObjectMake(context, getClassRef(), priv);
-}
-
-const JSClassDefinition* JSNumberArray::getClassInfo()
-{
- return &(m_classInfo);
-}
-
-JSClassRef JSNumberArray::getClassRef()
-{
- if (!m_jsClassRef) {
- m_jsClassRef = JSClassCreate(&m_classInfo);
- }
- return m_jsClassRef;
-}
-
-bool JSNumberArray::isObjectOfClass(JSContextRef context, JSValueRef value)
-{
- return JSValueIsObjectOfClass(context, value, getClassRef());
-}
-
-NumberArrayPtr JSNumberArray::getNumberArray(JSContextRef context, JSValueRef value)
-{
- if (!isObjectOfClass(context, value)) {
- Throw(WrtDeviceApis::Commons::InvalidArgumentException);
- }
- JSObjectRef object = JSValueToObject(context, value, NULL);
- if (!object) {
- Throw(WrtDeviceApis::Commons::InvalidArgumentException);
- }
- JSNumberArrayPriv* priv = static_cast<JSNumberArrayPriv*>(JSObjectGetPrivate(object));
- if (!priv) {
- Throw(WrtDeviceApis::Commons::NullPointerException);
- }
- return priv->getObject();
-}
-
-void JSNumberArray::initialize(JSContextRef context,
- JSObjectRef object)
-{
-}
-
-void JSNumberArray::finalize(JSObjectRef object)
-{
- JSNumberArrayPriv* priv =
- static_cast<JSNumberArrayPriv*>(JSObjectGetPrivate(object));
- delete priv;
- JSObjectSetPrivate(object, NULL);
-}
-
-bool JSNumberArray::hasProperty(JSContextRef context,
- JSObjectRef object,
- JSStringRef propertyName)
-{
- WrtDeviceApis::CommonsJavaScript::BasicConverter converter =
- WrtDeviceApis::CommonsJavaScript::BasicConverterFactory::getConverter(context);
- Try
- {
- size_t index = converter->toSizeT(propertyName);
- JSNumberArrayPriv* priv =
- static_cast<JSNumberArrayPriv*>(JSObjectGetPrivate(object));
- if (!priv) {
- Throw(WrtDeviceApis::Commons::NullPointerException);
- }
- NumberArrayPtr numbers = priv->getObject();
- if (index < numbers->size()) {
- return true;
- }
- }
- Catch(WrtDeviceApis::Commons::Exception)
- {
- //not reporting error is intended
- }
- return false;
-}
-
-JSValueRef JSNumberArray::getProperty(JSContextRef context,
- JSObjectRef object,
- JSStringRef propertyName,
- JSValueRef* exception)
-{
- WrtDeviceApis::CommonsJavaScript::BasicConverter converter =
- WrtDeviceApis::CommonsJavaScript::BasicConverterFactory::getConverter(context);
-
- Try
- {
- size_t index = converter->toSizeT(propertyName);
- JSNumberArrayPriv* priv =
- static_cast<JSNumberArrayPriv*>(JSObjectGetPrivate(object));
- if (!priv) {
- Throw(WrtDeviceApis::Commons::NullPointerException);
- }
- NumberArrayPtr numbers = priv->getObject();
- if (index < numbers->size()) {
- long long int result = numbers->at(index);
- LogInfo("index: "<<index<<", result: "<<result);
- return converter->toJSValueRef(result);
- }
- }
- Catch(WrtDeviceApis::Commons::Exception)
- {
- LogError("invalid property");
- }
- return JSValueMakeUndefined(context);
-}
-
-bool JSNumberArray::setProperty(JSContextRef context,
- JSObjectRef object,
- JSStringRef propertyName,
- JSValueRef value,
- JSValueRef* exception)
-{
- WrtDeviceApis::CommonsJavaScript::BasicConverter converter =
- WrtDeviceApis::CommonsJavaScript::BasicConverterFactory::getConverter(context);
-
- Try
- {
- size_t index = converter->toSizeT(propertyName);
- long long int number = 0;
- if (!JSValueIsUndefined(context, value)) {
- number = converter->toLongLong(value);
- }
- JSNumberArrayPriv* priv =
- static_cast<JSNumberArrayPriv*>(JSObjectGetPrivate(object));
- if (!priv) {
- Throw(WrtDeviceApis::Commons::NullPointerException);
- }
- NumberArrayPtr numbers = priv->getObject();
- if (!numbers) {
- Throw(WrtDeviceApis::Commons::NullPointerException);
- }
- if (numbers->size() <= index) {
- numbers->resize(index + 1);
- }
- (*numbers)[index] = number;
- return true;
- }
- Catch(WrtDeviceApis::Commons::Exception)
- {
- LogError("error occured");
- JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
- }
- return false;
-}
-
-void JSNumberArray::getPropertyNames(JSContextRef context,
- JSObjectRef object,
- JSPropertyNameAccumulatorRef propertyNames)
-{
- Converter converter(context);
-
- Try
- {
- JSNumberArrayPriv* priv =
- static_cast<JSNumberArrayPriv*>(JSObjectGetPrivate(object));
- if (!priv) {
- Throw(WrtDeviceApis::Commons::NullPointerException);
- }
- NumberArrayPtr numbers = priv->getObject();
-
- int count = numbers->size();
-
- for(int i=0; i < count; i++)
- {
- ScopedJSStringRef name(converter.toJSStringRef(converter.toString(i)));
- JSPropertyNameAccumulatorAddName(propertyNames, name.get());
- }
- }
- Catch(WrtDeviceApis::Commons::Exception)
- {
- LogError("invalid property");
- }
-}
-
-JSValueRef JSNumberArray::concat(JSContextRef context,
- JSObjectRef function,
- JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception)
-{
- Try
- {
- NumberArrayPtr numbers = NumberArrayPtr(new NumberArray());
- JSNumberArrayPriv *newPrivateObject = new JSNumberArrayPriv(
- context,
- numbers);
- JSValueRef result = JSObjectMake(context,
- getClassRef(), newPrivateObject);
-
- //copy current numbers
- JSNumberArrayPriv* priv =
- static_cast<JSNumberArrayPriv*>(JSObjectGetPrivate(thisObject));
- NumberArrayPtr currentNumbers = priv->getObject();
- for (size_t i = 0; i < currentNumbers->size(); ++i) {
- numbers->push_back(currentNumbers->at(i));
- }
-
- //copy submitted arrays
- WrtDeviceApis::CommonsJavaScript::BasicConverter converter =
- WrtDeviceApis::CommonsJavaScript::BasicConverterFactory::getConverter(context);
- for (size_t i = 0; i < argumentCount; ++i) {
- if (!JSIsArrayValue(context, arguments[i])) {
- Throw(WrtDeviceApis::Commons::ConversionException);
- }
- // process array of numbers
- JSObjectRef arrayObj = converter->toJSObjectRef(arguments[i]);
- unsigned int len = JSGetArrayLength(context, arrayObj);
- for (unsigned int e = 0; e < len; ++e) {
- JSValueRef att = JSGetArrayElement(context, arrayObj, e);
- numbers->push_back(converter->toLong(att));
- }
- }
- return result;
- }
- Catch(WrtDeviceApis::Commons::Exception)
- {
- LogError("error occured");
- }
- return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
-}
-
-JSValueRef JSNumberArray::join(JSContextRef context,
- JSObjectRef function,
- JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception)
-{
- Try
- {
- std::string result;
- std::string separator(",");
- WrtDeviceApis::CommonsJavaScript::BasicConverter converter =
- WrtDeviceApis::CommonsJavaScript::BasicConverterFactory::getConverter(context);
- JSNumberArrayPriv* priv = static_cast<JSNumberArrayPriv*>(JSObjectGetPrivate(thisObject));
- NumberArrayPtr currentNumbers = priv->getObject();
- if (argumentCount > 0 && JSValueIsString(context, arguments[0])) {
- separator = converter->toString(arguments[0]);
- LogDebug("Separator: "<<separator);
- }
- for (size_t i = 0; i < currentNumbers->size(); ++i) {
- if (i != 0) {
- result += separator;
- }
- std::stringstream ss;
- ss<<currentNumbers->at(i);
- result += ss.str();
- }
- LogDebug("Resulting string: "<<result);
- return converter->toJSValueRef(result);
- }
- Catch(WrtDeviceApis::Commons::Exception)
- {
- LogError("error occured");
- }
- return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
-}
-
-JSValueRef JSNumberArray::pop(JSContextRef context,
- JSObjectRef function,
- JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception)
-{
- Try
- {
- WrtDeviceApis::CommonsJavaScript::BasicConverter converter =
- WrtDeviceApis::CommonsJavaScript::BasicConverterFactory::getConverter(context);
- JSNumberArrayPriv* priv =
- static_cast<JSNumberArrayPriv*>(JSObjectGetPrivate(thisObject));
- NumberArrayPtr currentNumbers = priv->getObject();
- if (currentNumbers->size() > 0) {
- long long int result = currentNumbers->at(
- currentNumbers->size() - 1);
- currentNumbers->pop_back();
- return converter->toJSValueRef(result);
- }
- }
- Catch(WrtDeviceApis::Commons::Exception)
- {
- LogError("error occured");
- }
- return JSValueMakeUndefined(context);
-}
-
-JSValueRef JSNumberArray::push(JSContextRef context,
- JSObjectRef function,
- JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception)
-{
- Try
- {
- WrtDeviceApis::CommonsJavaScript::BasicConverter converter =
- WrtDeviceApis::CommonsJavaScript::BasicConverterFactory::getConverter(context);
- JSNumberArrayPriv* priv =
- static_cast<JSNumberArrayPriv*>(JSObjectGetPrivate(thisObject));
- NumberArrayPtr currentNumbers = priv->getObject();
- for (size_t i = 0; i < argumentCount; ++i) {
- currentNumbers->push_back(converter->toLong(arguments[i]));
- }
- return converter->toJSValueRef(currentNumbers->size());
- }
- Catch(WrtDeviceApis::Commons::Exception)
- {
- LogError("error occured");
- }
- return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
-}
-
-JSValueRef JSNumberArray::reverse(JSContextRef context,
- JSObjectRef function,
- JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception)
-{
- Try
- {
- WrtDeviceApis::CommonsJavaScript::BasicConverter converter =
- WrtDeviceApis::CommonsJavaScript::BasicConverterFactory::getConverter(context);
- JSNumberArrayPriv* priv =
- static_cast<JSNumberArrayPriv*>(JSObjectGetPrivate(thisObject));
- NumberArrayPtr currentNumbers = priv->getObject();
- std::reverse(currentNumbers->begin(), currentNumbers->end());
- return thisObject;
- }
- Catch(WrtDeviceApis::Commons::Exception)
- {
- LogError("error occured");
- }
- return JSValueMakeUndefined(context);
-}
-
-JSValueRef JSNumberArray::shift(JSContextRef context,
- JSObjectRef function,
- JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception)
-{
- Try
- {
- WrtDeviceApis::CommonsJavaScript::BasicConverter converter =
- WrtDeviceApis::CommonsJavaScript::BasicConverterFactory::getConverter(context);
- JSNumberArrayPriv* priv =
- static_cast<JSNumberArrayPriv*>(JSObjectGetPrivate(thisObject));
- NumberArrayPtr currentNumbers = priv->getObject();
- if (currentNumbers->size() > 0) {
- long long int result = currentNumbers->at(0);
- currentNumbers->erase(currentNumbers->begin());
- return converter->toJSValueRef(result);
- }
- }
- Catch(WrtDeviceApis::Commons::Exception)
- {
- LogError("error occured");
- }
- return JSValueMakeUndefined(context);
-}
-
-JSValueRef JSNumberArray::slice(JSContextRef context,
- JSObjectRef function,
- JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception)
-{
- Try
- {
- if (argumentCount < 1) {
- return JSValueMakeUndefined(context);
- }
- WrtDeviceApis::CommonsJavaScript::BasicConverter converter =
- WrtDeviceApis::CommonsJavaScript::BasicConverterFactory::getConverter(context);
- NumberArrayPtr numbers = NumberArrayPtr(new NumberArray());
- JSNumberArrayPriv *newPrivateObject = new JSNumberArrayPriv(
- context,
- numbers);
- JSValueRef result = JSObjectMake(context,
- getClassRef(), newPrivateObject);
-
- //copy current numbers
- JSNumberArrayPriv* priv =
- static_cast<JSNumberArrayPriv*>(JSObjectGetPrivate(thisObject));
- NumberArrayPtr currentNumbers = priv->getObject();
- std::size_t first = converter->toSizeT(arguments[0]);
- std::size_t last = currentNumbers->size() - 1;
- if (argumentCount > 1) {
- last = converter->toSizeT(arguments[1]);
- if (last >= currentNumbers->size()) {
- last = currentNumbers->size() - 1;
- }
- }
- for (size_t i = first; i <= last; ++i) {
- numbers->push_back(currentNumbers->at(i));
- }
-
- return result;
- }
- Catch(WrtDeviceApis::Commons::Exception)
- {
- LogError("error occured");
- }
- return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
-}
-
-JSValueRef JSNumberArray::sort(JSContextRef context,
- JSObjectRef function,
- JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception)
-{
- Try
- {
- WrtDeviceApis::CommonsJavaScript::BasicConverter converter =
- WrtDeviceApis::CommonsJavaScript::BasicConverterFactory::getConverter(context);
- JSNumberArrayPriv* priv =
- static_cast<JSNumberArrayPriv*>(JSObjectGetPrivate(thisObject));
- NumberArrayPtr currentNumbers = priv->getObject();
- std::sort(currentNumbers->begin(), currentNumbers->end());
- return thisObject;
- }
- Catch(WrtDeviceApis::Commons::Exception)
- {
- LogError("error occured");
- }
- return JSValueMakeUndefined(context);
-}
-
-JSValueRef JSNumberArray::splice(JSContextRef context,
- JSObjectRef function,
- JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception)
-{
- return JSValueMakeUndefined(context);
-}
-
-JSValueRef JSNumberArray::toString(JSContextRef context,
- JSObjectRef function,
- JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception)
-{
- return join(context, function, thisObject, 0, arguments, exception);
-}
-
-JSValueRef JSNumberArray::unshift(JSContextRef context,
- JSObjectRef function,
- JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception)
-{
- return JSValueMakeUndefined(context);
-}
-
-JSValueRef JSNumberArray::valueOf(JSContextRef context,
- JSObjectRef function,
- JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception)
-{
- return JSValueMakeUndefined(context);
-}
-
-} // Calendar
-} // DeviceAPI
+++ /dev/null
-//
-// Tizen Web Device API
-// Copyright (c) 2012 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 _TIZEN_CALENDAR_JS_NUMBER_ARRAY_H_
-#define _TIZEN_CALENDAR_JS_NUMBER_ARRAY_H_
-
-#include <vector>
-#include <JavaScriptCore/JavaScript.h>
-#include <CommonsJavaScript/PrivateObject.h>
-#include "CalendarEvent.h"
-
-namespace DeviceAPI {
-namespace Calendar {
-
-typedef WrtDeviceApis::CommonsJavaScript::PrivateObjectT<NumberArrayPtr>::Type JSNumberArrayPriv;
-
-class JSNumberArray
-{
-public:
-
- static const JSClassDefinition* getClassInfo();
-
- static JSClassRef getClassRef();
-
- static JSObjectRef createArray(JSContextRef context,
- const NumberArrayPtr &Numbers);
-
- static bool isObjectOfClass(JSContextRef context, JSValueRef value);
-
- static NumberArrayPtr getNumberArray(JSContextRef context, JSValueRef value);
-
-private:
-
- /**
- * The callback invoked when an object is first created.
- */
- static void initialize(JSContextRef context,
- JSObjectRef object);
-
- /**
- * The callback invoked when an object is finalized.
- */
- static void finalize(JSObjectRef object);
-
- static JSValueRef getLength(JSContextRef context,
- JSObjectRef object,
- JSStringRef propertyName,
- JSValueRef* exception);
-
- static bool hasProperty(JSContextRef context,
- JSObjectRef object,
- JSStringRef propertyName);
-
- static JSValueRef getProperty(JSContextRef context,
- JSObjectRef object,
- JSStringRef propertyName,
- JSValueRef* exception);
-
- static bool setProperty(JSContextRef context,
- JSObjectRef object,
- JSStringRef propertyName,
- JSValueRef value,
- JSValueRef* exception);
-
- static void getPropertyNames(JSContextRef context,
- JSObjectRef object,
- JSPropertyNameAccumulatorRef propertyNames);
-
- static JSValueRef concat(JSContextRef context,
- JSObjectRef function,
- JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception);
- static JSValueRef join(JSContextRef context,
- JSObjectRef function,
- JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception);
-
- static JSValueRef pop(JSContextRef context,
- JSObjectRef function,
- JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception);
- static JSValueRef push(JSContextRef context,
- JSObjectRef function,
- JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception);
- static JSValueRef reverse(JSContextRef context,
- JSObjectRef function,
- JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception);
- static JSValueRef shift(JSContextRef context,
- JSObjectRef function,
- JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception);
- static JSValueRef slice(JSContextRef context,
- JSObjectRef function,
- JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception);
- static JSValueRef sort(JSContextRef context,
- JSObjectRef function,
- JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception);
- static JSValueRef splice(JSContextRef context,
- JSObjectRef function,
- JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception);
- static JSValueRef toString(JSContextRef context,
- JSObjectRef function,
- JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception);
- static JSValueRef unshift(JSContextRef context,
- JSObjectRef function,
- JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception);
- static JSValueRef valueOf(JSContextRef context,
- JSObjectRef function,
- JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception);
-
- static bool checkValue(const long long int &value);
-
- static JSClassRef m_jsClassRef;
- /**
- * This structure describes a statically declared function property.
- */
- static JSStaticFunction m_function[];
-
- /**
- * This structure contains properties and callbacks that define a type of object.
- */
- static JSClassDefinition m_classInfo;
-
- /**
- * This member variable contains the initialization values for the static properties of this class.
- * The values are given according to the data structure JSPropertySpec
- */
- static JSStaticValue m_property[];
-};
-
-} // Calendar
-} // DeviceAPI
-
-#endif // _TIZEN_CALENDAR_JS_NUMBER_ARRAY_H_
+++ /dev/null
-//
-// Tizen Web Device API
-// Copyright (c) 2012 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 <algorithm>
-#include <dpl/log/log.h>
-#include <CommonsJavaScript/Converter.h>
-#include <CommonsJavaScript/ScopedJSStringRef.h>
-#include <JSTizenExceptionFactory.h>
-#include <JSTizenException.h>
-#include "CalendarConverter.h"
-#include "JSStringArray.h"
-
-#define FUNCTION_CONCAT "concat"
-#define FUNCTION_JOIN "join"
-#define FUNCTION_POP "pop"
-#define FUNCTION_PUSH "push"
-#define FUNCTION_REVERSE "reverse"
-#define FUNCTION_SHIFT "shift"
-#define FUNCTION_SLICE "slice"
-#define FUNCTION_SORT "sort"
-#define FUNCTION_SPLICE "splice"
-#define FUNCTION_TOSTRING "toString"
-#define FUNCTION_UNSHIFT "unshift"
-#define FUNCTION_VALUEOF "valueOf"
-#define ARRAY "Array"
-#define ATTRIBUTE_LENGTH "length"
-
-namespace DeviceAPI {
-namespace Calendar {
-
-
-using namespace DeviceAPI::Common;
-using namespace WrtDeviceApis::CommonsJavaScript;
-
-JSClassDefinition JSStringArray::m_classInfo = {
- 0,
- kJSClassAttributeNone,
- ARRAY,
- 0,
- m_property,
- m_function,
- initialize,
- finalize,
- hasProperty,
- getProperty,
- setProperty,
- NULL, //deleteProperty,
- getPropertyNames,
- NULL, //callAsFunction,
- NULL, //callAsConstructor,
- NULL, //hasInstance,
- NULL, //convertToType,
-};
-
-JSStaticValue JSStringArray::m_property[] = {
- { ATTRIBUTE_LENGTH, getLength, NULL, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete },
- { 0, 0, 0, 0 }
-};
-
-JSStaticFunction JSStringArray::m_function[] = {
- { FUNCTION_CONCAT, concat, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete },
- { FUNCTION_JOIN, join, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete },
- { FUNCTION_POP, pop, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete },
- { FUNCTION_PUSH, push, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete },
- { FUNCTION_REVERSE, reverse, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete },
- { FUNCTION_SHIFT, shift, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete },
- { FUNCTION_SLICE, slice, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete },
- { FUNCTION_SORT, sort, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete },
- { FUNCTION_SPLICE, splice, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete },
- { FUNCTION_TOSTRING, toString, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete },
- { FUNCTION_UNSHIFT, unshift, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete },
- { FUNCTION_VALUEOF, valueOf, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete },
- { 0, 0, 0 }
-};
-
-JSClassRef JSStringArray::m_jsClassRef = JSClassCreate(
- JSStringArray::getClassInfo());
-
-JSValueRef JSStringArray::getLength(JSContextRef context,
- JSObjectRef object,
- JSStringRef propertyName,
- JSValueRef* exception)
-{
- Try
- {
- JSStringArrayPriv* priv =
- static_cast<JSStringArrayPriv*>(JSObjectGetPrivate(object));
- if (!priv) {
- Throw(WrtDeviceApis::Commons::NullPointerException);
- }
- StringArrayPtr strs = priv->getObject();
- if (strs) {
- WrtDeviceApis::CommonsJavaScript::BasicConverter converter =
- WrtDeviceApis::CommonsJavaScript::BasicConverterFactory::getConverter(context);
- return converter->toJSValueRef(strs->size());
- }
- }
- Catch(WrtDeviceApis::Commons::Exception)
- {
- LogError("invalid conversion");
- }
- return JSValueMakeUndefined(context);
-}
-
-JSObjectRef JSStringArray::createArray(JSContextRef context,
- const StringArrayPtr &strs)
-{
- JSStringArrayPriv *priv = new JSStringArrayPriv(context, strs);
- return JSObjectMake(context, getClassRef(), priv);
-}
-
-const JSClassDefinition* JSStringArray::getClassInfo()
-{
- return &(m_classInfo);
-}
-
-JSClassRef JSStringArray::getClassRef()
-{
- if (!m_jsClassRef) {
- m_jsClassRef = JSClassCreate(&m_classInfo);
- }
- return m_jsClassRef;
-}
-
-bool JSStringArray::isObjectOfClass(JSContextRef context, JSValueRef value)
-{
- return JSValueIsObjectOfClass(context, value, getClassRef());
-}
-
-StringArrayPtr JSStringArray::getStringArray(JSContextRef context, JSValueRef value)
-{
- if (!isObjectOfClass(context, value)) {
- Throw(WrtDeviceApis::Commons::InvalidArgumentException);
- }
- JSObjectRef object = JSValueToObject(context, value, NULL);
- if (!object) {
- Throw(WrtDeviceApis::Commons::InvalidArgumentException);
- }
- JSStringArrayPriv* priv = static_cast<JSStringArrayPriv*>(JSObjectGetPrivate(object));
- if (!priv) {
- Throw(WrtDeviceApis::Commons::NullPointerException);
- }
- return priv->getObject();
-}
-
-void JSStringArray::initialize(JSContextRef context,
- JSObjectRef object)
-{
-}
-
-void JSStringArray::finalize(JSObjectRef object)
-{
- JSStringArrayPriv* priv =
- static_cast<JSStringArrayPriv*>(JSObjectGetPrivate(object));
- delete priv;
- JSObjectSetPrivate(object, NULL);
-}
-
-bool JSStringArray::hasProperty(JSContextRef context,
- JSObjectRef object,
- JSStringRef propertyName)
-{
- WrtDeviceApis::CommonsJavaScript::BasicConverter converter =
- WrtDeviceApis::CommonsJavaScript::BasicConverterFactory::getConverter(context);
- Try
- {
- size_t index = converter->toSizeT(propertyName);
- JSStringArrayPriv* priv =
- static_cast<JSStringArrayPriv*>(JSObjectGetPrivate(object));
- if (!priv) {
- Throw(WrtDeviceApis::Commons::NullPointerException);
- }
- StringArrayPtr strs = priv->getObject();
- if (index < strs->size()) {
- return true;
- }
- }
- Catch(WrtDeviceApis::Commons::Exception)
- {
- //not reporting error is intended
- }
- return false;
-}
-
-JSValueRef JSStringArray::getProperty(JSContextRef context,
- JSObjectRef object,
- JSStringRef propertyName,
- JSValueRef* exception)
-{
- WrtDeviceApis::CommonsJavaScript::BasicConverter converter =
- WrtDeviceApis::CommonsJavaScript::BasicConverterFactory::getConverter(context);
- Try
- {
- size_t index = converter->toSizeT(propertyName);
- JSStringArrayPriv* priv =
- static_cast<JSStringArrayPriv*>(JSObjectGetPrivate(object));
- if (!priv) {
- Throw(WrtDeviceApis::Commons::NullPointerException);
- }
- StringArrayPtr strs = priv->getObject();
- if (index < strs->size()) {
- std::string result = strs->at(index);
- if (!result.empty()) {
- return converter->toJSValueRef(result);
- }
- }
- }
- Catch(WrtDeviceApis::Commons::Exception)
- {
- LogError("invalid property");
- }
- return JSValueMakeUndefined(context);
-}
-
-bool JSStringArray::setProperty(JSContextRef context,
- JSObjectRef object,
- JSStringRef propertyName,
- JSValueRef value,
- JSValueRef* exception)
-{
- WrtDeviceApis::CommonsJavaScript::BasicConverter converter =
- WrtDeviceApis::CommonsJavaScript::BasicConverterFactory::getConverter(context);
- Try
- {
- size_t index = converter->toSizeT(propertyName);
- std::string str;
- if (!JSValueIsUndefined(context, value)) {
- str = converter->toString(value);
- }
- JSStringArrayPriv* priv =
- static_cast<JSStringArrayPriv*>(JSObjectGetPrivate(object));
- if (!priv) {
- Throw(WrtDeviceApis::Commons::NullPointerException);
- }
- StringArrayPtr strs = priv->getObject();
- if (!strs) {
- Throw(WrtDeviceApis::Commons::NullPointerException);
- }
- if (strs->size() <= index) {
- strs->resize(index + 1);
- }
- (*strs)[index] = str;
- return true;
- }
- Catch(WrtDeviceApis::Commons::Exception)
- {
- LogError("error occured");
- JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
- }
- return false;
-}
-
-void JSStringArray::getPropertyNames(JSContextRef context,
- JSObjectRef object,
- JSPropertyNameAccumulatorRef propertyNames)
-{
- CalendarConverter converter(context);
-
- Try
- {
- JSStringArrayPriv* priv =
- static_cast<JSStringArrayPriv*>(JSObjectGetPrivate(object));
- if (!priv) {
- Throw(WrtDeviceApis::Commons::NullPointerException);
- }
- StringArrayPtr strings = priv->getObject();
-
- int count = strings->size();
-
- for(int i=0; i < count; i++)
- {
- ScopedJSStringRef name(converter.toJSStringRef(converter.toString(i)));
- JSPropertyNameAccumulatorAddName(propertyNames, name.get());
- }
- }
- Catch(WrtDeviceApis::Commons::Exception)
- {
- LogError("invalid property");
- }
-}
-
-JSValueRef JSStringArray::concat(JSContextRef context,
- JSObjectRef function,
- JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception)
-{
- Try
- {
- StringArrayPtr strs = StringArrayPtr(new StringArray());
- JSStringArrayPriv *newPrivateObject = new JSStringArrayPriv(
- context,
- strs);
- JSValueRef result = JSObjectMake(context,
- getClassRef(), newPrivateObject);
-
- //copy current strs
- JSStringArrayPriv* priv =
- static_cast<JSStringArrayPriv*>(JSObjectGetPrivate(thisObject));
- StringArrayPtr currentStrings = priv->getObject();
- for (size_t i = 0; i < currentStrings->size(); ++i) {
- strs->push_back(currentStrings->at(i));
- }
-
- //copy submitted arrays
- WrtDeviceApis::CommonsJavaScript::BasicConverter converter =
- WrtDeviceApis::CommonsJavaScript::BasicConverterFactory::getConverter(context);
- for (size_t i = 0; i < argumentCount; ++i) {
- if (!JSIsArrayValue(context, arguments[i])) {
- Throw(WrtDeviceApis::Commons::ConversionException);
- }
- // process array of strings
- JSObjectRef arrayObj = converter->toJSObjectRef(arguments[i]);
- unsigned int len = JSGetArrayLength(context, arrayObj);
- for (unsigned int e = 0; e < len; ++e) {
- JSValueRef att = JSGetArrayElement(context, arrayObj, e);
- strs->push_back(converter->toString(att));
- }
- }
- return result;
- }
- Catch(WrtDeviceApis::Commons::Exception)
- {
- LogError("error occured");
- }
- return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
-}
-
-JSValueRef JSStringArray::join(JSContextRef context,
- JSObjectRef function,
- JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception)
-{
- Try
- {
- std::string result;
- std::string separator(",");
- WrtDeviceApis::CommonsJavaScript::BasicConverter converter =
- WrtDeviceApis::CommonsJavaScript::BasicConverterFactory::getConverter(context);
- JSStringArrayPriv* priv =
- static_cast<JSStringArrayPriv*>(JSObjectGetPrivate(thisObject));
- StringArrayPtr currentStrings = priv->getObject();
- if (argumentCount > 0 && JSValueIsString(context, arguments[0])) {
- separator = converter->toString(arguments[0]);
- }
- for (size_t i = 0; i < currentStrings->size(); ++i) {
- if (i != 0) {
- result += separator;
- }
- result += currentStrings->at(i);
- }
- return converter->toJSValueRef(result);
- }
- Catch(WrtDeviceApis::Commons::Exception)
- {
- LogError("error occured");
- }
- return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
-}
-
-JSValueRef JSStringArray::pop(JSContextRef context,
- JSObjectRef function,
- JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception)
-{
- Try
- {
- WrtDeviceApis::CommonsJavaScript::BasicConverter converter =
- WrtDeviceApis::CommonsJavaScript::BasicConverterFactory::getConverter(context);
- JSStringArrayPriv* priv =
- static_cast<JSStringArrayPriv*>(JSObjectGetPrivate(thisObject));
- StringArrayPtr currentStrings = priv->getObject();
- if (currentStrings->size() > 0) {
- std::string result = currentStrings->at(
- currentStrings->size() - 1);
- currentStrings->pop_back();
- return converter->toJSValueRef(result);
- }
- }
- Catch(WrtDeviceApis::Commons::Exception)
- {
- LogError("error occured");
- }
- return JSValueMakeUndefined(context);
-}
-
-JSValueRef JSStringArray::push(JSContextRef context,
- JSObjectRef function,
- JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception)
-{
- Try
- {
- WrtDeviceApis::CommonsJavaScript::BasicConverter converter =
- WrtDeviceApis::CommonsJavaScript::BasicConverterFactory::getConverter(context);
- JSStringArrayPriv* priv =
- static_cast<JSStringArrayPriv*>(JSObjectGetPrivate(thisObject));
- StringArrayPtr currentStrings = priv->getObject();
- for (size_t i = 0; i < argumentCount; ++i) {
- currentStrings->push_back(converter->toString(arguments[i]));
- }
- return converter->toJSValueRef(currentStrings->size());
- }
- Catch(WrtDeviceApis::Commons::Exception)
- {
- LogError("error occured");
- }
- return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
-}
-
-JSValueRef JSStringArray::reverse(JSContextRef context,
- JSObjectRef function,
- JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception)
-{
- Try
- {
- WrtDeviceApis::CommonsJavaScript::BasicConverter converter =
- WrtDeviceApis::CommonsJavaScript::BasicConverterFactory::getConverter(context);
- JSStringArrayPriv* priv =
- static_cast<JSStringArrayPriv*>(JSObjectGetPrivate(thisObject));
- StringArrayPtr currentStrings = priv->getObject();
- std::reverse(currentStrings->begin(), currentStrings->end());
- return thisObject;
- }
- Catch(WrtDeviceApis::Commons::Exception)
- {
- LogError("error occured");
- }
- return JSValueMakeUndefined(context);
-}
-
-JSValueRef JSStringArray::shift(JSContextRef context,
- JSObjectRef function,
- JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception)
-{
- Try
- {
- WrtDeviceApis::CommonsJavaScript::BasicConverter converter =
- WrtDeviceApis::CommonsJavaScript::BasicConverterFactory::getConverter(context);
- JSStringArrayPriv* priv =
- static_cast<JSStringArrayPriv*>(JSObjectGetPrivate(thisObject));
- StringArrayPtr currentStrings = priv->getObject();
- if (currentStrings->size() > 0) {
- std::string result = currentStrings->at(0);
- currentStrings->erase(currentStrings->begin());
- return converter->toJSValueRef(result);
- }
- }
- Catch(WrtDeviceApis::Commons::Exception)
- {
- LogError("error occured");
- }
- return JSValueMakeUndefined(context);
-}
-
-JSValueRef JSStringArray::slice(JSContextRef context,
- JSObjectRef function,
- JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception)
-{
- Try
- {
- if (argumentCount < 1) {
- return JSValueMakeUndefined(context);
- }
- WrtDeviceApis::CommonsJavaScript::BasicConverter converter =
- WrtDeviceApis::CommonsJavaScript::BasicConverterFactory::getConverter(context);
- StringArrayPtr strs = StringArrayPtr(new StringArray());
- JSStringArrayPriv *newPrivateObject = new JSStringArrayPriv(
- context,
- strs);
- JSValueRef result = JSObjectMake(context,
- getClassRef(), newPrivateObject);
-
- //copy current strs
- JSStringArrayPriv* priv =
- static_cast<JSStringArrayPriv*>(JSObjectGetPrivate(thisObject));
- StringArrayPtr currentStrings = priv->getObject();
- std::size_t first = converter->toSizeT(arguments[0]);
- std::size_t last = currentStrings->size() - 1;
- if (argumentCount > 1) {
- last = converter->toSizeT(arguments[1]);
- if (last >= currentStrings->size()) {
- last = currentStrings->size() - 1;
- }
- }
- for (size_t i = first; i <= last; ++i) {
- strs->push_back(currentStrings->at(i));
- }
-
- return result;
- }
- Catch(WrtDeviceApis::Commons::Exception)
- {
- LogError("error occured");
- }
- return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
-}
-
-JSValueRef JSStringArray::sort(JSContextRef context,
- JSObjectRef function,
- JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception)
-{
- Try
- {
- WrtDeviceApis::CommonsJavaScript::BasicConverter converter =
- WrtDeviceApis::CommonsJavaScript::BasicConverterFactory::getConverter(context);
- JSStringArrayPriv* priv =
- static_cast<JSStringArrayPriv*>(JSObjectGetPrivate(thisObject));
- StringArrayPtr currentStrings = priv->getObject();
- std::sort(currentStrings->begin(), currentStrings->end());
- return thisObject;
- }
- Catch(WrtDeviceApis::Commons::Exception)
- {
- LogError("error occured");
- }
- return JSValueMakeUndefined(context);
-}
-
-JSValueRef JSStringArray::splice(JSContextRef context,
- JSObjectRef function,
- JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception)
-{
- return JSValueMakeUndefined(context);
-}
-
-JSValueRef JSStringArray::toString(JSContextRef context,
- JSObjectRef function,
- JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception)
-{
- return join(context, function, thisObject, 0, arguments, exception);
-}
-
-JSValueRef JSStringArray::unshift(JSContextRef context,
- JSObjectRef function,
- JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception)
-{
- return JSValueMakeUndefined(context);
-}
-
-JSValueRef JSStringArray::valueOf(JSContextRef context,
- JSObjectRef function,
- JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception)
-{
- return JSValueMakeUndefined(context);
-}
-
-} // Calendar
-} // DeviceAPI
+++ /dev/null
-//
-// Tizen Web Device API
-// Copyright (c) 2012 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 _TIZEN_CALENDAR_JS_STRING_ARRAY_H_
-#define _TIZEN_CALENDAR_JS_STRING_ARRAY_H_
-
-#include <vector>
-#include <JavaScriptCore/JavaScript.h>
-#include <CommonsJavaScript/PrivateObject.h>
-#include "CalendarEvent.h"
-
-namespace DeviceAPI {
-namespace Calendar {
-
-typedef WrtDeviceApis::CommonsJavaScript::PrivateObjectT<StringArrayPtr>::Type JSStringArrayPriv;
-
-class JSStringArray
-{
-public:
-
- static const JSClassDefinition* getClassInfo();
-
- static JSClassRef getClassRef();
-
- static JSObjectRef createArray(JSContextRef context,
- const StringArrayPtr &Strings);
-
- static bool isObjectOfClass(JSContextRef context, JSValueRef value);
-
- static StringArrayPtr getStringArray(JSContextRef context, JSValueRef value);
-
-private:
-
- /**
- * The callback invoked when an object is first created.
- */
- static void initialize(JSContextRef context,
- JSObjectRef object);
-
- /**
- * The callback invoked when an object is finalized.
- */
- static void finalize(JSObjectRef object);
-
- static JSValueRef getLength(JSContextRef context,
- JSObjectRef object,
- JSStringRef propertyName,
- JSValueRef* exception);
-
- static bool hasProperty(JSContextRef context,
- JSObjectRef object,
- JSStringRef propertyName);
-
- static JSValueRef getProperty(JSContextRef context,
- JSObjectRef object,
- JSStringRef propertyName,
- JSValueRef* exception);
-
- static bool setProperty(JSContextRef context,
- JSObjectRef object,
- JSStringRef propertyName,
- JSValueRef value,
- JSValueRef* exception);
-
- static void getPropertyNames(JSContextRef context,
- JSObjectRef object,
- JSPropertyNameAccumulatorRef propertyNames);
-
- static JSValueRef concat(JSContextRef context,
- JSObjectRef function,
- JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception);
- static JSValueRef join(JSContextRef context,
- JSObjectRef function,
- JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception);
- static JSValueRef pop(JSContextRef context,
- JSObjectRef function,
- JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception);
- static JSValueRef push(JSContextRef context,
- JSObjectRef function,
- JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception);
- static JSValueRef reverse(JSContextRef context,
- JSObjectRef function,
- JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception);
- static JSValueRef shift(JSContextRef context,
- JSObjectRef function,
- JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception);
- static JSValueRef slice(JSContextRef context,
- JSObjectRef function,
- JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception);
- static JSValueRef sort(JSContextRef context,
- JSObjectRef function,
- JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception);
- static JSValueRef splice(JSContextRef context,
- JSObjectRef function,
- JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception);
- static JSValueRef toString(JSContextRef context,
- JSObjectRef function,
- JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception);
- static JSValueRef unshift(JSContextRef context,
- JSObjectRef function,
- JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception);
- static JSValueRef valueOf(JSContextRef context,
- JSObjectRef function,
- JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception);
-
- static bool checkValue(const std::string &value);
-
- static JSClassRef m_jsClassRef;
- /**
- * This structure describes a statically declared function property.
- */
- static JSStaticFunction m_function[];
-
- /**
- * This structure contains properties and callbacks that define a type of object.
- */
- static JSClassDefinition m_classInfo;
-
- /**
- * This member variable contains the initialization values for the static properties of this class.
- * The values are given according to the data structure JSPropertySpec
- */
- static JSStaticValue m_property[];
-};
-
-} // Calendar
-} // DeviceAPI
-
-#endif // _TIZEN_CALENDAR_JS_STRING_ARRAY_H_
\ No newline at end of file
+++ /dev/null
-//
-// Tizen Web Device API
-// Copyright (c) 2012 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 <algorithm>
-#include <sstream>
-#include <dpl/log/log.h>
-#include <CommonsJavaScript/Converter.h>
-#include <CommonsJavaScript/ScopedJSStringRef.h>
-#include <JSTizenExceptionFactory.h>
-#include <JSTizenException.h>
-#include <CommonsJavaScript/Converter.h>
-#include "JSTZDateArray.h"
-#include <TimeUtilConverter.h>
-
-#define FUNCTION_CONCAT "concat"
-#define FUNCTION_JOIN "join"
-#define FUNCTION_POP "pop"
-#define FUNCTION_PUSH "push"
-#define FUNCTION_REVERSE "reverse"
-#define FUNCTION_SHIFT "shift"
-#define FUNCTION_SLICE "slice"
-#define FUNCTION_SORT "sort"
-#define FUNCTION_SPLICE "splice"
-#define FUNCTION_TOSTRING "toString"
-#define FUNCTION_UNSHIFT "unshift"
-#define FUNCTION_VALUEOF "valueOf"
-#define ARRAY "Array"
-#define ATTRIBUTE_LENGTH "length"
-
-namespace DeviceAPI {
-namespace Calendar {
-
-
-using namespace DeviceAPI::Common;
-using namespace DeviceAPI::Time;
-using namespace WrtDeviceApis::CommonsJavaScript;
-
-JSClassDefinition JSTZDateArray::m_classInfo = {
- 0,
- kJSClassAttributeNone,
- ARRAY,
- 0,
- m_property,
- m_function,
- initialize,
- finalize,
- hasProperty,
- getProperty,
- setProperty,
- NULL, //deleteProperty,
- getPropertyNames,
- NULL, //callAsFunction,
- NULL, //callAsConstructor,
- NULL, //hasInstance,
- NULL, //convertToType,
-};
-
-JSStaticValue JSTZDateArray::m_property[] = {
- { ATTRIBUTE_LENGTH, getLength, NULL, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete },
- { 0, 0, 0, 0 }
-};
-
-JSStaticFunction JSTZDateArray::m_function[] = {
- { FUNCTION_CONCAT, concat, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete },
- { FUNCTION_JOIN, join, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete },
- { FUNCTION_POP, pop, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete },
- { FUNCTION_PUSH, push, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete },
- { FUNCTION_REVERSE, reverse, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete },
- { FUNCTION_SHIFT, shift, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete },
- { FUNCTION_SLICE, slice, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete },
- { FUNCTION_SORT, sort, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete },
- { FUNCTION_SPLICE, splice, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete },
- { FUNCTION_TOSTRING, toString, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete },
- { FUNCTION_UNSHIFT, unshift, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete },
- { FUNCTION_VALUEOF, valueOf, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete },
- { 0, 0, 0 }
-};
-
-JSClassRef JSTZDateArray::m_jsClassRef = JSClassCreate(
- JSTZDateArray::getClassInfo());
-
-JSValueRef JSTZDateArray::getLength(JSContextRef context,
- JSObjectRef object,
- JSStringRef propertyName,
- JSValueRef* exception)
-{
- Try
- {
- JSTZDateArrayPriv* priv =
- static_cast<JSTZDateArrayPriv*>(JSObjectGetPrivate(object));
- if (!priv) {
- Throw(WrtDeviceApis::Commons::NullPointerException);
- }
- NumberArrayPtr numbers = priv->getObject();
- if (numbers) {
- WrtDeviceApis::CommonsJavaScript::BasicConverter converter =
- WrtDeviceApis::CommonsJavaScript::BasicConverterFactory::getConverter(context);
- return converter->toJSValueRef(numbers->size());
- }
- }
- Catch(WrtDeviceApis::Commons::Exception)
- {
- LogError("invalid conversion");
- }
- return JSValueMakeUndefined(context);
-}
-
-JSObjectRef JSTZDateArray::createArray(JSContextRef context,
- const NumberArrayPtr &numbers)
-{
- JSTZDateArrayPriv *priv = new JSTZDateArrayPriv(context, numbers);
- return JSObjectMake(context, getClassRef(), priv);
-}
-
-const JSClassDefinition* JSTZDateArray::getClassInfo()
-{
- return &(m_classInfo);
-}
-
-JSClassRef JSTZDateArray::getClassRef()
-{
- if (!m_jsClassRef) {
- m_jsClassRef = JSClassCreate(&m_classInfo);
- }
- return m_jsClassRef;
-}
-
-bool JSTZDateArray::isObjectOfClass(JSContextRef context, JSValueRef value)
-{
- return JSValueIsObjectOfClass(context, value, getClassRef());
-}
-
-NumberArrayPtr JSTZDateArray::getTZDateArray(JSContextRef context, JSValueRef value)
-{
- if (!isObjectOfClass(context, value)) {
- Throw(WrtDeviceApis::Commons::InvalidArgumentException);
- }
- JSObjectRef object = JSValueToObject(context, value, NULL);
- if (!object) {
- Throw(WrtDeviceApis::Commons::InvalidArgumentException);
- }
- JSTZDateArrayPriv* priv = static_cast<JSTZDateArrayPriv*>(JSObjectGetPrivate(object));
- if (!priv) {
- Throw(WrtDeviceApis::Commons::NullPointerException);
- }
- return priv->getObject();
-}
-
-void JSTZDateArray::initialize(JSContextRef context,
- JSObjectRef object)
-{
-}
-
-void JSTZDateArray::finalize(JSObjectRef object)
-{
- JSTZDateArrayPriv* priv =
- static_cast<JSTZDateArrayPriv*>(JSObjectGetPrivate(object));
- delete priv;
- JSObjectSetPrivate(object, NULL);
-}
-
-bool JSTZDateArray::hasProperty(JSContextRef context,
- JSObjectRef object,
- JSStringRef propertyName)
-{
- WrtDeviceApis::CommonsJavaScript::BasicConverter converter =
- WrtDeviceApis::CommonsJavaScript::BasicConverterFactory::getConverter(context);
- Try
- {
- size_t index = converter->toSizeT(propertyName);
- JSTZDateArrayPriv* priv =
- static_cast<JSTZDateArrayPriv*>(JSObjectGetPrivate(object));
- if (!priv) {
- Throw(WrtDeviceApis::Commons::NullPointerException);
- }
- NumberArrayPtr numbers = priv->getObject();
- if (index < numbers->size()) {
- return true;
- }
- }
- Catch(WrtDeviceApis::Commons::Exception)
- {
- //not reporting error is intended
- }
- return false;
-}
-
-JSValueRef JSTZDateArray::getProperty(JSContextRef context,
- JSObjectRef object,
- JSStringRef propertyName,
- JSValueRef* exception)
-{
- WrtDeviceApis::CommonsJavaScript::BasicConverter converter =
- WrtDeviceApis::CommonsJavaScript::BasicConverterFactory::getConverter(context);
- TimeUtilConverter timeConverter(context);
-
- Try
- {
- size_t index = converter->toSizeT(propertyName);
- JSTZDateArrayPriv* priv =
- static_cast<JSTZDateArrayPriv*>(JSObjectGetPrivate(object));
- if (!priv) {
- Throw(WrtDeviceApis::Commons::NullPointerException);
- }
- NumberArrayPtr numbers = priv->getObject();
- if (index < numbers->size()) {
- long long int result = numbers->at(index);
- LogInfo("index: "<<index<<", result: "<<result);
- return timeConverter.toJSValueRefTZDate((double)(result*1000.0), "");
- }
- }
- Catch(WrtDeviceApis::Commons::Exception)
- {
- LogError("invalid property");
- }
- return JSValueMakeUndefined(context);
-}
-
-bool JSTZDateArray::setProperty(JSContextRef context,
- JSObjectRef object,
- JSStringRef propertyName,
- JSValueRef value,
- JSValueRef* exception)
-{
- WrtDeviceApis::CommonsJavaScript::BasicConverter converter =
- WrtDeviceApis::CommonsJavaScript::BasicConverterFactory::getConverter(context);
- TimeUtilConverter timeConverter(context);
-
- Try
- {
- size_t index = converter->toSizeT(propertyName);
- long long int number = 0;
- if (!JSValueIsUndefined(context, value)) {
- number = timeConverter.getTimeInMilliseconds(value)/1000;
- }
- JSTZDateArrayPriv* priv =
- static_cast<JSTZDateArrayPriv*>(JSObjectGetPrivate(object));
- if (!priv) {
- Throw(WrtDeviceApis::Commons::NullPointerException);
- }
- NumberArrayPtr numbers = priv->getObject();
- if (!numbers) {
- Throw(WrtDeviceApis::Commons::NullPointerException);
- }
- if (numbers->size() <= index) {
- numbers->resize(index + 1);
- }
- (*numbers)[index] = number;
- return true;
- }
- Catch(WrtDeviceApis::Commons::Exception)
- {
- LogError("error occured");
- JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
- }
- return false;
-}
-
-void JSTZDateArray::getPropertyNames(JSContextRef context,
- JSObjectRef object,
- JSPropertyNameAccumulatorRef propertyNames)
-{
- Converter converter(context);
-
- Try
- {
- JSTZDateArrayPriv* priv =
- static_cast<JSTZDateArrayPriv*>(JSObjectGetPrivate(object));
- if (!priv) {
- Throw(WrtDeviceApis::Commons::NullPointerException);
- }
- NumberArrayPtr numbers = priv->getObject();
-
- int count = numbers->size();
-
- for(int i=0; i < count; i++)
- {
- ScopedJSStringRef name(converter.toJSStringRef(converter.toString(i)));
- JSPropertyNameAccumulatorAddName(propertyNames, name.get());
- }
- }
- Catch(WrtDeviceApis::Commons::Exception)
- {
- LogError("invalid property");
- }
-}
-
-JSValueRef JSTZDateArray::concat(JSContextRef context,
- JSObjectRef function,
- JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception)
-{
- Try
- {
- NumberArrayPtr numbers = NumberArrayPtr(new NumberArray());
- JSTZDateArrayPriv *newPrivateObject = new JSTZDateArrayPriv(
- context,
- numbers);
- JSValueRef result = JSObjectMake(context, getClassRef(), newPrivateObject);
-
- //copy current numbers
- JSTZDateArrayPriv* priv =
- static_cast<JSTZDateArrayPriv*>(JSObjectGetPrivate(thisObject));
- NumberArrayPtr currentNumbers = priv->getObject();
- for (size_t i = 0; i < currentNumbers->size(); ++i) {
- numbers->push_back(currentNumbers->at(i));
- }
-
- //copy submitted arrays
- WrtDeviceApis::CommonsJavaScript::BasicConverter converter =
- WrtDeviceApis::CommonsJavaScript::BasicConverterFactory::getConverter(context);
- TimeUtilConverter timeConverter(context);
- for (size_t i = 0; i < argumentCount; ++i) {
- if (!JSIsArrayValue(context, arguments[i])) {
- Throw(WrtDeviceApis::Commons::ConversionException);
- }
- // process array of numbers
- JSObjectRef arrayObj = converter->toJSObjectRef(arguments[i]);
- unsigned int len = JSGetArrayLength(context, arrayObj);
- for (unsigned int e = 0; e < len; ++e) {
- JSValueRef att = JSGetArrayElement(context, arrayObj, e);
-
- long long int number = 0;
- if (!JSValueIsUndefined(context, att)) {
- number = timeConverter.getTimeInMilliseconds(att)/1000;
- }
- LogDebug("Concatenating a number: "<<number);
- numbers->push_back(number);
- }
- }
- return result;
- }
- Catch(WrtDeviceApis::Commons::Exception)
- {
- LogError("error occured");
- }
- return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
-}
-
-JSValueRef JSTZDateArray::join(JSContextRef context,
- JSObjectRef function,
- JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception)
-{
- Try
- {
- std::string result;
- std::string separator(",");
- WrtDeviceApis::CommonsJavaScript::BasicConverter converter =
- WrtDeviceApis::CommonsJavaScript::BasicConverterFactory::getConverter(context);
- JSTZDateArrayPriv* priv = static_cast<JSTZDateArrayPriv*>(JSObjectGetPrivate(thisObject));
- TimeUtilConverter timeConverter(context);
-
- NumberArrayPtr currentNumbers = priv->getObject();
- if (argumentCount > 0 && JSValueIsString(context, arguments[0])) {
- separator = converter->toString(arguments[0]);
- LogDebug("Separator: "<<separator);
- }
- for (size_t i = 0; i < currentNumbers->size(); ++i) {
- if (i != 0) {
- result += separator;
- }
- std::stringstream ss;
- ss<<currentNumbers->at(i);
- result += ss.str();
- }
- LogDebug("Resulting string: "<<result);
- return converter->toJSValueRef(result);
- }
- Catch(WrtDeviceApis::Commons::Exception)
- {
- LogError("error occured");
- }
- return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
-}
-
-JSValueRef JSTZDateArray::pop(JSContextRef context,
- JSObjectRef function,
- JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception)
-{
- Try
- {
- TimeUtilConverter timeConverter(context);
-
- JSTZDateArrayPriv* priv = static_cast<JSTZDateArrayPriv*>(JSObjectGetPrivate(thisObject));
- NumberArrayPtr currentNumbers = priv->getObject();
- if (currentNumbers->size() > 0) {
- long long int result = currentNumbers->at(currentNumbers->size() - 1);
- currentNumbers->pop_back();
- return timeConverter.toJSValueRefTZDate((double)(result*1000.0), "");
- }
- }
- Catch(WrtDeviceApis::Commons::Exception)
- {
- LogError("error occured");
- }
- return JSValueMakeUndefined(context);
-}
-
-JSValueRef JSTZDateArray::push(JSContextRef context,
- JSObjectRef function,
- JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception)
-{
- Try
- {
- TimeUtilConverter timeConverter(context);
-
- JSTZDateArrayPriv* priv = static_cast<JSTZDateArrayPriv*>(JSObjectGetPrivate(thisObject));
- NumberArrayPtr currentNumbers = priv->getObject();
- for (size_t i = 0; i < argumentCount; ++i) {
- long long int number = 0;
- if (!JSValueIsUndefined(context, arguments[i])) {
- number = timeConverter.getTimeInMilliseconds(arguments[i])/1000;
- }
- LogDebug("Pushing a TZDate number: "<<number<<" for index: "<<i);
- currentNumbers->push_back(number);
- }
- return timeConverter.toJSValueRef(currentNumbers->size());
- }
- Catch(WrtDeviceApis::Commons::Exception)
- {
- LogError("error occured");
- }
- return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
-}
-
-JSValueRef JSTZDateArray::reverse(JSContextRef context,
- JSObjectRef function,
- JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception)
-{
- Try
- {
- WrtDeviceApis::CommonsJavaScript::BasicConverter converter =
- WrtDeviceApis::CommonsJavaScript::BasicConverterFactory::getConverter(context);
- JSTZDateArrayPriv* priv =
- static_cast<JSTZDateArrayPriv*>(JSObjectGetPrivate(thisObject));
- NumberArrayPtr currentNumbers = priv->getObject();
- std::reverse(currentNumbers->begin(), currentNumbers->end());
- return thisObject;
- }
- Catch(WrtDeviceApis::Commons::Exception)
- {
- LogError("error occured");
- }
- return JSValueMakeUndefined(context);
-}
-
-JSValueRef JSTZDateArray::shift(JSContextRef context,
- JSObjectRef function,
- JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception)
-{
- Try
- {
- WrtDeviceApis::CommonsJavaScript::BasicConverter converter =
- WrtDeviceApis::CommonsJavaScript::BasicConverterFactory::getConverter(context);
- JSTZDateArrayPriv* priv =
- static_cast<JSTZDateArrayPriv*>(JSObjectGetPrivate(thisObject));
- NumberArrayPtr currentNumbers = priv->getObject();
- if (currentNumbers->size() > 0) {
- long long int result = currentNumbers->at(0);
- currentNumbers->erase(currentNumbers->begin());
- return converter->toJSValueRef(result);
- }
- }
- Catch(WrtDeviceApis::Commons::Exception)
- {
- LogError("error occured");
- }
- return JSValueMakeUndefined(context);
-}
-
-JSValueRef JSTZDateArray::slice(JSContextRef context,
- JSObjectRef function,
- JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception)
-{
- Try
- {
- if (argumentCount < 1) {
- return JSValueMakeUndefined(context);
- }
- WrtDeviceApis::CommonsJavaScript::BasicConverter converter =
- WrtDeviceApis::CommonsJavaScript::BasicConverterFactory::getConverter(context);
- NumberArrayPtr numbers = NumberArrayPtr(new NumberArray());
- JSTZDateArrayPriv *newPrivateObject = new JSTZDateArrayPriv(context, numbers);
- JSValueRef result = JSObjectMake(context, getClassRef(), newPrivateObject);
-
- //copy current numbers
- JSTZDateArrayPriv* priv = static_cast<JSTZDateArrayPriv*>(JSObjectGetPrivate(thisObject));
- NumberArrayPtr currentNumbers = priv->getObject();
- std::size_t first = converter->toSizeT(arguments[0]);
- std::size_t last = currentNumbers->size() - 1;
- if (argumentCount > 1) {
- last = converter->toSizeT(arguments[1]);
- if (last >= currentNumbers->size()) {
- last = currentNumbers->size() - 1;
- }
- }
-
- for (size_t i = first; i <= last; ++i) {
- numbers->push_back(currentNumbers->at(i));
- }
-
- return result;
- }
- Catch(WrtDeviceApis::Commons::Exception)
- {
- LogError("error occured");
- }
- return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
-}
-
-JSValueRef JSTZDateArray::sort(JSContextRef context,
- JSObjectRef function,
- JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception)
-{
- Try
- {
- WrtDeviceApis::CommonsJavaScript::BasicConverter converter =
- WrtDeviceApis::CommonsJavaScript::BasicConverterFactory::getConverter(context);
- JSTZDateArrayPriv* priv =
- static_cast<JSTZDateArrayPriv*>(JSObjectGetPrivate(thisObject));
- NumberArrayPtr currentNumbers = priv->getObject();
- std::sort(currentNumbers->begin(), currentNumbers->end());
- return thisObject;
- }
- Catch(WrtDeviceApis::Commons::Exception)
- {
- LogError("error occured");
- }
- return JSValueMakeUndefined(context);
-}
-
-JSValueRef JSTZDateArray::splice(JSContextRef context,
- JSObjectRef function,
- JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception)
-{
- return JSValueMakeUndefined(context);
-}
-
-JSValueRef JSTZDateArray::toString(JSContextRef context,
- JSObjectRef function,
- JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception)
-{
- return join(context, function, thisObject, 0, arguments, exception);
-}
-
-JSValueRef JSTZDateArray::unshift(JSContextRef context,
- JSObjectRef function,
- JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception)
-{
- return JSValueMakeUndefined(context);
-}
-
-JSValueRef JSTZDateArray::valueOf(JSContextRef context,
- JSObjectRef function,
- JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception)
-{
- return JSValueMakeUndefined(context);
-}
-
-} // Calendar
-} // DeviceAPI
+++ /dev/null
-//
-// Tizen Web Device API
-// Copyright (c) 2012 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 _TIZEN_CALENDAR_JS_TZDATE_ARRAY_H_
-#define _TIZEN_CALENDAR_JS_TZDATE_ARRAY_H_
-
-#include <vector>
-#include <JavaScriptCore/JavaScript.h>
-#include <CommonsJavaScript/PrivateObject.h>
-#include "CalendarEvent.h"
-
-namespace DeviceAPI {
-namespace Calendar {
-
-typedef WrtDeviceApis::CommonsJavaScript::PrivateObjectT<NumberArrayPtr>::Type JSTZDateArrayPriv;
-
-class JSTZDateArray
-{
-public:
-
- static const JSClassDefinition* getClassInfo();
-
- static JSClassRef getClassRef();
-
- static JSObjectRef createArray(JSContextRef context,
- const NumberArrayPtr &Numbers);
-
- static bool isObjectOfClass(JSContextRef context, JSValueRef value);
-
- static NumberArrayPtr getTZDateArray(JSContextRef context, JSValueRef value);
-
-private:
-
- /**
- * The callback invoked when an object is first created.
- */
- static void initialize(JSContextRef context,
- JSObjectRef object);
-
- /**
- * The callback invoked when an object is finalized.
- */
- static void finalize(JSObjectRef object);
-
- static JSValueRef getLength(JSContextRef context,
- JSObjectRef object,
- JSStringRef propertyName,
- JSValueRef* exception);
-
- static bool hasProperty(JSContextRef context,
- JSObjectRef object,
- JSStringRef propertyName);
-
- static JSValueRef getProperty(JSContextRef context,
- JSObjectRef object,
- JSStringRef propertyName,
- JSValueRef* exception);
-
- static bool setProperty(JSContextRef context,
- JSObjectRef object,
- JSStringRef propertyName,
- JSValueRef value,
- JSValueRef* exception);
-
- static void getPropertyNames(JSContextRef context,
- JSObjectRef object,
- JSPropertyNameAccumulatorRef propertyNames);
-
- static JSValueRef concat(JSContextRef context,
- JSObjectRef function,
- JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception);
- static JSValueRef join(JSContextRef context,
- JSObjectRef function,
- JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception);
-
- static JSValueRef pop(JSContextRef context,
- JSObjectRef function,
- JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception);
- static JSValueRef push(JSContextRef context,
- JSObjectRef function,
- JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception);
- static JSValueRef reverse(JSContextRef context,
- JSObjectRef function,
- JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception);
- static JSValueRef shift(JSContextRef context,
- JSObjectRef function,
- JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception);
- static JSValueRef slice(JSContextRef context,
- JSObjectRef function,
- JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception);
- static JSValueRef sort(JSContextRef context,
- JSObjectRef function,
- JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception);
- static JSValueRef splice(JSContextRef context,
- JSObjectRef function,
- JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception);
- static JSValueRef toString(JSContextRef context,
- JSObjectRef function,
- JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception);
- static JSValueRef unshift(JSContextRef context,
- JSObjectRef function,
- JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception);
- static JSValueRef valueOf(JSContextRef context,
- JSObjectRef function,
- JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception);
-
- static bool checkValue(const long long int &value);
-
- static JSClassRef m_jsClassRef;
- /**
- * This structure describes a statically declared function property.
- */
- static JSStaticFunction m_function[];
-
- /**
- * This structure contains properties and callbacks that define a type of object.
- */
- static JSClassDefinition m_classInfo;
-
- /**
- * This member variable contains the initialization values for the static properties of this class.
- * The values are given according to the data structure JSPropertySpec
- */
- static JSStaticValue m_property[];
-};
-
-} // Calendar
-} // DeviceAPI
-
-#endif // _TIZEN_CALENDAR_JS_TZDATE_ARRAY_H_
\ No newline at end of file
#include "CalendarAsyncCallbackManager.h"
#include "CalendarListenerManager.h"
+#include <GlobalContextManager.h>
+
namespace DeviceAPI {
namespace Calendar {
void on_frame_load_callback(const void * context)
{
LogDebug("[Tizen\\Calendar] on_frame_load_callback (" << context << ")");
+ DeviceAPI::Common::GlobalContextManager::getInstance()->addGlobalContext(static_cast<JSContextRef>(context));
}
void on_frame_unload_callback(const void * context)
CalendarAsyncCallbackManagerSingleton::Instance().unregisterContext(static_cast<JSContextRef>(context));
CalendarListenerManagerSingleton::Instance().unregisterContext(static_cast<JSContextRef>(context));
+ DeviceAPI::Common::GlobalContextManager::getInstance()->removeGlobalContext(static_cast<JSContextRef>(context));
}
PLUGIN_ON_WIDGET_START(on_widget_start_callback)
#include <Commons/Exception.h>
#include <CommonsJavaScript/JSCallbackManager.h>
#include <dpl/shared_ptr.h>
-#include <dpl/log/log.h>
+#include <Logger.h>
+
#include <IFilter.h>
#include <IFilterVisitor.h>
#include "CallHistoryDefine.h"
if (m_watchers.size() > 0) {
for (;it < CallHistory::m_watchers.end();) {
- ret = contacts_db_remove_changed_cb(_contacts_phone_log._uri, callhistoryListenerCB, it->Get());
+ //ret = contacts_db_remove_changed_cb(_contacts_phone_log._uri, callhistoryListenerCB, it->Get());
+ ret = contacts_db_remove_changed_cb_with_info(_contacts_phone_log._uri, callhistoryListenerCB, it->Get());
if (ret != CONTACTS_ERROR_NONE) {
LogDebug("callhistory remove listener error [" << ret << "]");
EventRequestReceiver<EventCallHistory>::PostRequest(event);
}
-void CallHistory::callhistoryListenerCB(const char* view_uri, void* user_data)
+void CallHistory::callhistoryListenerCB(const char* view_uri, char *changes, void* user_data)
{
- LogDebug("enter");
+
if (user_data != NULL) {
- ((CallHistory::Watcher*)user_data)->addedListenerCB();
- ((CallHistory::Watcher*)user_data)->changedListenerCB();
+ ((CallHistory::Watcher*)user_data)->ListenerCB(changes);
}
}
if (CallHistory::m_watchers.size() == 0) {
WatcherPtr watcher(new Watcher(0, emitter));
- ret = contacts_db_add_changed_cb(_contacts_phone_log._uri, callhistoryListenerCB, watcher.Get());
-
- if (ret == CONTACTS_ERROR_NONE) {
- CallHistoryEntryListPtr callHistoryListPtr(new CallHistoryEntryList());
-
- contacts_query_h query = NULL;
- contacts_filter_h filter = NULL;
- contacts_list_h recordList = NULL;
-
- contacts_query_create(_contacts_phone_log._uri, &query);
- contacts_filter_create(_contacts_phone_log._uri, &filter);
- contacts_filter_add_int(filter, _contacts_phone_log.log_type, CONTACTS_MATCH_LESS_THAN_OR_EQUAL, CONTACTS_PLOG_TYPE_VIDEO_BLOCKED);
-
- contacts_query_set_filter(query, filter);
- contacts_query_set_sort(query, _contacts_phone_log.id, false);
- ret = contacts_db_get_records_with_query(query, 0, 1, &recordList);
-
- if (ret != CONTACTS_ERROR_NONE) {
- LogDebug("callhistory query error [" << ret << "]");
- }
-
- if (parseRecord(&recordList, callHistoryListPtr)) {
- if (callHistoryListPtr->size() > 0) {
- watcher->setCurrentLogId((*callHistoryListPtr)[0]->getEntryId());
- }
- }
- contacts_list_destroy(recordList, true);
- contacts_query_destroy(query);
- contacts_filter_destroy(filter);
-
- MissedCallListPtr missedCallList(updateCurrentMissedCall());
- watcher->setMissedCallList(missedCallList);
- }
+ ret = contacts_db_add_changed_cb_with_info(_contacts_phone_log._uri, callhistoryListenerCB, watcher.Get());
watcher->setHandle(static_cast<long>(emitter->getId()));
CallHistory::m_watchers.push_back(watcher);
if (id == (*it)->getHandle()) {
flag = true;
- ret = contacts_db_remove_changed_cb(_contacts_phone_log._uri, callhistoryListenerCB, it->Get());
+ ret = contacts_db_remove_changed_cb_with_info(_contacts_phone_log._uri, callhistoryListenerCB, it->Get());
if (ret != CONTACTS_ERROR_NONE) {
LogDebug("callhistory remove listener error [" << ret << "]");
continue;
}
++it;
-
}
- LogDebug("CallHistory Watcher is removed. (" << CallHistory::m_watchers.size() << ")");
if (!flag) {
ThrowMsg(Commons::InvalidArgumentException, "Invalid values error : handle");
contacts_list_get_count(*recordList, &total);
- LogDebug("total [" << total << "]");
-
for (int i = 0; i < total; i++) {
ret = contacts_list_get_current_record_p(*recordList, &record);
}
}
-MissedCallListPtr CallHistory::updateCurrentMissedCall()
-{
- CallHistoryEntryListPtr callHistoryListPtr(new CallHistoryEntryList());
- MissedCallListPtr missedCallList(new MissedCallList());
- int ret = CONTACTS_ERROR_NONE;
-
- contacts_query_h query = NULL;
- contacts_filter_h filter = NULL;
- contacts_list_h recordList = NULL;
-
- contacts_query_create(_contacts_phone_log._uri, &query);
- contacts_filter_create(_contacts_phone_log._uri, &filter);
- contacts_filter_add_int(filter, _contacts_phone_log.log_type, CONTACTS_MATCH_EQUAL, CONTACTS_PLOG_TYPE_VOICE_INCOMMING_UNSEEN);
- contacts_filter_add_operator(filter, CONTACTS_FILTER_OPERATOR_OR);
- contacts_filter_add_int(filter, _contacts_phone_log.log_type, CONTACTS_MATCH_EQUAL, CONTACTS_PLOG_TYPE_VIDEO_INCOMMING_UNSEEN);
-
- contacts_query_set_filter(query, filter);
- contacts_query_set_sort(query, _contacts_phone_log.log_time, false);
- ret = contacts_db_get_records_with_query(query, 0, 0, &recordList);
-
- if (ret != CONTACTS_ERROR_NONE) {
- LogDebug("callhistory query error [" << ret << "]");
- }
-
- if (parseRecord(&recordList, callHistoryListPtr)) {
- LogDebug("result counter [" << callHistoryListPtr->size() << "]");
- CallHistoryEntryList::iterator it = callHistoryListPtr->begin();
-
- for (;it != callHistoryListPtr->end(); ++it) {
- missedCallList->push_back((*it)->getEntryId());
- }
- LogDebug("missed Call size (" << missedCallList->size() << ")");
- }
-
- contacts_list_destroy(recordList, true);
- contacts_query_destroy(query);
- contacts_filter_destroy(filter);
-
- return missedCallList;
-}
-
void CallHistory::OnRequestReceived(const EventCallHistoryPtr& event)
{
try {
if (entryList == NULL)
return;
+ LogDebug("enter");
+
EventCallHistoryListenerPtr event(new EventCallHistoryListener());
event->setResultState(state);
event->setResult(entryList);
m_emitter->emit(event);
}
-bool CallHistory::Watcher::parseRecord(contacts_list_h *recordList, CallHistoryEntryListPtr &entryList)
+void CallHistory::Watcher::stateHasRemoved(StringArrayPtr &entryList, EventCallHistoryListener::ResultStates state)
{
- CallHistory* callHistory = (CallHistory *) this;
- if (callHistory != NULL) {
- return callHistory->parseRecord(recordList, entryList);
- }
- return false;
-}
+ if (entryList == NULL)
+ return;
-bool CallHistory::Watcher::addMissedCall(CallHistoryEntryListPtr &entryList)
-{
- if (entryList != NULL) {
- CallHistoryEntryList::iterator it = entryList->begin();
- for (; it != entryList->end(); it++) {
- if ((*it)->getDirection().compare(STR_MISSED_NEW) == 0) {
- m_missedCallList->push_back((*it)->getEntryId());
- }
- }
- return true;
- }
- return false;
+ LogDebug("enter");
+
+ EventCallHistoryListenerPtr event(new EventCallHistoryListener());
+ event->setResultState(state);
+ event->setRemoveResult(entryList);
+ m_emitter->emit(event);
}
-bool CallHistory::Watcher::updateCurrentMissedCall()
+
+bool CallHistory::Watcher::parseRecord(contacts_list_h *recordList, CallHistoryEntryListPtr &entryList)
{
CallHistory* callHistory = (CallHistory *) this;
if (callHistory != NULL) {
- setMissedCallList(callHistory->updateCurrentMissedCall());
- return true;
+ return callHistory->parseRecord(recordList, entryList);
}
return false;
}
-void CallHistory::Watcher::addedListenerCB()
+bool CallHistory::Watcher::parseRemoveRecord(char* record, StringArrayPtr &removeRecords)
{
- CallHistoryEntryListPtr callHistoryListPtr(new CallHistoryEntryList());
- int ret = CONTACTS_ERROR_NONE;
-
- contacts_query_h query = NULL;
- contacts_filter_h filter = NULL;
- contacts_list_h recordList = NULL;
+ std::string recordStr(record);
+ removeRecords->push_back(recordStr);
- contacts_query_create(_contacts_phone_log._uri, &query);
- contacts_filter_create(_contacts_phone_log._uri, &filter);
- contacts_filter_add_int(filter, _contacts_phone_log.log_type, CONTACTS_MATCH_LESS_THAN_OR_EQUAL, CONTACTS_PLOG_TYPE_VIDEO_BLOCKED);
- contacts_filter_add_operator(filter, CONTACTS_FILTER_OPERATOR_AND);
- contacts_filter_add_int(filter, _contacts_phone_log.id, CONTACTS_MATCH_GREATER_THAN, static_cast<int>(getCurrentLogId()));
+ return true;
+}
- contacts_query_set_filter(query, filter);
- contacts_query_set_sort(query, _contacts_phone_log.id, false);
- ret = contacts_db_get_records_with_query(query, 0, 0, &recordList);
+void CallHistory::Watcher::ListenerCB(char* changes)
+{
+ LogDebug("enter");
- if (ret != CONTACTS_ERROR_NONE) {
- LogDebug("callhistory query error [" << ret << "]");
- }
+ char seps[] = ",:";
+ char* tokenType = NULL;
+ char* tokenId = NULL;
+ int changeType = 0;
+ int changeId = 0;
- if (parseRecord(&recordList, callHistoryListPtr)) {
- if (callHistoryListPtr->size() > 0) {
- setCurrentLogId((*callHistoryListPtr)[0]->getEntryId());
- stateHasChanged(callHistoryListPtr, EventCallHistoryListener::ADDED);
- addMissedCall(callHistoryListPtr);
- }
- }
+ CallHistoryEntryListPtr callHistoryListPtr(new CallHistoryEntryList());
+ StringArrayPtr RemoveListPtr(new StringArray());
- contacts_list_destroy(recordList, true);
- contacts_query_destroy(query);
- contacts_filter_destroy(filter);
-}
+ tokenType = strtok( changes, seps );
+ while( tokenType != NULL )
+ {
+ tokenId = strtok( NULL, seps );
+ LogDebug("[ %s / %s ]", tokenType , tokenId );
+ changeType = atoi((const char*)tokenType);
+ changeId = atoi((const char*)tokenId);
-void CallHistory::Watcher::changedListenerCB()
-{
- MissedCallListPtr missedCallListPtr(getMissedCallList());
- CallHistoryEntryListPtr callHistoryListPtr(new CallHistoryEntryList());
- int ret = CONTACTS_ERROR_NONE;
- contacts_query_h query = NULL;
- contacts_filter_h filter = NULL;
- contacts_list_h recordList = NULL;
+ contacts_query_h query = NULL;
+ contacts_filter_h filter = NULL;
+ contacts_list_h recordList = NULL;
+ int ret = 0;
- if (missedCallListPtr->size() > 0) {
contacts_query_create(_contacts_phone_log._uri, &query);
contacts_filter_create(_contacts_phone_log._uri, &filter);
- contacts_filter_add_int(filter, _contacts_phone_log.log_type, CONTACTS_MATCH_LESS_THAN_OR_EQUAL, CONTACTS_PLOG_TYPE_VIDEO_BLOCKED);
- contacts_filter_add_operator(filter, CONTACTS_FILTER_OPERATOR_AND);
-
- MissedCallList::iterator itM = missedCallListPtr->begin();
-
- do {
- if (itM != missedCallListPtr->begin()) {
- contacts_filter_add_operator(filter, CONTACTS_FILTER_OPERATOR_OR);
- }
- contacts_filter_add_int(filter, _contacts_phone_log.id, CONTACTS_MATCH_EQUAL, static_cast<int>(*itM));
- itM++;
- } while(itM < missedCallListPtr->end());
+ contacts_filter_add_int(filter, _contacts_phone_log.id, CONTACTS_MATCH_EQUAL, changeId );
contacts_query_set_filter(query, filter);
contacts_query_set_sort(query, _contacts_phone_log.id, false);
- ret = contacts_db_get_records_with_query(query, 0, 0, &recordList);
+ ret = contacts_db_get_records_with_query(query, 0, 1, &recordList);
if (ret != CONTACTS_ERROR_NONE) {
LogDebug("callhistory query error [" << ret << "]");
+ return;
}
- if (parseRecord(&recordList, callHistoryListPtr)) {
- CallHistoryEntryList::iterator itC = callHistoryListPtr->begin();
-
- for (;itC != callHistoryListPtr->end();) {
- if ((*itC)->getDirection().compare(STR_MISSED) != 0) {
- itC = callHistoryListPtr->erase(itC);
- continue;
+ if((changeType == CONTACTS_CHANGE_INSERTED)||(changeType == CONTACTS_CHANGE_UPDATED)){
+ if (parseRecord(&recordList, callHistoryListPtr)) {
+ if (callHistoryListPtr->size() > 0) {
+ setCurrentLogId((*callHistoryListPtr)[0]->getEntryId());
}
- ++itC;
- }
-
- if (callHistoryListPtr->size() > 0) {
- updateCurrentMissedCall();
- stateHasChanged(callHistoryListPtr, EventCallHistoryListener::CHANGED);
}
+ }else if(changeType == CONTACTS_CHANGE_DELETED){
+ parseRemoveRecord(tokenId, RemoveListPtr);
}
contacts_list_destroy(recordList, true);
contacts_query_destroy(query);
contacts_filter_destroy(filter);
+
+ tokenType = strtok( NULL, seps );
+ }
+
+
+ if((changeType == CONTACTS_CHANGE_INSERTED)||(changeType == CONTACTS_CHANGE_UPDATED)){
+ if (callHistoryListPtr->size() > 0) {
+ setCurrentLogId((*callHistoryListPtr)[0]->getEntryId());
+
+ if(changeType == CONTACTS_CHANGE_INSERTED){
+ stateHasChanged(callHistoryListPtr, EventCallHistoryListener::ADDED);
+ }else if(changeType == CONTACTS_CHANGE_UPDATED){
+ stateHasChanged(callHistoryListPtr, EventCallHistoryListener::CHANGED);
+ }
+
+ }
+ }else if(changeType == CONTACTS_CHANGE_DELETED){
+ stateHasRemoved(RemoveListPtr, EventCallHistoryListener::REMOVED);
}
}
CallHistory();
~CallHistory();
- static void callhistoryListenerCB(const char* view_uri, void* user_data);
+ static void callhistoryListenerCB(const char* view_uri, char *changes, void* user_data);
static void removeBatchCB(int error, void *user_data);
static void removeAllCB(int error, void *user_data);
-
void find(const EventFindCallHistoryPtr& event);
bool remove(const unsigned long entryId);
void removeBatch(const EventRemoveBatchPtr& event);
void setHandle(long handle)
{
- LogDebug("setHandle : handle ["<<handle<<"]");
m_handle = handle;
}
long getHandle()
{
- LogDebug("getHandle : handle ["<<m_handle<<"]");
return m_handle;
}
void setCurrentLogId(unsigned int logId)
{
m_currentLogId = logId;
- LogDebug("setCurrentLogId : logId ["<<logId);
-
}
unsigned int getCurrentLogId()
return m_currentLogId;
}
- void setMissedCallList(const MissedCallListPtr &missedCallList)
- {
- m_missedCallList = missedCallList;
- }
-
- MissedCallListPtr getMissedCallList()
- {
- return m_missedCallList;
- }
-
EventCallHistoryListenerEmitterPtr getEmitter()
{
return m_emitter;
}
void stateHasChanged(CallHistoryEntryListPtr &entryList, EventCallHistoryListener::ResultStates state);
+ void stateHasRemoved(StringArrayPtr &entryList, EventCallHistoryListener::ResultStates state);
+
bool parseRecord(contacts_list_h *recordList, CallHistoryEntryListPtr &entryList);
- bool addMissedCall(CallHistoryEntryListPtr &entryList);
- bool updateCurrentMissedCall();
- void addedListenerCB();
- void changedListenerCB();
+ bool parseRemoveRecord(char* record, StringArrayPtr &removeRecords);
+
+ void ListenerCB(char* changes);
};
typedef DPL::SharedPtr<Watcher> WatcherPtr;
bool convertCallHistory(callhistory_query_s *query_log, CallHistoryEntryListPtr &callEntries);
bool parseRecord(contacts_list_h *recordList, CallHistoryEntryListPtr &callEntries);
unsigned int convertAttrName(std::string &name);
- MissedCallListPtr updateCurrentMissedCall();
std::vector<EventRemoveBatchDataPtr> m_removeBatchEvent;
std::vector<EventRemoveAllDataPtr> m_removeAllEvent;
namespace CallHistory {
EventCallHistoryListenerPrivateData::EventCallHistoryListenerPrivateData(
- const JSCallbackManagerPtr& onAdded, const JSCallbackManagerPtr& onChanged) :
- m_onAdded(onAdded), m_onChanged(onChanged)
+ const JSCallbackManagerPtr& onAdded, const JSCallbackManagerPtr& onChanged, const JSCallbackManagerPtr& onRemoved) :
+ m_onAdded(onAdded), m_onChanged(onChanged), m_onRemoved(onRemoved)
{
}
return m_onChanged;
}
+JSCallbackManagerPtr EventCallHistoryListenerPrivateData::getOnRemoved() const
+{
+ return m_onRemoved;
+}
+
+
}
}
{
JSValueRef onAdded;
JSValueRef onChanged;
+ JSValueRef onRemoved;
CallHistoryChangeCB() :
onAdded(NULL),
- onChanged(NULL)
+ onChanged(NULL),
+ onRemoved(NULL)
{ }
};
{
public:
EventCallHistoryListenerPrivateData(const JSCallbackManagerPtr& onAdded,
- const JSCallbackManagerPtr& onChanged);
+ const JSCallbackManagerPtr& onChanged, const JSCallbackManagerPtr& onRemoved);
JSCallbackManagerPtr getOnAdded() const;
JSCallbackManagerPtr getOnChanged() const;
+ JSCallbackManagerPtr getOnRemoved() const;
private:
JSCallbackManagerPtr m_onAdded;
JSCallbackManagerPtr m_onChanged;
+ JSCallbackManagerPtr m_onRemoved;
};
typedef DPL::SharedPtr<EventCallHistoryListenerPrivateData> EventCallHistoryListenerPrivateDataPtr;
JSContextRef context = defaultCbm->getContext();
Converter converter(context);
- try {
- JSValueRef result = converter.toJSValueRef(event->getResult(), context);
-
+ try {
switch (event->getResultState()) {
case EventCallHistoryListener::ADDED :
- multiCallbacks->getOnAdded()->callOnSuccess(result);
- break;
+ {
+ JSValueRef result = converter.toJSValueRef(event->getResult(), context);
+ multiCallbacks->getOnAdded()->callOnSuccess(result);
+ break;
+ }
case EventCallHistoryListener::CHANGED :
- multiCallbacks->getOnChanged()->callOnSuccess(result);
- break;
+ {
+ JSValueRef result = converter.toJSValueRef(event->getResult(), context);
+ multiCallbacks->getOnChanged()->callOnSuccess(result);
+ break;
+ }
+ case EventCallHistoryListener::REMOVED :
+ {
+ JSValueRef result = converter.toJSValueRef(event->getRemoveResult(), context);
+ multiCallbacks->getOnRemoved()->callOnSuccess(result);
+ break;
+ }
}
} catch(ConversionException) {
LogError("Conversion exception while processing EventCallHistoryListener");
EventCallHistoryListenerPrivateDataPtr
Converter::toEventCallHistoryListenerPrivateData(const JSValueRef &jsValue, JSContextRef context)
{
+
+ LogDebug("enter");
+
if (JSValueIsNull(m_context, jsValue) || JSValueIsUndefined(m_context, jsValue)) {
ThrowMsg(Commons::ConversionException, "Type missmatch error : Listener callback is null or undefined");
}
result.onAdded = JSUtils::getJSPropertyOrUndefined(m_context, objectCallbacks, "onadded");
result.onChanged = JSUtils::getJSPropertyOrUndefined(m_context, objectCallbacks, "onchanged");
+ result.onRemoved = JSUtils::getJSPropertyOrUndefined(m_context, objectCallbacks, "onremoved");
JSCallbackManagerPtr onAddedCbm = JSCallbackManager::createObject(context);
JSCallbackManagerPtr onChangedCbm = JSCallbackManager::createObject(context);
+ JSCallbackManagerPtr onRemovedCbm = JSCallbackManager::createObject(context);
if (!JSValueIsNull(m_context, result.onAdded) && !JSValueIsUndefined(m_context, result.onAdded)) {
if (JSObjectIsFunction(m_context, toJSObjectRef(result.onAdded))) {
}
}
- return EventCallHistoryListenerPrivateDataPtr(new EventCallHistoryListenerPrivateData(onAddedCbm, onChangedCbm));
+ if (!JSValueIsNull(m_context, result.onRemoved) && !JSValueIsUndefined(m_context, result.onRemoved)) {
+ if (JSObjectIsFunction(m_context, toJSObjectRef(result.onRemoved))) {
+ onRemovedCbm->setOnSuccess(result.onRemoved);
+ LogDebug("onRemoved register");
+ } else {
+
+ ThrowMsg(Commons::ConversionException, "Type missmatch error : onremoved callback");
+ }
+ }
+
+
+ return EventCallHistoryListenerPrivateDataPtr(new EventCallHistoryListenerPrivateData(onAddedCbm, onChangedCbm, onRemovedCbm));
}
JSValueRef Converter::toJSValueRef(const CallHistoryEntryListPtr& arg, JSContextRef context)
m_entryList = entryList;
}
+void EventCallHistoryListener::setRemoveResult (const StringArrayPtr &entryList)
+{
+ m_removeList = entryList;
+}
+
EventCallHistoryListener::ResultStates EventCallHistoryListener::getResultState() const
{
return m_resultState;
return m_entryList;
}
+StringArrayPtr EventCallHistoryListener::getRemoveResult() const
+{
+ return m_removeList;
+}
+
}
}
public:
typedef enum {
ADDED,
- CHANGED
+ CHANGED,
+ REMOVED
} ResultStates;
private:
ResultStates m_resultState;
CallHistoryEntryListPtr m_entryList;
+ StringArrayPtr m_removeList;
public:
void setResultState(const ResultStates state);
void setResult(const CallHistoryEntryListPtr &entryList);
+ void setRemoveResult (const StringArrayPtr &entryList);
ResultStates getResultState() const;
CallHistoryEntryListPtr getResult() const;
+ StringArrayPtr getRemoveResult() const;
+
EventCallHistoryListener();
};
}
}
-#endif
\ No newline at end of file
+#endif
ArgumentValidator::~ArgumentValidator(){
}
-JSValueRef ArgumentValidator::getArgument(int index, bool nullable){
+JSValueRef ArgumentValidator::getArgument(int index, bool nullable) const{
if( index < mArgc ){
return mArgv[index];
}
return value;
}
-double ArgumentValidator::toNumber(int index, bool nullable, double defaultvalue){
+double ArgumentValidator::toNumber(int index, bool nullable, double defaultvalue) const{
JSValueRef value = getArgument(index, nullable);
JSValueRef exception = NULL;
if( JSValueIsNull(mContext, value) && nullable){
return numberValue;
}
-long ArgumentValidator::toLong(int index, bool nullable, long defaultvalue){
+long ArgumentValidator::toLong(int index, bool nullable, long defaultvalue) const{
return static_cast<long>(toLongLong(index,nullable,defaultvalue));
}
-unsigned long ArgumentValidator::toULong(int index, bool nullable, long defaultvalue){
+unsigned long ArgumentValidator::toULong(int index, bool nullable, long defaultvalue) const{
return static_cast<unsigned long>(toULongLong(index,nullable,defaultvalue));
}
-long long ArgumentValidator::toLongLong(int index, bool nullable, long long defaultvalue){
+long long ArgumentValidator::toLongLong(int index, bool nullable, long long defaultvalue) const{
return static_cast<long long>(toNumber(index,nullable,defaultvalue));
}
-unsigned long long ArgumentValidator::toULongLong(int index, bool nullable, long long defaultvalue){
+unsigned long long ArgumentValidator::toULongLong(int index, bool nullable, long long defaultvalue) const{
return static_cast<unsigned long long>(toNumber(index,nullable,defaultvalue));
}
-double ArgumentValidator::toDouble(int index, bool nullable, double defaultvalue){
+double ArgumentValidator::toDouble(int index, bool nullable, double defaultvalue) const{
double doublevalue = toNumber(index,nullable,defaultvalue);
if( isnan(doublevalue)){
throw TypeMismatchException("Value is not number");
return doublevalue;
}
-std::string ArgumentValidator::toString(int index, bool nullable, const string & defaultvalue){
+std::string ArgumentValidator::toString(int index, bool nullable, const string & defaultvalue) const{
JSValueRef value = getArgument(index, nullable);
if( JSValueIsNull(mContext, value) && nullable){
return defaultvalue;
return result;
}
-bool ArgumentValidator::toBool(int index, bool nullable, bool defaultvalue){
+bool ArgumentValidator::toBool(int index, bool nullable, bool defaultvalue) const{
JSValueRef value = getArgument(index, nullable);
if( JSValueIsNull(mContext, value) && nullable){
return defaultvalue;
return boolvalue;
}
-time_t ArgumentValidator::toTimeT(int index, bool nullable, time_t defaultvalue){
+time_t ArgumentValidator::toTimeT(int index, bool nullable, time_t defaultvalue) const{
JSValueRef value = getArgument(index, nullable);
if( JSValueIsNull(mContext, value) && nullable){
return defaultvalue;
return JSUtil::JSValueToTimeT(mContext, value);
}
-JSObjectRef ArgumentValidator::toObject(int index, bool nullable){
+JSObjectRef ArgumentValidator::toObject(int index, bool nullable) const{
JSValueRef value = getArgument(index, nullable);
if( JSValueIsNull(mContext, value) && nullable){
return NULL;
return object;
}
-JSObjectRef ArgumentValidator::toObject(int index, JSClassRef info, bool nullable){
+JSObjectRef ArgumentValidator::toObject(int index, JSClassRef info, bool nullable) const{
JSObjectRef obj = toObject(index, nullable);
if( obj == NULL )
return NULL;
return obj;
}
-JSValueRef ArgumentValidator::toJSValueRef(int index, bool nullable){
+JSValueRef ArgumentValidator::toJSValueRef(int index, bool nullable) const{
return getArgument(index, nullable);
}
-JSObjectRef ArgumentValidator::toFunction(int index, bool nullable){
+JSObjectRef ArgumentValidator::toFunction(int index, bool nullable) const{
JSObjectRef obj = toObject(index, nullable);
if( obj == NULL && nullable){
return NULL;
return obj;
}
-JSObjectRef ArgumentValidator::toArrayObject(int index, bool nullable){
+JSObjectRef ArgumentValidator::toArrayObject(int index, bool nullable) const{
JSValueRef value = getArgument(index, nullable);
if( JSValueIsNull(mContext, value) && nullable){
return NULL;
}
if( !JSIsArrayValue(mContext, value)){
- JSObjectRef jsArray = JSCreateArrayObject(mContext, 0, NULL);
- if( !JSValueIsNull(mContext,value) && !JSValueIsUndefined(mContext,value) )
- JSSetArrayElement(mContext, jsArray, 0, value);
- return jsArray;
+ throw TypeMismatchException("Type is not Array");
}
+
JSValueRef exception = NULL;
JSObjectRef obj = JSValueToObject(mContext, value, &exception);
if( exception != NULL )
}
-std::vector<std::string> ArgumentValidator::toStringVector(int index, bool nullable){
+std::vector<std::string> ArgumentValidator::toStringVector(int index, bool nullable) const{
JSObjectRef value = toArrayObject(index, nullable);
if( value == NULL || JSValueIsNull(mContext, value) ){
return std::vector<std::string>();
return JSUtil::JSArrayToStringVector(mContext, value);
}
-std::vector<long> ArgumentValidator::toLongVector(int index, bool nullable){
+std::vector<long> ArgumentValidator::toLongVector(int index, bool nullable) const{
JSObjectRef value = toArrayObject(index, nullable);
if( value == NULL || JSValueIsNull(mContext, value) ){
return std::vector<long>();
}
-std::vector<double> ArgumentValidator::toDoubleVector(int index, bool nullable){
+std::vector<double> ArgumentValidator::toDoubleVector(int index, bool nullable) const{
JSObjectRef value = toArrayObject(index, nullable);
if( value == NULL || JSValueIsNull(mContext, value) ){
return std::vector<double>();
return JSUtil::JSArrayToDoubleVector(mContext, value);
}
-std::vector<time_t> ArgumentValidator::toTimeTVector(int index, bool nullable){
+std::vector<time_t> ArgumentValidator::toTimeTVector(int index, bool nullable) const{
JSObjectRef value = toArrayObject(index, nullable);
if( value == NULL || JSValueIsNull(mContext, value) ){
return std::vector<time_t>();
return JSUtil::JSArrayToTimeTVector(mContext, value);
}
-std::vector<bool> ArgumentValidator::toBoolVector(int index, bool nullable){
+std::vector<bool> ArgumentValidator::toBoolVector(int index, bool nullable) const{
JSObjectRef value = toArrayObject(index, nullable);
if( value == NULL || JSValueIsNull(mContext, value) ){
return std::vector<bool>();
return JSUtil::JSArrayToBoolVector(mContext, value);
}
-std::vector<JSValueRef> ArgumentValidator::toJSValueRefVector(int index, bool nullable){
+std::vector<JSValueRef> ArgumentValidator::toJSValueRefVector(int index, bool nullable) const{
JSObjectRef value = toArrayObject(index, nullable);
if( value == NULL || JSValueIsNull(mContext, value) ){
return std::vector<JSValueRef>();
return result;
}
-std::map<std::string, std::string> ArgumentValidator::toStringMap(int index, bool nullable){
+std::map<std::string, std::string> ArgumentValidator::toStringMap(int index, bool nullable) const{
JSObjectRef value = toObject(index, nullable);
if( value == NULL || JSValueIsNull(mContext, value) ){
return std::map<std::string, std::string>();
ArgumentValidator(JSContextRef ctx, int argc, const JSValueRef* argv);
~ArgumentValidator();
- double toNumber(int index, bool nullable = false, double defaultvalue = 0);
- long toLong(int index, bool nullable = false, long defaultvalue = 0);
- unsigned long toULong(int index, bool nullable = false, long defaultvalue = 0);
- long long toLongLong(int index, bool nullable = false, long long defaultvalue = 0);
- unsigned long long toULongLong(int index, bool nullable = false, long long defaultvalue = 0);
- double toDouble(int index, bool nullable = false, double defaultvalue = 0);
- std::string toString(int index, bool nullable = false, const std::string& defaultvalue = "");
- bool toBool(int index, bool nullable = false, bool defaultvalue = false);
- time_t toTimeT(int index, bool nullable = false, time_t defaultvalue = 0);
- JSObjectRef toObject(int index, bool nullable = false);
- JSObjectRef toObject(int index, JSClassRef info, bool nullable = false);
- JSObjectRef toFunction(int index, bool nullable = false);
- JSObjectRef toArrayObject(int index, bool nullable = false);
- JSValueRef toJSValueRef(int index, bool nullable = false);
+ double toNumber(int index, bool nullable = false, double defaultvalue = 0) const;
+ long toLong(int index, bool nullable = false, long defaultvalue = 0) const;
+ unsigned long toULong(int index, bool nullable = false, long defaultvalue = 0) const;
+ long long toLongLong(int index, bool nullable = false, long long defaultvalue = 0) const;
+ unsigned long long toULongLong(int index, bool nullable = false, long long defaultvalue = 0) const;
+ double toDouble(int index, bool nullable = false, double defaultvalue = 0) const;
+ std::string toString(int index, bool nullable = false, const std::string& defaultvalue = "") const;
+ bool toBool(int index, bool nullable = false, bool defaultvalue = false) const;
+ time_t toTimeT(int index, bool nullable = false, time_t defaultvalue = 0) const;
+ JSObjectRef toObject(int index, bool nullable = false) const;
+ JSObjectRef toObject(int index, JSClassRef info, bool nullable = false) const;
+ JSObjectRef toFunction(int index, bool nullable = false) const;
+ JSObjectRef toArrayObject(int index, bool nullable = false) const;
+ JSValueRef toJSValueRef(int index, bool nullable = false) const;
- std::vector<std::string> toStringVector(int index, bool nullable = false);
- std::vector<long> toLongVector(int index, bool nullable = false);
- std::vector<double> toDoubleVector(int index, bool nullable = false);
- std::vector<time_t> toTimeTVector(int index, bool nullable = false);
- std::vector<bool> toBoolVector(int index, bool nullable = false);
- std::vector<JSValueRef> toJSValueRefVector(int index, bool nullable= false);
+ std::vector<std::string> toStringVector(int index, bool nullable = false) const;
+ std::vector<long> toLongVector(int index, bool nullable = false) const;
+ std::vector<double> toDoubleVector(int index, bool nullable = false) const;
+ std::vector<time_t> toTimeTVector(int index, bool nullable = false) const;
+ std::vector<bool> toBoolVector(int index, bool nullable = false) const;
+ std::vector<JSValueRef> toJSValueRefVector(int index, bool nullable= false) const;
- std::map<std::string, std::string> toStringMap(int index, bool nullable = false);
+ std::map<std::string, std::string> toStringMap(int index, bool nullable = false) const;
private:
- JSValueRef getArgument(int index, bool nullable);
+ JSValueRef getArgument(int index, bool nullable) const;
JSContextRef mContext;
int mArgc;
const JSValueRef* mArgv;
static JSObjectRef makeDateObject(JSContextRef ctx, const time_t value);
-protected:
-
template<class T>
static std::vector<T> JSArrayToType_(JSContextRef ctx, JSValueRef value, T (*convert)(JSContextRef, JSValueRef)){
std::vector<T> result;
Try
{
int *ids = new int[contactIds->size()];
- int *tmpIds = new int[contactIds->size()];
+// int *tmpIds = new int[contactIds->size()];
int count = 0;
if(errorCode != CONTACTS_ERROR_NONE)
}
ids[count] = contactId;
- tmpIds[count] = contactId;
+// tmpIds[count] = contactId;
count++;
}
Catch(Exception)
// continue;
}
}
-
+/*
contacts_filter_h filter = NULL;
contacts_query_h query = NULL;
if(contactIds->size() != (unsigned int)record_count)
ThrowMsg(InvalidArgumentException, "Ids' db count : " << record_count << " (" << __FUNCTION__ << ")");
-
+*/
KeySharePtrPair *keyPair = new KeySharePtrPair();
keyPair->key = m_eventMapAcc;
keyPair->addressBook = this;
{
delete [] ids;
}
+/*
if(tmpIds != NULL)
{
delete [] tmpIds;
}
+*/
if(errorCode != CONTACTS_ERROR_NONE)
{
delete keyPair;
else if(type == CONTACT_PHONE_NUMBER_TYPE_PCS)
ctsIntType = ctsIntType | CONTACTS_NUMBER_TYPE_PCS;
else
- {
- // TODO Will be added after type changed to string
- // ctsIntType = ctsIntType | CONTACTS_NUMBER_TYPE_CUSTOM;
- // ctsStrCustomType = ...;
- }
+ ctsIntType = ctsIntType | CONTACTS_NUMBER_TYPE_VOICE;
}
child_record = NULL;
ctsIntType = ctsIntType | CONTACTS_EMAIL_TYPE_HOME;
else if(type == CONTACT_EMAIL_TYPE_WORK)
ctsIntType = ctsIntType | CONTACTS_EMAIL_TYPE_WORK;
- //else
- //{
- // //TODO Will be added after type changed to string
- // //ctsIntType = ctsIntType | CONTACTS_EMAIL_TYPE_CUSTOM;
- // // ctsStrCustomType = ...;
- //}
+ else
+ ctsIntType = ctsIntType | CONTACTS_EMAIL_TYPE_HOME;
}
child_record = NULL;
ctsIntType = ctsIntType | CONTACTS_ADDRESS_TYPE_HOME;
else if(type == CONTACT_ADDRESS_TYPE_WORK)
ctsIntType = ctsIntType | CONTACTS_ADDRESS_TYPE_WORK;
- //else
- //{
- // // TODO Will be added after type changed to string
- // // ctsIntType = ctsIntType | CTS_POSTAL_TYPE_CUSTOM;
- // // ctsStrCustomType = ...;
- //}
+ else
+ ctsIntType = ctsIntType | CONTACTS_ADDRESS_TYPE_HOME;
}
child_record = NULL;
else if(type == WEBSITE_TYPE_BLOG)
ctsIntType = CONTACTS_URL_TYPE_WORK;
else
- {
- // TODO Will be added after type changed to string
- // ctsIntType = CONTACTS_URL_TYPE_CUSTOM;
- // ctsStrCustomType = ...;
- }
+ ctsIntType = CONTACTS_URL_TYPE_HOME;
child_record = NULL;
if(intValue & CONTACTS_NUMBER_TYPE_PCS)
phoneNumber->addType(CONTACT_PHONE_NUMBER_TYPE_PCS);
+ if(phoneNumber->getTypes()->size() == 0)
+ phoneNumber->addType(CONTACT_PHONE_NUMBER_TYPE_VOICE);
+
// TODO Will be added after type changed to string
// if(intValue & CONTACTS_NUMBER_TYPE_CUSTOM)
// {
if(intValue & CONTACTS_EMAIL_TYPE_WORK)
email->addType(CONTACT_EMAIL_TYPE_WORK);
+ if(email->getTypes()->size() == 0)
+ email->addType(CONTACT_EMAIL_TYPE_HOME);
+
// TODO Will be added after type changed to string
// if(intValue & CONTACTS_EMAIL_TYPE_CUSTOM)
// {
anniversary->setLabel(charValue);
anniversaries->push_back(anniversary);
+ }else{
+ ContactAnniversaryPtr anniversary = ContactAnniversaryPtr(new ContactAnniversary());
+
+ anniversary->setDate(tmDate);
+ contacts_record_get_str_p(child_record, _contacts_event.label, &charValue);
+ if(charValue)
+ anniversary->setLabel(charValue);
+
+ anniversaries->push_back(anniversary);
}
}
}
if(intValue & CONTACTS_ADDRESS_TYPE_WORK)
address->addType(CONTACT_ADDRESS_TYPE_WORK);
+ if(address->getTypes()->size() == 0)
+ address->addType(CONTACT_ADDRESS_TYPE_HOME);
+
// TODO Will be added after type changed to string
// if(intValue & CONTACTS_ADDRESS_TYPE_CUSTOM)
// {
contacts_record_get_int(child_record, _contacts_url.type, &intValue);
if(intValue == CONTACTS_URL_TYPE_HOME)
url->setType(WEBSITE_TYPE_HOMEPAGE);
- else if(intValue == CONTACTS_URL_TYPE_WORK)
+ if(intValue == CONTACTS_URL_TYPE_WORK)
url->setType(WEBSITE_TYPE_BLOG);
+ if(url->getTypeIsSet() == false)
+ url->setType(WEBSITE_TYPE_HOMEPAGE);
+
// TODO Will be added after type changed to string
// if(intValue & CONTACTS_URL_TYPE_CUSTOM)
// {
void ContactQueueManager::decreaseQueueList()
{
- count--;
+ if(count > 0)
+ count--;
LogDebug("count : " << count);
}
if(length != 0)
{
- sortContacts(property, ids, m_sortOrder, m_filteredContactIds);
- result = getContacts(ids);
+ if(m_sortOrder == ASCENDING_SORT_ORDER)
+ sortContacts(property, ids, true, m_filteredContactIds);
+ else
+ sortContacts(property, ids, false, m_filteredContactIds);
+
+ result = getContacts(ids);
}else{
ContactArrayPtr contacts(new ContactArray());
result = contacts;
{
string result;
- if(validate("^file:///[\x20-\x7E]+$", str, VALIDATE_MATCH_CASELESS))
- result = str.substr(string("file://").size());
- else if(validate("^/[\x20-\x7E]+$", str, VALIDATE_MATCH_CASELESS))
+ std::string schema ("file://");
+ unsigned found = str.find(schema);
+ if(found != std::string::npos)
+ result = str.substr(schema.size());
+ else
result = str;
return result;
{
string result;
- if(validate("^/[\x20-\x7E]+$", str, VALIDATE_MATCH_CASELESS))
- result = "file://" + str;
- else if(validate("^file:///[\x20-\x7E]+$", str, VALIDATE_MATCH_CASELESS))
+ std::string schema ("file://");
+ unsigned found = str.find(schema);
+ if(found != std::string::npos)
result = str;
+ else
+ result = schema + str;
return result;
}
MediacontentFolder::MediacontentFolder()
{
+ m_modifiedDate = NULL;
}
MediacontentFolder::~MediacontentFolder()
{
-
+ if(m_modifiedDate != NULL)
+ {
+ free(m_modifiedDate);
+ }
}
m_storageType = value;
}
-tm MediacontentFolder::getFolderModifiedDate() const
+tm* MediacontentFolder::getFolderModifiedDate() const
{
return m_modifiedDate;
}
}
-void MediacontentFolder::setFolderModifiedDate(const tm &value)
+void MediacontentFolder::setFolderModifiedDate(tm *value)
{
m_modifiedDate = value;
string getFolderPath() const;
string getFolderName() const;
string getFolderStorageType();
- tm getFolderModifiedDate() const;
+ tm* getFolderModifiedDate() const;
MediaIdListPtr getMediaIdList() const;
void setFolderUUID(const string &value);
void setFolderPath(const string &value);
void setFolderName(const string &value);
void setFolderStorageType(const string &value);
- void setFolderModifiedDate(const tm &value);
+ void setFolderModifiedDate(tm *value);
void setMediaIdList(const MediaIdListPtr &value);
void insertValue(string attr, string value);
string m_folderPath;
string m_folderName;
string m_storageType;
- tm m_modifiedDate;
+ tm* m_modifiedDate;
MediaIdListPtr m_mediaIdArrayPtr;
map<string,string> m_folderValue;
}
*/
-tm MediacontentManager::toDateTm(time_t date)
+tm* MediacontentManager::toDateTm(time_t date)
{
- tm tm_date;
+ tm *tm_date = (struct tm *)calloc(1, sizeof(struct tm));
- localtime_r(&date, &tm_date);
+ localtime_r(&date, tm_date);
return tm_date;
}
//newImage->setReleasedDate(toDateTm(sqlite3_column_int(pStmt,7)));
if ( MEDIA_CONTENT_ERROR_NONE == media_info_get_modified_time (info, &tmpDate) )
{
- newMedia->setModifiedDate(toDateTm(tmpDate));
+ if(tmpDate)
+ {
+ newMedia->setModifiedDate(toDateTm(tmpDate));
+ }
}
if ( MEDIA_CONTENT_ERROR_NONE == media_info_get_favorite (info, &tmpBool) )
{
if ( tmpStr )
{
- struct tm result;
- if (strptime(tmpStr, "%Y:%m:%d %H:%M:%S", &result) == NULL) {
+ struct tm *result = (struct tm *)calloc(1, sizeof(struct tm));
+ if (strptime(tmpStr, "%Y:%m:%d %H:%M:%S", result) == NULL) {
LogError( "Couldn't convert supplied date.");
}
{
if ( tmpStr )
{
- struct tm result;
- if (strptime(tmpStr, "%Y:%m:%d %H:%M:%S", &result) == NULL) {
+ struct tm *result=(struct tm *)calloc(1, sizeof(struct tm));
+ if (strptime(tmpStr, "%Y:%m:%d %H:%M:%S", result) == NULL) {
LogError( "Couldn't convert supplied date.");
}
newVideo->setReleasedDate(result);
{
if ( tmpStr )
{
- struct tm result;
- if (strptime(tmpStr, "%Y:%m:%d %H:%M:%S", &result) == NULL) {
+ struct tm *result = (struct tm *)calloc(1, sizeof(struct tm));
+ if (strptime(tmpStr, "%Y:%m:%d %H:%M:%S", result) == NULL) {
LogError( "Couldn't convert supplied date.");
}
newAudio->setReleasedDate(result);
static void convertToPlatformFolder(media_folder_h media_folder, MediacontentFolderPtr& newFolder);
bool updateMediaToDB(MediacontentMediaPtr mediaPtr);
string makeQuerySortMode(SortModeArrayPtr attr, MediaSearchVisitor::QueryType value=MediaSearchVisitor::QUERY_FOLDER);
- static tm toDateTm(time_t date);
+ static tm* toDateTm(time_t date);
media_content_orientation_e convertToOrientation(string orientation);
private:
{
m_isChangedFavorite = false;
m_isChangedDisplayName = false;
+ m_createdDate = NULL;
+ m_releasedDate = NULL;
+ m_modifiedDate = NULL;
m_size = 0;
m_rating = 0;
MediacontentMedia::~MediacontentMedia()
{
- m_editableAttrList.clear();
+ m_editableAttrList.clear();
+ if(m_createdDate != NULL)
+ {
+ free(m_createdDate);
+ }
+ if(m_releasedDate != NULL)
+ {
+ free(m_releasedDate);
+ }
+ if(m_modifiedDate != NULL)
+ {
+ free(m_modifiedDate);
+ }
}
string MediacontentMedia::getMediaUUID() const
}
-tm MediacontentMedia::getCreatedDate() const
+tm* MediacontentMedia::getCreatedDate() const
{
return m_createdDate;
}
-tm MediacontentMedia::getReleasedDate() const
+tm* MediacontentMedia::getReleasedDate() const
{
return m_releasedDate;
}
m_thumbnailPath = value;
}
-tm MediacontentMedia::getModifiedDate() const
+tm* MediacontentMedia::getModifiedDate() const
{
return m_modifiedDate;
}
-void MediacontentMedia::setCreatedDate(const tm &value)
+void MediacontentMedia::setCreatedDate(tm *value)
{
m_createdDate = value;
}
-void MediacontentMedia::setReleasedDate(const tm &value)
+void MediacontentMedia::setReleasedDate(tm *value)
{
m_releasedDate = value;
}
-void MediacontentMedia::setModifiedDate(const tm &value)
+void MediacontentMedia::setModifiedDate(tm *value)
{
m_modifiedDate = value;
virtual string getTitle() const;
virtual string getFilePath() const;
virtual string getThumbnailPath() const;
- virtual tm getCreatedDate() const;
- virtual tm getReleasedDate() const;
- virtual tm getModifiedDate() const;
+ virtual tm* getCreatedDate() const;
+ virtual tm* getReleasedDate() const;
+ virtual tm* getModifiedDate() const;
virtual string getDescription() const;
virtual bool getFavorite() const;
virtual unsigned long long getSize() const;
virtual void setTitle(const string &value);
virtual void setFilePath(const string &value);
virtual void setThumbnailPath(const string &value);
- virtual void setCreatedDate(const tm &value);
- virtual void setReleasedDate(const tm &value);
- virtual void setModifiedDate(const tm &value);
+ virtual void setCreatedDate(tm *value);
+ virtual void setReleasedDate(tm *value);
+ virtual void setModifiedDate(tm *value);
virtual void setFavorite( bool value);
virtual void setDescription(const string &value, bool isChanged=false);
virtual void setSize(unsigned long long value);
string m_filePath;
string m_thumbnailPath;
string m_description;
- tm m_createdDate;
- tm m_releasedDate;
- tm m_modifiedDate;
+ tm *m_createdDate;
+ tm *m_releasedDate;
+ tm *m_modifiedDate;
unsigned long long m_size;
int m_rating;
bool m_favorite; //unused.
string ContentUtility::convertUriToPath(const string str)
{
- string result;
+ string result;
+ std::string schema ("file://");
+ std::string _str = ContentUtility::ltrim(str);
- if(validate("^file:///[\x20-\x7E]+$", str, VALIDATE_MATCH_CASELESS))
- result = str.substr(string("file://").size());
- else if(validate("^/[\x20-\x7E]+$", str, VALIDATE_MATCH_CASELESS))
- result = str;
+ std::string _schema = _str.substr(0,schema.size());
- return result;
+ if(_schema == schema)
+ {
+ result = _str.substr(schema.size());
+ }
+ else
+ {
+ result = _str;
+ }
+ return result;
}
string ContentUtility::convertPathToUri(const string str)
{
- string result;
+ string result;
+ std::string schema ("file://");
+ std::string _str = ContentUtility::ltrim(str);
- if(validate("^/[\x20-\x7E]+$", str, VALIDATE_MATCH_CASELESS))
- result = "file://" + str;
- else if(validate("^file:///[\x20-\x7E]+$", str, VALIDATE_MATCH_CASELESS))
- result = str;
+ std::string _schema = _str.substr(0,schema.size());
- return result;
+ if(_schema == schema)
+ {
+ result = _str;
+ }
+ else
+ {
+ result = schema + _str;
+ }
+ return result;
+}
+
+std::string ContentUtility::ltrim(const std::string s)
+{
+ std::string str = s;
+ std::string::iterator i;
+ for (i = str.begin(); i != str.end(); i++) {
+ if (!isspace(*i)) {
+ break;
+ }
+ }
+ if (i == str.end()) {
+ str.clear();
+ } else {
+ str.erase(str.begin(), i);
+ }
+ return str;
}
class ContentUtility
{
public:
- ContentUtility();
- virtual ~ContentUtility();
+ ContentUtility();
+ virtual ~ContentUtility();
- static std::string convertUriToPath(const std::string str);
- static std::string convertPathToUri(const std::string str);
+ static std::string convertUriToPath(const std::string str);
+ static std::string convertPathToUri(const std::string str);
+
+private:
+ static std::string ltrim(const std::string s);
};
{
Converter converter(context);
MediacontentMediaPtr media = getMediaObject(object);
- return converter.toJSValueRef(media->getModifiedDate());
+ if(media->getModifiedDate() != NULL)
+ {
+ return converter.toJSValueRef(*(media->getModifiedDate()));
+ }
}
Catch(Exception)
{
{
Converter converter(context);
MediacontentMediaPtr media = getMediaObject(object);
- return converter.toJSValueRef(media->getReleasedDate());
+ if(media->getReleasedDate() != NULL)
+ {
+ return converter.toJSValueRef(*(media->getReleasedDate()));
+ }
}
Catch(Exception)
{
{
Converter converter(context);
MediacontentFolderPtr folder = getFolderObject(object);
- return converter.toJSValueRef(folder->getFolderModifiedDate());
+ if(folder->getFolderModifiedDate() != NULL)
+ {
+ return converter.toJSValueRef(*(folder->getFolderModifiedDate()));
+ }
}
Catch(Exception)
{
moveOneRow();
}
- buf = new char[memorizedSize];
+ buf = new char[memorizedSize + 1];
if (buf == NULL)
{
delete[] buf;
}
- buf = new char[memorizedSize];
+ buf = new char[memorizedSize + 1];
}
if (buf == NULL)
ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Out of memory");
}
- memset(buf, 0, memorizedSize);
+ memset(buf, 0, memorizedSize + 1);
switch (type)
{
} else if (!tizenValue.compare(TIZEN_DATA_SYNC_TYPE_ONE_WAY_FROM_SERVER)) {
return SyncInfo::ONE_WAY_FROM_SERVER_TYPE;
} else if (!tizenValue.compare(TIZEN_DATA_SYNC_TYPE_REFRESH_FROM_SERVER)) {
- return SyncInfo::REFRESH_FROM_CLIENT_TYPE;
+ return SyncInfo::REFRESH_FROM_SERVER_TYPE;
} else {
ThrowMsg(ConversionException, "Invalid sync type.");
}
} else if (!tizenValue.compare(TIZEN_DATA_SYNC_INTERVAL_1_WEEK)) {
return SyncInfo::INTERVAL_1_WEEK;
} else if (!tizenValue.compare(TIZEN_DATA_SYNC_INTERVAL_1_MONTH)) {
- return SyncInfo::INTERVAL_1_WEEK;
+ return SyncInfo::INTERVAL_1_MONTH;
} else {
ThrowMsg(ConversionException, "Invalid sync interval.");
}
eventPtr->setProfileId(profileDirName);
}
- if(0==strcmp(error, "DONE")) {
- // Stoped and completed cases not distinguished yet.
+ if(NULL==progress) {
+ LogWarning("Null status.");
+ eventPtr->setSessionStatus(OnDataSyncStateChanged::UNDEFINED_STATUS);
+ } else if(0==strcmp(progress, "DONE")) {
eventPtr->setSessionStatus(OnDataSyncStateChanged::COMPLETE_STATUS);
- } else if(0==strcmp(error, "ERROR")) {
- // Error cases should be transferred.
+ } else if(0==strcmp(progress, "CANCEL")) {
+ eventPtr->setSessionStatus(OnDataSyncStateChanged::STOP_STATUS);
+ } else if(0==strcmp(progress, "ERROR")) {
+ // Error cases should be redefined and transferred based on the error value.
eventPtr->setSessionStatus(OnDataSyncStateChanged::FAIL_STATUS);
} else {
LogWarning("Wrong status.");
char *profileDirName = NULL;
int syncType = 0;
- char *uri = NULL;
+ int uri;
char *progressStatus = NULL;
char *operationType = NULL;
eventPtr->setSessionStatus(OnDataSyncStateChanged::PROGRESS_STATUS);
- if(0==strcmp(uri, "Contacts")) {
+ if(SYNC_AGENT_SRC_URI_CONTACT==uri) {
eventPtr->setServiceType(SyncServiceInfo::CONTACT_SERVICE_TYPE);
- } else if(0==strcmp(uri, "Organizer")) {
+ } else if(SYNC_AGENT_SRC_URI_CALENDAR==uri) {
eventPtr->setServiceType(SyncServiceInfo::EVENT_SERVICE_TYPE);
} else {
LogWarning("Wrong service type.");
if(profileDirName) {
g_free(profileDirName);
}
- if(uri) {
- g_free(uri);
- }
if(progressStatus) {
g_free(progressStatus);
}
if(event->getEmitter()) {
LogDebug("Attaching the emitter with profileId: "<<event->getProfileId());
- m_changeEmitters[event->getProfileId()] = event->getEmitter();
+ m_changeEmitters[std::string("Sync") + event->getProfileId()] = event->getEmitter();
}
event->setResult(true);
emitter->setListener(&DataSyncResponseDispatcher::getInstance());
emitter->setEventPrivateData(DPL::StaticPointerCast<IEventPrivateData>(privData));
+ LogDebug("Set the emitter.");
dplEvent->setEmitter(emitter);
} else if (JSValueIsNull(context, arguments[1]) || JSValueIsUndefined(context, arguments[1]) ) {
LogDebug("Null or undefined listener.");
throw UnknownException(("Platform error while getting downloaded full path. " + _get_download_error(ret)).c_str());
}
+ ret = download_destroy(downloadId);
+ if (ret != DOWNLOAD_ERROR_NONE) {
+ LogWarning("Platform error while destroying download handle. downloadId=" << downloadId);
+ }
+
std::string virtualPath;
try {
virtualPath = DeviceAPI::Filesystem::Utils::toVirtualPath(NULL, fullPath);
errMessage = _get_download_error(err);
}
+ ret = download_destroy(downloadId);
+ if (ret != DOWNLOAD_ERROR_NONE) {
+ LogWarning("Platform error while destroying download handle. downloadId=" << downloadId);
+ }
+
UnknownException error(errMessage.c_str());
callback->onfailed(downloadId, error);
thisObj->removeCallbackFromMap(downloadId);
throw UnknownException(("Platform error while unsetting progress callback. " + _get_download_error(ret)).c_str());
}
+ ret = download_destroy(downloadId);
+ if (ret != DOWNLOAD_ERROR_NONE) {
+ LogWarning("Platform error while destroying download handle. downloadId=" << downloadId);
+ }
+
callback->oncanceled(downloadId);
thisObj->removeCallbackFromMap(downloadId);
break;
try {
priv->setDestination(validator.toString(1, true, ""));
} catch (const BasePlatformException& err) {
- LogWarning("url destination is failed. %s", err.getMessage().c_str());
+ LogWarning("destination convertion is failed. %s", err.getMessage().c_str());
}
try {
priv->setFileName(validator.toString(2, true, ""));
} catch (const BasePlatformException& err) {
- LogWarning("url fileName is failed. %s", err.getMessage().c_str());
+ LogWarning("fileName convertion is failed. %s", err.getMessage().c_str());
}
try {
priv->setNetworkType(validator.toString(3, true, ""));
} catch (const BasePlatformException& err) {
- LogWarning("url networkType is failed. %s", err.getMessage().c_str());
+ LogWarning("networkType convertion is failed. %s", err.getMessage().c_str());
}
try {
priv->setHttpHeader(validator.toStringMap(4, true));
} catch (const BasePlatformException& err) {
- LogWarning("url networkType is failed. %s", err.getMessage().c_str());
+ LogWarning("httpHeader convertion is failed. %s", err.getMessage().c_str());
}
setPrivateObject(context, obj, priv);
{
LogDebug("arg:[" << arg << "]");
+ // uri path, strip file://
+ if (isUriPath(arg)) {
+ std::string stripPath = arg.substr(strlen("file://"));
+ LogDebug("uri absolute path" << stripPath);
+ IPathPtr result = IPath::create(stripPath);
+
+ return result;
+ }
+
if (!isPathValid(arg)) {
LogDebug("virtual path is invalid:[" << arg << "]");
ThrowMsg(Commons::ConversionException, "Not found path component.");
rootToPath["wgt-private"] = widgetDB->getWidgetPersistentStoragePath();
rootToPath["wgt-private-tmp"] = widgetDB->getWidgetTemporaryStoragePath();
RootToPathMapIterator it = rootToPath.find(root);
+
if (it == rootToPath.end()) {
- ThrowMsg(Commons::NotFoundException, "Location not found.");
+ //ThrowMsg(Commons::NotFoundException, "Location not found.");
+ LogDebug("Allow non virtual root path " << arg);
+ return IPath::create(arg);
}
+
IPathPtr result = IPath::create(it->second);
if (!tail.empty()) {
pathToRoot[widgetDB->getWidgetTemporaryStoragePath()] = "wgt-private-tmp";
std::string path = arg;
+
std::string::size_type pos = path.size();
while (std::string::npos != (pos = path.rfind(IPath::getSeparator(), pos))) {
PathToRootMapIterator it = pathToRoot.find(path);
}
path.erase(pos, path.size());
}
- ThrowMsg(Commons::ConversionException, "Path doesn't contain a valid location type.");
+ LogDebug("Allow non virtual root path");
+
+ return arg;
+// ThrowMsg(Commons::ConversionException, "Path doesn't contain a valid location type.");
+}
+
+bool isUriPath(const std::string& path) {
+ const char* uriPrefix = "file://";
+ const char* stringFromPath = path.c_str();
+
+ if (!strncmp(uriPrefix, stringFromPath, strlen(uriPrefix)) && path[strlen(uriPrefix)] == '/') {
+ return true;
+ }
+
+ return false;
}
bool isPathValid(const std::string& path) {
std::string toVirtualPath(JSContextRef context, const std::string& arg);
bool isPathValid(const std::string& path);
+bool isUriPath(const std::string& path);
+
void toUTF8String(std::string fromEncoding, const char* from, const size_t fromLength, std::string &outputString);
}
}
bool recursive = converter.toBool(reserveArguments[1]);
if (*privateObject->getObject()->getNode()->getPath() != path->getPath()) {
- cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::IO_ERROR, "IO error"));
+ cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::NOT_FOUND_ERROR, "not found error"));
return JSValueMakeUndefined(context);
}
if (eventResolve->setForSynchronousCall()) {
IManager::getInstance().getNode(eventResolve);
if (!eventResolve->getResult() || (eventResolve->getExceptionCode() != WrtDeviceApis::Commons::ExceptionCodes::None)) {
- cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::IO_ERROR, "IO error"));
- return JSValueMakeUndefined(context);
+
+ if(eventResolve->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::NotFoundException)
+ ThrowMsg(NotFoundException, "Not found error");
+ else
+ ThrowMsg(PlatformException, "IO Error");
}
if (eventResolve->getResult()->getType() != NT_DIRECTORY) {
} catch(const WrtDeviceApis::Commons::InvalidArgumentException& ex) {
cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR, ex.GetMessage()));
} catch(const WrtDeviceApis::Commons::NotFoundException& ex) {
- return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_FOUND_ERROR, ex.GetMessage());
+ cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::NOT_FOUND_ERROR, ex.GetMessage()));
} catch(const WrtDeviceApis::Commons::Exception& ex) {
cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR, ex.GetMessage()));
}
JSObjectRef object = JSUtils::makeObject(data->getCallbackManager()->getContext(), JSFile::getClassRef(), privData);
data->getCallbackManager()->callOnSuccess(object);
} else {
- JSObjectRef jsException = JSTizenExceptionFactory::makeErrorObject(data->getCallbackManager()->getContext(), JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error");
+ JSObjectRef jsException;
+ if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::NotFoundException) {
+ jsException = JSTizenExceptionFactory::makeErrorObject(data->getCallbackManager()->getContext(), JSTizenException::NOT_FOUND_ERROR, "NotFoundError");
+ } else {
+ JSTizenExceptionFactory::makeErrorObject(data->getCallbackManager()->getContext(), JSTizenException::UNKNOWN_ERROR, "Unknown error");
+ }
data->getCallbackManager()->callOnError(jsException);
}
}
JSObjectRef object = JSUtils::makeObject(data->getContext(), JSFilestream::getClassRef(), event->getResult());
data->callOnSuccess(object);
} else {
- JSObjectRef jsException = JSTizenExceptionFactory::makeErrorObject(data->getContext(), JSTizenException::IO_ERROR, "IO error");
+ JSObjectRef jsException;
+
+ if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::NotFoundException) {
+ jsException = JSTizenExceptionFactory::makeErrorObject(data->getContext(), JSTizenException::NOT_FOUND_ERROR, "NotFoundError");
+ }
+ else {
+ jsException = JSTizenExceptionFactory::makeErrorObject(data->getContext(), JSTizenException::IO_ERROR, "IO error");
+ }
data->callOnError(jsException);
}
}
JSObjectRef jsException = NULL;
if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::SecurityException) {
jsException = JSTizenExceptionFactory::makeErrorObject(data->getContext(), JSTizenException::PERMISSION_DENIED_ERROR, "Permission denied error");
- } else {
+ }
+ else if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::NotFoundException) {
+ jsException = JSTizenExceptionFactory::makeErrorObject(data->getContext(), JSTizenException::NOT_FOUND_ERROR, "NotFoundError");
+ }
+ else {
jsException = JSTizenExceptionFactory::makeErrorObject(data->getContext(), JSTizenException::IO_ERROR, "IO error");
}
data->callOnError(jsException);
JSObjectRef jsException = NULL;
if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::SecurityException) {
jsException = JSTizenExceptionFactory::makeErrorObject(data->getContext(), JSTizenException::PERMISSION_DENIED_ERROR, "Permission denied error");
- } else {
+ }
+ else if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::NotFoundException) {
+ jsException = JSTizenExceptionFactory::makeErrorObject(data->getContext(), JSTizenException::NOT_FOUND_ERROR, "NotFoundError");
+ }
+ else {
jsException = JSTizenExceptionFactory::makeErrorObject(data->getContext(), JSTizenException::IO_ERROR, "IO error");
}
data->callOnError(jsException);
JSObjectRef jsException = NULL;
if (event->getExceptionCode() ==WrtDeviceApis::Commons::ExceptionCodes::SecurityException) {
jsException = JSTizenExceptionFactory::makeErrorObject(data->getContext(), JSTizenException::PERMISSION_DENIED_ERROR, "Permission denied error");
- } else {
+ }
+ else if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::NotFoundException) {
+ jsException = JSTizenExceptionFactory::makeErrorObject(data->getContext(), JSTizenException::NOT_FOUND_ERROR, "NotFoundError");
+ }
+ else {
jsException = JSTizenExceptionFactory::makeErrorObject(data->getContext(), JSTizenException::IO_ERROR, "IO error");
}
data->callOnError(jsException);
JSObjectRef jsException = NULL;
if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::SecurityException) {
jsException = JSTizenExceptionFactory::makeErrorObject(data->getContext(), JSTizenException::PERMISSION_DENIED_ERROR, "Permission denied error");
- } else {
+ }
+ else if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::NotFoundException) {
+ jsException = JSTizenExceptionFactory::makeErrorObject(data->getContext(), JSTizenException::NOT_FOUND_ERROR, "NotFoundError");
+ }
+ else {
jsException = JSTizenExceptionFactory::makeErrorObject(data->getContext(), JSTizenException::IO_ERROR, "IO error");
}
data->callOnError(jsException);
{
if (m_connected) { return; }
- m_connection = dbus_bus_get(bus, &m_error);
+ m_connection = dbus_bus_get_private(bus, &m_error);
if (!m_connection || dbus_error_is_set(&m_error)) {
std::string message = m_error.message;
dbus_error_free(&m_error);
if (!dbus_connection_set_watch_functions(m_connection, addWatch,
removeWatch, toggleWatch, this,
NULL)) {
+ LogDebug("Couldn't set-up watch functions.");
ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Couldn't set-up watch functions.");
}
if (!dbus_connection_add_filter(m_connection, filterMessage, this, NULL)) {
- ThrowMsg(WrtDeviceApis::Commons::PlatformException,
- "Couldn't set signal handler callback.");
+ LogDebug("Couldn't set signal handler callback.");
+ ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Couldn't set signal handler callback.");
}
m_connected = true;
removeFilterInternal(*it);
}
+ dbus_connection_close(m_connection);
dbus_connection_unref(m_connection);
m_connected = false;
LogError("DBus message not set, this should not happen!");
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
-
FilterSetIterator it = this_->m_filters.begin();
for (; it != this_->m_filters.end(); ++it) {
// TODO: extend following matching procedure to check not only
// interface's name.
- if ((*it).find(msg->getInterface()) != std::string::npos) {
+ if (!msg->getInterface().empty() && ((*it).find(msg->getInterface()) != std::string::npos))
+ {
MessageEvent event(msg);
this_->EmitEvent(event);
}
virtual int getOpTypeFromOpId(int opId) = 0;
virtual IMessagePtr getMessageFromOpId(int opId) = 0;
virtual EventMessagingServicePtr getEventFromOpId(int opId) = 0;
+ virtual EventMessagingServicePtr getEventFromHandle(int handle) = 0;
virtual void setHandleToOpId(int opId, int handle) = 0;
virtual void setMessageToOpId(int opId, IMessagePtr& message) = 0;
virtual void setEventToOpId(int opId, EventMessagingServicePtr &event) = 0;
event->opId = opId;
imessagingService->setMessageToOpId(opId, event->m_message);
+ imessagingService->setEventToOpId(event->opId, event);
+ event->m_messagingService = imessagingService;
+
event->setEventType(MESSAGING_SERVICE_EVENT_TYPE_LOAD_MESSAGE_BODY);
event->setPrivateData(DPL::StaticPointerCast<WrtDeviceApis::Commons::IEventPrivateData>(privateData));
event->setForAsynchronousCall(&MessagingController::getInstance());
event->opId = opId;
imessagingService->setMessageToOpId(opId, event->m_message);
+ imessagingService->setEventToOpId(event->opId, event);
+ event->m_messagingService = imessagingService;
//JSValueRef pendingOperation = WrtDeviceApis::CommonsJavaScript::makePendingOperation(globalContext, event); //create pendingOperation.
ReqReceiverMessageSingleton::Instance().loadMessageAttachment(event); //load message Body
// TODO Copied from former solution, refactor it.
void MailSender::OnEventReceived(const DBus::MessageEvent& event)
{
- LogDebug("HERE");
+ LogDebug("enter");
NetworkStatusPtr msg(new NetworkStatus(event.GetArg0()));
int mailId = msg->getMailId();
LogDebug("status : " << msg->getStatus() << " mailId : " << mailId);
m_dbusThread(new DPL::Thread()),
m_dbus(new DBus::Connection())
{
+ LogDebug("enter");
m_dbusThread->Run();
m_dbus->setWorkerThread(m_dbusThread.Get());
const IMessagingServicePtr& messagingService = it->second.messagingService;
if (messagingService && messagingService->getAccountID() == accountId)
{
- ThrowMsg(WrtDeviceApis::Commons::PlatformException,
- "Sync: " << accountId << " already requested to be Sync Account.");
+ LogDebug("accountId is sync requested already");
+// ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Sync: " << accountId << " already requested to be Sync Account.");
}
}
return syncAccountInternal(messagingService, limit);
else
{
LogDebug("Insert sync request");
- SyncRequestData data = SyncRequestData(email_handle, MESSAGING_SERVICE_SYNC_TYPE_SYNC, messagingService);
+ SyncRequestData data = SyncRequestData(email_handle, MESSAGING_SERVICE_SYNC_TYPE_SYNC, messagingService);
m_SyncRequests.insert(std::make_pair(email_handle, data));
}
if (messagingService && messagingService->getAccountID() == accountId
&& it->second.folderId == folder_id)
{
- ThrowMsg(WrtDeviceApis::Commons::PlatformException,
- "Sync: " << accountId << " already requested to be Sync Account.");
+ LogDebug("accountId is syncFolder requested already");
+// ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Sync: " << accountId << " already requested to be Sync Account.");
}
}
if ( mail && requestReceiver )
{
EventMessagingServicePtr event = mail->getMessagingServiceEvent();
+// EventMessagingServicePtr event = messagingService->getEventFromHandle(handle);
if (status == NOTI_DOWNLOAD_ATTACH_FINISH)
{
if ( messagingService && requestReceiver)
{
- EventMessagingServicePtr event = messagingService->getMessagingServiceEvent();
+ EventMessagingServicePtr event = messagingService->getEventFromHandle(handle);
+ // get event using handle from m_opRequests;
if ( status == NOTI_DOWNLOAD_FINISH )
{
LogDebug("Sync Success");
if ( messagingService && requestReceiver)
{
- EventMessagingServicePtr event = messagingService->getMessagingServiceEvent();
+ EventMessagingServicePtr event = messagingService->getEventFromHandle(handle);
if ( status == NOTI_DOWNLOAD_FINISH )
{
LogDebug("Sync Success");
EventMessagingServiceReqReceiver* requestReceiver = mail->getRequestReceiver();
if (mail && requestReceiver) {
EventMessagingServicePtr event = mail->getMessagingServiceEvent();
+// EventMessagingServicePtr event = messagingService->getEventFromHandle(handle);
+
if ( status == NOTI_DOWNLOAD_BODY_FINISH )
{
event->m_message->readAllData();
MessageFilterValidatorFactory::ATTRIBUTE_BODY, "preview_text")); //TODO check
attributeMap.insert(
std::pair<std::string, std::string>(
- MessageFilterValidatorFactory::ATTRIBUTE_IS_READ, "mail_status")); //TODO 1:seen, 2:deleted, 4:flagged, 8:answered, 20:draft
+ MessageFilterValidatorFactory::ATTRIBUTE_IS_READ, "flags_seen_field")); //TODO 1:seen, 2:deleted, 4:flagged, 8:answered, 20:draft
attributeMap.insert(
std::pair<std::string, std::string>(
MessageFilterValidatorFactory::ATTRIBUTE_PRIORITY, "priority"));
m_query.append(getQueryFromVector());
- if(m_query.compare(getQueryPrefix())==0){
- return "";
- }else{
- if(m_sortMode != NULL){
- std::string platformAttrName = convertToEmfAttrName(m_sortMode->getAttributeName());
- std::string sortModeString;
- if(m_sortMode->getOrder() == ASCENDING_SORT_ORDER){
- sortModeString = "ASC";
- }else{
- sortModeString = "DESC";
- }
+ LogDebug("m_limit : " << m_limit << " m_offset : " << m_offset);
- buffer << " ORDER BY " << platformAttrName << " " << sortModeString;
- if(m_limit != 0){
- buffer << " LIMIT " << m_offset << "," << m_limit;
- }
+ if(m_sortMode != NULL)
+ {
+ std::string platformAttrName = convertToEmfAttrName(m_sortMode->getAttributeName());
+ std::string sortModeString;
+ if(m_sortMode->getOrder() == ASCENDING_SORT_ORDER){
+ sortModeString = "ASC";
+ }else{
+ sortModeString = "DESC";
}
+ buffer << " ORDER BY " << platformAttrName << " " << sortModeString;
+ }
+ if(m_limit != 0){
+ buffer << " LIMIT " << m_offset << "," << m_limit;
+ }
+
+ m_orderLimit.append(buffer.str());
+
+ if(m_query.compare(getQueryPrefix())==0){
+ LogDebug("m_query null");
+ return "";
+ }else{
m_query.append(getQuerySuffix());
-// m_query.append(buffer.str());
- m_orderLimit.append(buffer.str());
+ LogDebug("m_query not null");
return m_query;
}
}
vector<IMessagePtr> retVal;
std::string filterSql;
std::string orderLimitSql ="";
+ std::string emailFilterSql;
std::string typeAndString = "AND A.MAIN_TYPE=";
std::string typeString = "A.MAIN_TYPE=";
switch(type){
case EMAIL:
LogDebug("message type is EMAIL:[" << messageType <<"]");
- LogDebug("filterSql:[" << filterSql <<"]");
- retVal = queryEmailMessage(filterSql);
+ emailFilterSql = filterSql + orderLimitSql;
+ LogDebug("filterSql:[" << emailFilterSql <<"]");
+ retVal = queryEmailMessage(emailFilterSql);
break;
case SMS:
FolderType folder = msg->getCurrentFolder();
jsEvent->setMsg_Event_Type(EventMessageReceived::MSG_ADDED);
+ LogInfo("Added message is in folder: " << folder);
+
+ jsEvent->setMessage(msg);
+ jsEvent->setConversation(conversation);
+
+ if(m_onMessageReceived.size() > 0){
+ m_onMessageReceived.emit(jsEvent);
+ }
+
+ if(m_onConversationReceived.size() > 0){
+ m_onConversationReceived.emit(jsEvent);
+ }
+/*
if (OUTBOX != folder && SENTBOX != folder && DRAFTBOX != folder)
{
jsEvent->setMessage(msg);
} else {
LogWarning("New email message in ignored folder: " << folder);
}
+*/
}
else if ((mail_id > 0) && (NOTI_MAIL_DELETE == status))
{ // TODO also RECEIVE_THREAD_ITEM?
return event;
}
+EventMessagingServicePtr MessagingService::getEventFromHandle(int handle)
+{
+ LogDebug("handle index : " << handle);
+ EventMessagingServicePtr event;
+ int cnt = m_opRequests.size(); //item count.
+ LogDebug("cnt : " << cnt);
+ if (cnt > 0)
+ {
+ OpRequestsIterator it;
+ for( it = m_opRequests.begin(); it != m_opRequests.end(); ++it)
+ {
+ LogDebug("it->first : " << it->first);
+ LogDebug("it->second.handle : " << it->second.handle);
+ if((unsigned int)handle == it->second.handle)
+ {
+ LogDebug("get opId : " << it->first);
+ LogDebug("event of handle : " << it->second.handle);
+ event = it->second.event;
+ }
+ }
+ }
+ return event;
+}
+
void MessagingService::setHandleToOpId(int opIdx, int handle)
{
LogDebug("operation index : " << opIdx);
int getOpTypeFromOpId(int opId);
IMessagePtr getMessageFromOpId(int opId);
EventMessagingServicePtr getEventFromOpId(int opId);
+ EventMessagingServicePtr getEventFromHandle(int handle);
void setHandleToOpId(int opId, int handle);
void setMessageToOpId(int opId, IMessagePtr& message);
SyncNetworkStatus::SyncNetworkStatus(const DBus::MessagePtr& message)
{
- Assert(message->getInterface() == DBUS_INTERFACE_NETWORK_STATUS);
+ LogDebug("enter : " << message->getInterface());
+ Assert(message->getInterface() == DBUS_INTERFACE_NETWORK_STATUS);
initialize(message);
}
size_t dataSize; /**< Indicates the data size. The unit is byte. */
void *pData; /**< Indicates the message payload information as a body. default character encoding is UTF-8*/
void *pMmsData; /**< Indicates the message payload information as a body. default character encoding is UTF-8*/
- size_t mmsDataSize;
+// size_t mmsDataSize;
} MSG_MESSAGE_HIDDEN_S;
NFC_DETATCHED
};
-enum EventNFCSEType {
- NFC_SE_NONE,
- NFC_SE_ESE,
- NFC_SE_UICC,
- NFC_SE_INVALID
-};
-
class EventNFCChanged : public WrtDeviceApis::Commons::ListenerEvent<EventNFCChanged>
{
private:
EventNFCChangedSetPowered(bool state): powerState(state) { }
};
-class EventNFCSetCardEmulation : public EventNFCTemplate<EventNFCSetCardEmulation>
-{
-private:
- EventNFCSEType seType;
-public:
- EventNFCSEType getSEType() {return seType;}
- EventNFCSetCardEmulation(EventNFCSEType type): seType(type) { }
-};
-
-class EventNFCChangedCardEmulation : public WrtDeviceApis::Commons::ListenerEvent<EventNFCChangedCardEmulation>
-{
-private:
- EventNFCSEType seType;
-public:
- EventNFCSEType getSEType() {return seType;}
- void setSEType(EventNFCSEType type) {seType = type;}
- EventNFCChangedCardEmulation():seType(NFC_SE_NONE) { }
-};
typedef DPL::SharedPtr<EventNFCChanged> EventNFCChangedPtr;
typedef WrtDeviceApis::Commons::ListenerEventEmitter<EventNFCChanged> EventNFCChangedEmitter;
typedef DPL::SharedPtr<EventNFCChangedEmitter> EventNFCChangedEmitterPtr;
typedef DPL::SharedPtr<EventNFCChangedSetPowered> EventNFCChangedSetPoweredPtr;
-typedef DPL::SharedPtr<EventNFCSetCardEmulation> EventNFCSetCardEmulationPtr;
-typedef DPL::SharedPtr<EventNFCChangedCardEmulation> EventNFCChangedCardEmulationPtr;
-typedef WrtDeviceApis::Commons::ListenerEventEmitter<EventNFCChangedCardEmulation> EventNFCChangedCardEmulationEmitter;
-typedef DPL::SharedPtr<EventNFCChangedCardEmulationEmitter> EventNFCChangedCardEmulationEmitterPtr;
} // NFC
} // DeviceAPI
// 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.
-//\r
-\r
-\r
-#include "INFCAdapter.h"\r
-\r
-namespace DeviceAPI {\r
-namespace NFC {\r
-\r
-using namespace WrtDeviceApis::Commons;\r
-\r
-INFCAdapter::INFCAdapter() :\r
- EventNFCSetPoweredRequestReceiver(ThreadEnum::NFC_THREAD),\r
- EventNFCSetCardEmulationRequestReceiver(ThreadEnum::NFC_THREAD) {\r
-}\r
-\r
-INFCAdapter::~INFCAdapter() {\r
-}\r
-\r
-}\r
-}\r
+//
+
+
+#include "INFCAdapter.h"
+
+namespace DeviceAPI {
+namespace NFC {
+
+using namespace WrtDeviceApis::Commons;
+
+INFCAdapter::INFCAdapter() :
+ EventNFCSetPoweredRequestReceiver(ThreadEnum::NFC_THREAD) {
+}
+
+INFCAdapter::~INFCAdapter() {
+}
+
+}
+}
namespace NFC {
typedef WrtDeviceApis::Commons::EventRequestReceiver<EventNFCChangedSetPowered> EventNFCSetPoweredRequestReceiver;
-typedef WrtDeviceApis::Commons::EventRequestReceiver<EventNFCSetCardEmulation> EventNFCSetCardEmulationRequestReceiver;
class INFCAdapter :
- public EventNFCSetPoweredRequestReceiver,
- public EventNFCSetCardEmulationRequestReceiver
+ public EventNFCSetPoweredRequestReceiver
{
public:
virtual void *getCachedMessage() = 0;
virtual bool getPowerState() = 0;
virtual void setPowered(const EventNFCChangedSetPoweredPtr& event) = 0;
- virtual EventNFCSEType getSEType() = 0;
- virtual void setCardEmulation(const EventNFCSetCardEmulationPtr& event) = 0;
- virtual void setCardEmulationChangeListener(const EventNFCChangedCardEmulationEmitterPtr& event) = 0;
- virtual void unsetCardEmulationChangeListener() = 0;
protected:
INFCAdapter();
virtual void OnRequestReceived(const EventNFCChangedSetPoweredPtr& event) = 0;
- virtual void OnRequestReceived(const EventNFCSetCardEmulationPtr& event) = 0;
};
typedef DPL::SharedPtr<INFCAdapter> INFCAdapterPtr;
#define TIZEN_NFCADAPTER_ATTRIBUTENAME "NFCAdapter"
#define TIZEN_NFCADAPTER_POWERED "powered"
-#define TIZEN_NFCADAPTER_SETYPE "seType"
+
namespace DeviceAPI {
namespace NFC {
{
//NFCAdapterProperties
{TIZEN_NFCADAPTER_POWERED, getProperty, NULL, kJSPropertyAttributeReadOnly},
- {TIZEN_NFCADAPTER_SETYPE, getProperty, NULL, kJSPropertyAttributeReadOnly},
{ 0, 0, 0, 0 }
};
{"unsetPeerListener", JSNFCAdapter::unsetPeerListener, kJSPropertyAttributeNone},
{"getCachedMessage", JSNFCAdapter::getCachedMessage, kJSPropertyAttributeNone},
{"setPowered", JSNFCAdapter::setPowered, kJSPropertyAttributeNone },
- {"setCardEmulation", JSNFCAdapter::setCardEmulation, kJSPropertyAttributeNone },
- {"setCardEmulationChangeListener", JSNFCAdapter::setCardEmulationChangeListener, kJSPropertyAttributeNone },
- {"unsetCardEmulationChangeListener", JSNFCAdapter::unsetCardEmulationChangeListener, kJSPropertyAttributeNone },
{ 0, 0, 0}
};
}
INFCAdapterPtr nfcAdapter(privateObject->getObject() );
return convert.toJSValueRef(nfcAdapter->getPowerState());
- } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_NFCADAPTER_SETYPE)) {
- AceSecurityStatus status = NFC_CHECK_ACCESS(NFC_FUNCTION_API_CARDEMULATION_FUNCS);
- TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
-
- NFCAdapterPrivObject* privateObject = static_cast<NFCAdapterPrivObject*>(JSObjectGetPrivate(object));
- if (!privateObject) {
- LogError("private object is null");
- ThrowMsg(NullPointerException, "Private object not initialized");
- }
- INFCAdapterPtr nfcAdapter(privateObject->getObject() );
- return convert.toJSValueRefSEType(nfcAdapter->getSEType());
}
} Catch (NullPointerException) {
LogError("NullPointerException: " << _rethrown_exception.GetMessage());
return JSValueMakeUndefined(context);
}
-JSValueRef JSNFCAdapter::setCardEmulation (JSContextRef context, JSObjectRef object,
- JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
- JSValueRef* exception) {
- LogDebug("Enter");
-
- AceSecurityStatus status = NFC_CHECK_ACCESS(NFC_FUNCTION_API_CARDEMULATION_FUNCS);
- TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
-
- Validator validator(context, exception);
- if(argumentCount == 0) {
- /* 1st argument is mandatory. */
- LogError("TypeMismatchException!");
- return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
- }
- if ((argumentCount > 1) && !JSValueIsNull(context, arguments[1]) && !JSValueIsUndefined(context, arguments[1]) && !validator.isCallback(arguments[1])) {
- /* And 2st argument must be Callback. */
- LogError("TypeMismatchException!");
- return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
- }
- if ((argumentCount > 2) && !JSValueIsNull(context, arguments[2]) && !JSValueIsUndefined(context, arguments[2]) && !validator.isCallback(arguments[2])) {
- /* 3nd argument must be Callback. */
- LogError("TypeMismatchException!");
- return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
- }
-
- JSValueRef onSuccessForCbm = NULL, onErrorForCbm = NULL;
- if ((argumentCount > 1) && validator.isCallback(arguments[1])) {
- onSuccessForCbm = arguments[1];
- }
- if ((argumentCount > 2) && validator.isCallback(arguments[2])) {
- onErrorForCbm = arguments[2];
- }
-
- NFCAdapterPrivObject* privateObject = static_cast<NFCAdapterPrivObject*>(JSObjectGetPrivate(thisObject));
- if (!privateObject) {
- LogError("private object is null");
- return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
- }
-
- JSContextRef global_context = privateObject->getContext();
-
- INFCAdapterPtr nfcAdapter(privateObject->getObject() );
- JSCallbackManagerPtr callbackManager = JSCallbackManager::createObject(global_context, onSuccessForCbm, onErrorForCbm, true, true);
-
- Try {
- NFCConverter nfcConverter(context);
- EventNFCSEType seType = NFC_SE_INVALID;
- seType = nfcConverter.toSEType(arguments[0]);
-
- EventNFCSetCardEmulationPtr event(new EventNFCSetCardEmulation(seType));
- event->setPrivateData( StaticPointerCast<IEventPrivateData>(callbackManager) );
- event->setForAsynchronousCall(&NFCStaticController::getInstance());
- nfcAdapter->setCardEmulation(event);
- NFCAsyncCallbackManagerSingleton::Instance().registerCallbackManager(callbackManager, global_context);
- return JSValueMakeUndefined(context);
- } Catch (ConversionException) {
- LogError("ConversionException");
- return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
- } Catch (PlatformException) {
- LogError("PlatformException: " << _rethrown_exception.GetMessage());
- callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::SERVICE_NOT_AVAILABLE, "Service Not Available"));
- return JSValueMakeUndefined(context);
- } Catch (UnknownException) {
- LogError("UnknownException: " << _rethrown_exception.GetMessage());
- } Catch(NullPointerException) {
- LogError("Exception: " << _rethrown_exception.GetMessage());
- return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
- } Catch (WrtDeviceApis::Commons::Exception) {
- LogError("Exception: " << _rethrown_exception.GetMessage());
- }
- callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR,"Unknown Error"));
- return JSValueMakeUndefined(context);
-}
-
-JSValueRef JSNFCAdapter::setCardEmulationChangeListener (JSContextRef context, JSObjectRef object,
- JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
- JSValueRef* exception) {
- LogDebug("Entered ");
-
- AceSecurityStatus status = NFC_CHECK_ACCESS(NFC_FUNCTION_API_CARDEMULATION_FUNCS);
- TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
-
- Validator validator(context, exception);
-
- if ((argumentCount < 1) || JSValueIsNull(context, arguments[0]) || JSValueIsUndefined(context, arguments[0]) || !validator.isCallback(arguments[0])) {
- /* 1st argument is mandatory. And 1st argument must be Callback. */
- LogError("TypeMismatchException!");
- return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
- }
-
- JSValueRef onSuccessForCbm = NULL;
- if (validator.isCallback(arguments[0])) {
- onSuccessForCbm = arguments[0];
- }
-
- NFCAdapterPrivObject* privateObject = static_cast<NFCAdapterPrivObject*>(JSObjectGetPrivate(thisObject));
- if (!privateObject) {
- LogError("private object is null");
- return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
- }
-
- JSContextRef global_context = privateObject->getContext();
-
- INFCAdapterPtr nfcAdapter(privateObject->getObject() );
- JSCallbackManagerPtr callbackManager = JSCallbackManager::createObject(global_context, onSuccessForCbm, NULL, true, true);
-
- Try {
- EventNFCChangedCardEmulationEmitterPtr emitter(new EventNFCChangedCardEmulationEmitter);
- emitter->setListener(&NFCStaticController::getInstance());
- emitter->setEventPrivateData(StaticPointerCast<EventNFCChangedCardEmulation::PrivateDataType>(callbackManager));
- nfcAdapter->setCardEmulationChangeListener(emitter);
-
- NFCListenerCancellerPtr canceller = NFCListenerCancellerPtr(new NFCListenerCanceller(global_context, thisObject, static_cast<long>(ID_NFCADAPTER_CARDEMULATION_LISTENER)));
- IListenerItemPtr listenerItem = StaticPointerCast<IListenerItem>(canceller);
- NFCListenerManagerSingleton::Instance().registerListener(listenerItem, global_context);
-
- return JSValueMakeUndefined(context);
- } Catch (ConversionException) {
- LogError("ConversionException");
- return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
- } Catch (PlatformException) {
- LogError("PlatformException: " << _rethrown_exception.GetMessage());
- return JSTizenExceptionFactory::postException(context, exception, JSTizenException::SERVICE_NOT_AVAILABLE, "Service Not Available");
- } Catch (UnknownException) {
- LogError("UnknownException: " << _rethrown_exception.GetMessage());
- } Catch (WrtDeviceApis::Commons::Exception) {
- LogError("Exception: " << _rethrown_exception.GetMessage());
- }
-
- return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
-}
-
-JSValueRef JSNFCAdapter::unsetCardEmulationChangeListener(JSContextRef context, JSObjectRef object, JSObjectRef thisObject,
- size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) {
- LogDebug("JSNFCAdapter::unsetPeerListener Enter");
-
- AceSecurityStatus status = NFC_CHECK_ACCESS(NFC_FUNCTION_API_CARDEMULATION_FUNCS);
- TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
-
- NFCAdapterPrivObject* privateObject = static_cast<NFCAdapterPrivObject*>(JSObjectGetPrivate(thisObject));
- if (!privateObject) {
- LogError("private object is null");
- return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
- }
-
- Try {
- INFCAdapterPtr nfcAdapter(privateObject->getObject());
- nfcAdapter->unsetCardEmulationChangeListener();
-
- NFCListenerCancellerPtr canceller = NFCListenerCancellerPtr(new NFCListenerCanceller(privateObject->getContext(), thisObject, ID_NFCADAPTER_CARDEMULATION_LISTENER));
- IListenerItemPtr listenerItem = StaticPointerCast<IListenerItem>(canceller);
- NFCListenerManagerSingleton::Instance().unregisterListener(listenerItem);
-
- return JSValueMakeUndefined(context);
- } Catch (ConversionException) {
- LogError("ConversionException");
- return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
- } Catch (NullPointerException) {
- return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
- } Catch (PlatformException) {
- LogError("PlatformException: " << _rethrown_exception.GetMessage());
- return JSTizenExceptionFactory::postException(context, exception, JSTizenException::SERVICE_NOT_AVAILABLE, "Service Not Available");
- } Catch (WrtDeviceApis::Commons::Exception) {
- LogError("Exception: " << _rethrown_exception.GetMessage());
- }
- return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
-}
-
}
}
size_t argumentCount,
const JSValueRef arguments[],
JSValueRef* exception);
-
- static JSValueRef setCardEmulation(JSContextRef context,
- JSObjectRef object,
- JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception);
-
- static JSValueRef setCardEmulationChangeListener(JSContextRef context,
- JSObjectRef object,
- JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception);
-
- static JSValueRef unsetCardEmulationChangeListener(JSContextRef context,
- JSObjectRef object,
- JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception);
};
}
m_NFCTargetEmitterPtr.Reset();
m_tagFilter.Reset();
m_EventNFCChangedSetPoweredPtr.Reset();
- m_eventNFCSetCardEmulationPtr.Reset();
- m_NFCChangedCardEmulations.Reset();
}
NFCAdapter::~NFCAdapter() {
unsetTagListener();
unsetPeerListener();
m_EventNFCChangedSetPoweredPtr.Reset();
- m_eventNFCSetCardEmulationPtr.Reset();
- unsetCardEmulationChangeListener();
}
int NFCAdapter::setTagListener(const EventNFCChangedEmitterPtr& emitter, const TagFilterPtr& filter) {
}
}
-EventNFCSEType NFCAdapter::getSEType() {
- return NFCDefaultAdapterSingleton::Instance().getSEType();
-}
-
-void NFCAdapter::setCardEmulation(const EventNFCSetCardEmulationPtr& event) {
- LogDebug("Enter");
- EventRequestReceiver<EventNFCSetCardEmulation>::PostRequest(event);
-}
-
-void NFCAdapter::OnRequestReceived(const EventNFCSetCardEmulationPtr& event) {
- if (getSEType() == event->getSEType()) {
- event->setResult(true);
- return;
- }
- if (m_eventNFCSetCardEmulationPtr.Get() !=NULL) {
- event->setResult(false);
- event->setError(DeviceAPI::Common::JSTizenException::SERVICE_NOT_AVAILABLE);
- event->setErrorMessage("Progressing Identical Operation");
- return;
- }
-
- event->switchToManualAnswer();
- m_eventNFCSetCardEmulationPtr = event;
- Try {
- NFCDefaultAdapterSingleton::Instance().setCardEmulation(event->getSEType(), this);
- return;
- } Catch(PlatformException) {
- LogError("Exception: " << _rethrown_exception.GetMessage());
- event->setResult(false);
- event->setError(DeviceAPI::Common::JSTizenException::SERVICE_NOT_AVAILABLE);
- event->setErrorMessage("Progressing Identical Operation");
- EventRequestReceiver<EventNFCSetCardEmulation>::ManualAnswer(event);
- } Catch(WrtDeviceApis::Commons::Exception) {
- LogError("Exception: " << _rethrown_exception.GetMessage());
- setCardEmulationManualAnswer(NFC_ERROR_OPERATION_FAILED);
- }
-}
-
-void NFCAdapter::setCardEmulationManualAnswer(int error) {
- if (m_eventNFCSetCardEmulationPtr.Get() != NULL) {
- if (error == NFC_ERROR_NONE) {
- m_eventNFCSetCardEmulationPtr->setResult(true);
- } else {
- NFCUtil util;
- m_eventNFCSetCardEmulationPtr->setResult(false);
- if (error == NFC_ERROR_INVALID_PARAMETER) {
- m_eventNFCSetCardEmulationPtr->setError(DeviceAPI::Common::JSTizenException::NOT_FOUND_ERROR);
- m_eventNFCSetCardEmulationPtr->setErrorMessage("Not Found Error");
- } else {
- m_eventNFCSetCardEmulationPtr->setError(util.getNFCErrorString(error));
- m_eventNFCSetCardEmulationPtr->setErrorMessage(util.getNFCErrorMessage(error));
- }
- }
- EventRequestReceiver<EventNFCSetCardEmulation>::ManualAnswer(m_eventNFCSetCardEmulationPtr);
- m_eventNFCSetCardEmulationPtr.Reset();
- }
-}
-
-void NFCAdapter::setCardEmulationChangeListener(const EventNFCChangedCardEmulationEmitterPtr& emitter) {
- LogDebug("Entered");
-
- if (m_NFCChangedCardEmulations.Get() != NULL)
- ThrowMsg(PlatformException, "It has already set Card Emulation Change Listener");
-
- m_NFCChangedCardEmulations = emitter;
-
- NFCDefaultAdapterSingleton::Instance().setCardEmulationChangeListener(this);
-}
-
-void NFCAdapter::seChanged(EventNFCSEType seType) {
- if (m_NFCChangedCardEmulations.Get() != NULL) {
- EventNFCChangedCardEmulationPtr event(new EventNFCChangedCardEmulation());
- event->setSEType(seType);
- LogDebug("emit event with seChanged(type:" << seType << ")");
- m_NFCChangedCardEmulations->emit(event);
- }
-}
-void NFCAdapter::unsetCardEmulationChangeListener() {
- m_NFCChangedCardEmulations.Reset();
- NFCDefaultAdapterSingleton::Instance().unsetCardEmulationChangeListener(this);
-}
-
}
}
virtual bool getPowerState();
virtual void setPowered(const EventNFCChangedSetPoweredPtr& event);
void setPoweredManualAnswer(int error);
-
- virtual EventNFCSEType getSEType();
- virtual void setCardEmulation(const EventNFCSetCardEmulationPtr& event);
- void setCardEmulationManualAnswer(int error);
-
- virtual void setCardEmulationChangeListener(const EventNFCChangedCardEmulationEmitterPtr& event);
- void seChanged(EventNFCSEType seType);
- virtual void unsetCardEmulationChangeListener();
private:
EventNFCChangedEmitterPtr m_NFCTagEmitterPtr;
EventNFCChangedEmitterPtr m_NFCTargetEmitterPtr;
EventNFCChangedSetPoweredPtr m_EventNFCChangedSetPoweredPtr;
- EventNFCSetCardEmulationPtr m_eventNFCSetCardEmulationPtr;
- EventNFCChangedCardEmulationEmitterPtr m_NFCChangedCardEmulations;
TagFilterPtr m_tagFilter;
protected:
virtual void OnRequestReceived(const EventNFCChangedSetPoweredPtr& event);
- virtual void OnRequestReceived(const EventNFCSetCardEmulationPtr& event);
};
}
return result;
}
-EventNFCSEType NFCConverter::toSEType(JSValueRef arg) {
- std::string seType = toString(arg);
- if (seType == "NONE")
- return NFC_SE_NONE;
- else if (seType == "ESE")
- return NFC_SE_ESE;
- else if (seType == "UICC")
- return NFC_SE_UICC;
- else
- ThrowMsg(Commons::ConversionException, "No Match SE Type");
-}
-
-JSValueRef NFCConverter::toJSValueRefSEType(EventNFCSEType type) {
- if (type == NFC_SE_NONE)
- return toJSValueRef("NONE");
- else if (type == NFC_SE_ESE)
- return toJSValueRef("ESE");
- else if (type == NFC_SE_UICC)
- return toJSValueRef("UICC");
- else
- ThrowMsg(Commons::ConversionException, "No Match SE Type");
-}
-
}
}
void *getRecordHandle(const JSValueRef& arg);
void *getMessageHandle(const JSValueRef& arg);
NFCChangedCallback toNFCChangedCallback(const JSValueRef& arg);
- EventNFCSEType toSEType(JSValueRef arg);
- JSValueRef toJSValueRefSEType(EventNFCSEType type);
private:
bool initializeAllowedProperties();
static std::vector<std::string> m_allowedTagFilterProperties;
LogDebug("Callback NFCSetActivationCompletedCallback.");
NFCDefaultAdapterSingleton::Instance().setPoweredManualAnswer(error);
}
- static void NFCSetCardEmulationCompletedCallback(nfc_error_e error, void *user_data) {
- LogDebug("Callback NFCSetActivationCompletedCallback.");
- NFCDefaultAdapterSingleton::Instance().setCardEmulationManualAnswer(error, user_data);
- }
- static void NFCSetSEEventCallback(nfc_se_event_e event, void *user_data) {
- LogDebug("Callback NFCSetSEEventCallback.");
- if (event == NFC_SE_EVENT_SE_TYPE_CHANGED)
- NFCDefaultAdapterSingleton::Instance().seChanged();
- }
+
}//private namespace
NFCDefaultAdapter::NFCDefaultAdapter()
m_NFCTagListeners.clear();
m_NFCTargetListeners.clear();
- m_NFCChangedSETypes.clear();
m_poweredAdapter = NULL;
- m_seType = NFC_SE_INVALID;
}
NFCDefaultAdapter::~NFCDefaultAdapter() {
}
}
-EventNFCSEType NFCDefaultAdapter::getSEType() {
- LogDebug("Enter");
- nfc_se_type_e type = NFC_SE_TYPE_DISABLE;
- if (nfc_manager_get_card_emulation_se_type(&type) == NFC_ERROR_NONE) {
- NFCUtil util;
- if (util.convertTonfcSEType(type) != NFC_SE_INVALID)
- return util.convertTonfcSEType(type);
- }
- ThrowMsg(PlatformException, "Wrong SE Type or operation to get SE Type is failed");
-}
-
-void NFCDefaultAdapter::setCardEmulation(const EventNFCSEType seType, NFCAdapter * adapter) {
- LogDebug("Enter");
- try {
- if (getSEType() == seType) {
- adapter->setCardEmulationManualAnswer(NFC_ERROR_NONE);
- seChanged();
- return;
- }
-
- nfc_se_type_e nfcSeType = NFC_SE_TYPE_DISABLE;
- if (seType == NFC_SE_NONE)
- nfcSeType = NFC_SE_TYPE_DISABLE;
- else if (seType == NFC_SE_ESE)
- nfcSeType = NFC_SE_TYPE_ESE;
- else if (seType == NFC_SE_UICC)
- nfcSeType = NFC_SE_TYPE_UICC;
- else
- ThrowMsg(PlatformException, "Wrong SE TYPE");
-
- int result = NFC_ERROR_NONE;
- if (!m_initialized)
- result = initialize();
-
- if (result == NFC_ERROR_NONE) {
- result = nfc_manager_set_card_emulation_se_type(nfcSeType, NFCSetCardEmulationCompletedCallback, (void *)adapter);
- }
-
- if (result != NFC_ERROR_NONE)
- adapter->setCardEmulationManualAnswer(result);
- } catch (const WrtDeviceApis::Commons::Exception& ex) {
- LogError("Exception: " << ex.GetMessage());
- adapter->setCardEmulationManualAnswer(NFC_ERROR_OPERATION_FAILED);
- }
-}
-
-void NFCDefaultAdapter::setCardEmulationManualAnswer(int error, void *adapter) {
- if (adapter != NULL) {
- ((NFCAdapter *)adapter)->setCardEmulationManualAnswer(error);
- if (error == NFC_ERROR_NONE)
- seChanged();
- }
-}
-
-void NFCDefaultAdapter::setCardEmulationChangeListener(NFCAdapter *adapter) {
- LogDebug("Entered");
- int result = -1;
-
- m_NFCChangedSETypes.push_back(adapter);
-
- if (!m_initialized) {
- if (initialize() != NFC_ERROR_NONE) {
- m_NFCChangedSETypes.clear();
- ThrowMsg(PlatformException, "Could not initialize NFC.");
- }
- }
- if (m_NFCChangedSETypes.size() > 1)
- return;
-
- m_seType = getSEType();
- result = nfc_manager_set_se_event_cb(NFCSetSEEventCallback, this);
-
- NFCUtil util;
- if (result != NFC_ERROR_NONE) {
- m_NFCTargetListeners.pop_back();
- util.throwNFCException(result, "failed to set callback of nfc_manager_set_p2p_target_discovered_cb");
- }
-
- LogInfo("NFCDefaultAdapter::setPeerListener : result << " << result);
-}
-
-void NFCDefaultAdapter::unsetCardEmulationChangeListener(NFCAdapter * adapter) {
- LogDebug("Entered");
-
- if (!m_initialized) {
- if (initialize() != NFC_ERROR_NONE) {
- ThrowMsg(PlatformException, "Could not initialize NFC.");
- }
- }
-
- std::vector<NFCAdapter *>::iterator it;
- for (it = m_NFCChangedSETypes.begin(); it != m_NFCChangedSETypes.end(); ++it) {
- if (*it == adapter) {
- m_NFCChangedSETypes.erase(it);
- LogDebug("emitter is removed. (" << m_NFCChangedSETypes.size() << ")");
- break;
- }
- }
-
- if (m_NFCChangedSETypes.empty()) {
- nfc_manager_unset_se_event_cb();
- m_seType = NFC_SE_INVALID;
- }
-}
-
-void NFCDefaultAdapter::seChanged() {
- if (m_seType != NFC_SE_INVALID) {
- if (m_seType != getSEType()) {
- m_seType = getSEType();
- std::vector<NFCAdapter *>::iterator it;
- for (it = m_NFCChangedSETypes.begin(); it != m_NFCChangedSETypes.end(); ++it) {
- (*it)->seChanged(m_seType);
- }
- }
- }
-}
}
}
void setPowered(const bool state, NFCAdapter * adapter);
void setPoweredManualAnswer(int error);
- EventNFCSEType getSEType();
- void setCardEmulation(const EventNFCSEType seType, NFCAdapter * adapter);
- void setCardEmulationManualAnswer(int error, void *adapter);
-
- void setCardEmulationChangeListener(NFCAdapter *adapter);
- void seChanged();
- void unsetCardEmulationChangeListener(NFCAdapter * adapter);
-
bool isSupported();
void deinitialze();
private:
std::vector<NFCAdapter *> m_NFCTagListeners;
std::vector<NFCAdapter *> m_NFCTargetListeners;
- std::vector<NFCAdapter *> m_NFCChangedSETypes;
NFCAdapter * m_poweredAdapter;
bool m_initialized;
- EventNFCSEType m_seType;
friend class DPL::Singleton<NFCDefaultAdapter>;
ID_NFCADAPTER_TAG_LISTENER = 1,
ID_NFCADAPTER_PEER_LISTENER,
ID_NFCPEER_RECEIVENDEF_LISTENER,
- ID_NFCADAPTER_CARDEMULATION_LISTENER
};
class NFCListenerManager : public DeviceAPI::Common::IListenerController
}
break;
}
- case ID_NFCADAPTER_CARDEMULATION_LISTENER:
- {
- NFCAdapterPrivObject* privateObject = static_cast<NFCAdapterPrivObject*>(JSObjectGetPrivate(m_object));
- if (NULL == privateObject) {
- LogError("Object has no privateObject");
- return;
- }
- Try {
- INFCAdapterPtr nfcAdapter( privateObject->getObject());
- nfcAdapter->unsetCardEmulationChangeListener();
- } Catch(WrtDeviceApis::Commons::Exception) {
- LogError("Error on platform : " << _rethrown_exception.GetMessage());
- }
- break;
- }
+
default:
LogError("Wrong ID");
}
NFCStaticController::NFCStaticController() :
EventNFCChangedListener(ThreadEnum::NULL_THREAD),
- setPoweredAnswerReceiver(ThreadEnum::NULL_THREAD),
- setCardEmulationAnswerReceiver(ThreadEnum::NULL_THREAD),
- EventNFCChangedCardEmulationListener(ThreadEnum::NULL_THREAD) {
+ setPoweredAnswerReceiver(ThreadEnum::NULL_THREAD) {
}
void NFCStaticController::onAnswerReceived(const EventNFCChangedPtr& event) {
}
}
-void NFCStaticController::OnAnswerReceived(const EventNFCSetCardEmulationPtr &event)
-{
- JSCallbackManagerPtr cbm =
- DPL::StaticPointerCast<JSCallbackManager>(event->getPrivateData());
-
- Try {
- if (!cbm) {
- LogDebug("no callback manager");
- return;
- }
- NFCAsyncCallbackManagerSingleton::Instance().unregisterCallbackManager(cbm);
- if (event->getResult()) {
- LogDebug("result success");
- cbm->callOnSuccess();
- return;
- }
- LogDebug("result fail");
- std::string error = event->getError();
- std::string errorMessage = event->getErrorMessage();
- JSValueRef errorObject;
- if (error != "") {
- if (errorMessage != "")
- errorObject = JSTizenExceptionFactory::makeErrorObject(cbm->getContext(), error, errorMessage);
- else
- errorObject = JSTizenExceptionFactory::makeErrorObject(cbm->getContext(), error, error);
- } else
- errorObject = JSTizenExceptionFactory::makeErrorObject(cbm->getContext(), JSTizenException::UNKNOWN_ERROR,"Unknown Error");
- cbm->callOnError(errorObject);
- } Catch (PlatformException) {
- LogError("PlatformException" << _rethrown_exception.GetMessage());
- JSValueRef errorObject = JSTizenExceptionFactory::makeErrorObject(cbm->getContext(), JSTizenException::SERVICE_NOT_AVAILABLE,"Service Not Available");
- cbm->callOnError(errorObject);
- } Catch (UnknownException) {
- LogError("UnknownException" << _rethrown_exception.GetMessage());
- JSValueRef errorObject = JSTizenExceptionFactory::makeErrorObject(cbm->getContext(), JSTizenException::UNKNOWN_ERROR,"Unknown Error");
- cbm->callOnError(errorObject);
- } Catch (Exception) {
- LogError("Exception: " << _rethrown_exception.GetMessage());
- JSValueRef errorObject = JSTizenExceptionFactory::makeErrorObject(cbm->getContext(), JSTizenException::UNKNOWN_ERROR,"Unknown Error");
- cbm->callOnError(errorObject);
- }
-}
-
-void NFCStaticController::onAnswerReceived(const EventNFCChangedCardEmulationPtr& event) {
- LogDebug("Enter");
-
- Try {
- JSCallbackManagerPtr cbm =
- DPL::StaticPointerCast<JSCallbackManager>(event->getPrivateData());
- EventNFCSEType seType = event->getSEType();
-
- if (seType != NFC_SE_INVALID) {
- JSContextRef context = cbm->getContext();
- LogDebug("callOnSuccess");
- NFCConverter converter(context);
- cbm->callOnSuccess(converter.toJSValueRefSEType(seType));
- }
- } Catch (ConversionException) {
- LogError("Conversion exception while processing EventNFCChanged");
- } Catch (PlatformException) {
- LogError("PlatformException:Platform can't create NFCTag" << _rethrown_exception.GetMessage());
- } Catch (UnknownException) {
- LogError("UnknownException:Platform can't create NFCTag" << _rethrown_exception.GetMessage());
- } Catch (NullPointerException) {
- LogError("NullPointer exception while processing EventNFCChanged");
- }
-
-}
-
} // NFC
} // DeviceAPI
using namespace WrtDeviceApis::Commons;
typedef EventListener<EventNFCChanged> EventNFCChangedListener;
typedef EventAnswerReceiver<EventNFCChangedSetPowered> setPoweredAnswerReceiver;
-typedef EventAnswerReceiver<EventNFCSetCardEmulation> setCardEmulationAnswerReceiver;
-typedef EventListener<EventNFCChangedCardEmulation> EventNFCChangedCardEmulationListener;
+
class NFCStaticController :
public EventNFCChangedListener,
- public setPoweredAnswerReceiver,
- public setCardEmulationAnswerReceiver,
- public EventNFCChangedCardEmulationListener
+ public setPoweredAnswerReceiver
{
public:
static NFCStaticController& getInstance();
void onAnswerReceived(const EventNFCChangedPtr& event);
void OnAnswerReceived(const EventNFCChangedSetPoweredPtr &event);
- void OnAnswerReceived(const EventNFCSetCardEmulationPtr &event);
- void onAnswerReceived(const EventNFCChangedCardEmulationPtr& event);
+
protected:
NFCStaticController();
};
}
}
-EventNFCSEType NFCUtil::convertTonfcSEType(unsigned short type) {
- switch (static_cast<nfc_se_type_e>(type)) {
- case NFC_SE_TYPE_DISABLE:
- return NFC_SE_NONE;
- case NFC_SE_TYPE_ESE:
- return NFC_SE_ESE;
- case NFC_SE_TYPE_UICC:
- return NFC_SE_UICC;
- default:
- LogDebug("Wrong SE Type : " << type);
- return NFC_SE_INVALID;
- }
-}
NdefRecordData NFCUtil::getNDEFRecordData(void *handle) {
nfc_ndef_record_h recordHandle = static_cast<nfc_ndef_record_h>(handle);
nfcTagType convertTonfcTagType(const unsigned short type);
unsigned short convertToTNF(nfcTNF tnf);
nfcTNF convertTonfcTNF(unsigned short tnf);
- EventNFCSEType convertTonfcSEType(unsigned short type);
NdefRecordData getNDEFRecordData(void *handle);
bool copyNDEFRecord(void **src, void **dest);
bool copyNDEFMessage(void **src, void **dest);
std::string networkType = converter.toString(arguments[0]);
std::string domainName = converter.toString(arguments[1]);
if (strcmp(networkType.c_str(), "CELLULAR") != 0) {
- return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid values error");
+ return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error");
}
callbackManager->setOnSuccess(onsuccess);
}
NotificationLine::NotificationLine(notification_h noti, int index, std::string &info, std::string &subInfo):
-m_notiHandle(noti),
-m_index(index),
m_info(info),
-m_subInfo(subInfo)
+m_subInfo(subInfo),
+m_notiHandle(noti),
+m_index(index)
{
LogDebug("create by notification with data" );
}
#endif
StatusNotification::StatusNotification(NotificationType statusType) :
- m_notiHandle(NULL),
m_service(NULL),
+ m_notiHandle(NULL),
m_lines(NULL)
{
notification_type_e type = NOTIFICATION_TYPE_NONE;
LogDebug("noti =" << noti);
setNotificationHandle((void*)noti);
setNotificationState(NOTI_STATE_CREATED);
+ if ( statusType == NOTI_TYPE_PROGRESS)
+ {
+ notification_update_progress(noti, NOTIFICATION_PRIV_ID_NONE, getProgressValue());
+ }
}
m_lines = NotificationLineArrayPtr(new NotificationLineArray());
m_thumbs = StringArrayPtr(new StringArray());
}
StatusNotification::StatusNotification(void* noti) :
- m_notiHandle(NULL),
m_service(NULL),
+ m_notiHandle(NULL),
m_lines(NULL)
{
LogDebug("noti : " << noti);
setNotificationLines();
setNotificationState(NOTI_STATE_CREATED);
+ if ( type == NOTI_TYPE_PROGRESS)
+ {
+ notification_update_progress(notification, NOTIFICATION_PRIV_ID_NONE, getProgressValue());
+ }
+
//service
bundle *bSvc = NULL;
ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service creation error");
}
-#if 0
- const char *tmpStr = NULL;
- if(m_service == NULL && service_create(&m_service) != SERVICE_ERROR_NONE)
- {
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service creation error");
- }
-
- tmpStr = appsvc_get_operation(bSvc);
- if (tmpStr)
- {
- LogDebug("operation = " << tmpStr);
- if (tmpStr)
- {
- if (service_set_operation(m_service, tmpStr) != SERVICE_ERROR_NONE)
- {
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service set operation error");
- }
- }
- else if (service_set_operation(m_service, SERVICE_OPERATION_DEFAULT) != SERVICE_ERROR_NONE)
- {
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service set operation error");
- }
- tmpStr = NULL;
- }
-
- else
- {
- if (service_set_operation(m_service, SERVICE_OPERATION_DEFAULT) != SERVICE_ERROR_NONE)
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service set operation error");
- }
-
- tmpStr = appsvc_get_uri(bSvc);
- if (tmpStr)
- {
- LogDebug("uri = " << tmpStr);
- if (service_set_uri(m_service, tmpStr) != SERVICE_ERROR_NONE)
- {
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service set uri error");
- }
- tmpStr = NULL;
- }
-
- tmpStr = appsvc_get_mime(bSvc);
- if(tmpStr)
- {
- LogDebug("mime = " << tmpStr);
- if (service_set_mime(m_service, tmpStr) != SERVICE_ERROR_NONE)
- {
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service set mime error");
- }
- tmpStr = NULL;
- }
-
- tmpStr = appsvc_get_category(bSvc);
- if(tmpStr)
- {
- LogDebug("category = " << tmpStr);
- if (service_set_category(m_service, tmpStr) != SERVICE_ERROR_NONE)
- {
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service set category error");
- }
- tmpStr = NULL;
- }
-
- //extra option
- bundle_foreach(bSvc, service_bundle_iterator, m_service);
-#endif
bundle_free(bSvc); //bundle free
}
}
}
StatusNotification::StatusNotification(int privID) :
- m_notiHandle(NULL),
m_service(NULL),
+ m_notiHandle(NULL),
m_lines(NULL)
{
LogDebug("priv ID : " << privID);
DeviceAPI::Application::ApplicationControlPtr StatusNotification::getApplicationControl()
{
service_h service = NULL;
- int retcode = 0;
char *tempStr = NULL;
DeviceAPI::Application::ApplicationControlPtr appControl(new DeviceAPI::Application::ApplicationControl());
}
std::vector<DeviceAPI::Application::ApplicationControlDataPtr> appControlDataArray = appControl->getAppControlDataArray();
- size_t index = 0, indexArray = 0;
+ size_t index = 0;
LogDebug (" App Control Datas Count : " << appControlDataArray.size());
void StatusNotification::setApplicationId(const std::string& appId)
{
- int retcode = 0;
LogDebug("m_service = " << m_service << " appId = " << appId);
if (!m_service)
{
SET(SRCS
plugin_initializer.cpp
+ plugin_config.cpp
)
ADD_LIBRARY(${TARGET_NAME} SHARED ${SRCS})
{
protected:
bool result;
- std::string errorCode;
+ std::string errorName;
+ std::string errorMessage;
public:
void setResult(const bool value) {result = value;}
bool getResult() const {return result;}
- void setError(const std::string &error) { errorCode= error;}
- std::string getError() {return errorCode;}
+ void setError(const std::string &error) { errorName = error;}
+ std::string getError() {return errorName;}
+ void setErrorMessage(const std::string &message) { errorMessage= message;}
+ std::string getErrorMessage() {return errorMessage;}
EventSETemplate() :result(true) { }
};
#include "JSSEChannel.h"
#include "SEAsyncCallbackManager.h"
#include "SEConverter.h"
+#include "plugin_config.h"
using namespace DeviceAPI::Common;
using namespace WrtDeviceApis::Commons;
{
LogDebug("Entered ");
+ AceSecurityStatus status = SECURE_ELEMENT_CHECK_ACCESS(SECUREELEMENT_FUNCTION_API_FUNCS);
+ TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+
SEChannelPrivObject* privateObject = static_cast<SEChannelPrivObject*>(JSObjectGetPrivate(thisObject));
if (NULL == privateObject) {
LogError("private object is null");
return JSValueMakeUndefined(context);
} Catch (UnknownException) {
LogError("Exception: " << _rethrown_exception.GetMessage());
- } Catch (PlatformException) {
- LogError("Exception: " << _rethrown_exception.GetMessage());
- return JSTizenExceptionFactory::postException(context, exception, JSTizenException::SERVICE_NOT_AVAILABLE, "Service Not Available");
} Catch (WrtDeviceApis::Commons::Exception) {
LogError("Exception: " << _rethrown_exception.GetMessage());
}
{
LogDebug("Entered ");
+ AceSecurityStatus status = SECURE_ELEMENT_CHECK_ACCESS(SECUREELEMENT_FUNCTION_API_FUNCS);
+ TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+
Validator validator(context, exception);
if ((argumentCount < 2) || JSValueIsNull(context, arguments[0]) || JSValueIsUndefined(context, arguments[0]) || !JSIsArrayValue(context, arguments[0])) {
} Catch (ConversionException) {
LogError("ConversionException: " << _rethrown_exception.GetMessage());
return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
- } Catch (InvalidArgumentException) {
- LogError("InvalidArgumentException: " << _rethrown_exception.GetMessage());
- callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values"));
- return JSValueMakeUndefined(context);
- } Catch (PlatformException) {
- LogError("PlatformException: " << _rethrown_exception.GetMessage());
- callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::SERVICE_NOT_AVAILABLE, "Service Not Available"));
- return JSValueMakeUndefined(context);
} Catch (UnknownException) {
LogError("UnknownException: " << _rethrown_exception.GetMessage());
} Catch (WrtDeviceApis::Commons::Exception) {
#include "SEResponseDispatcher.h"
#include "JSSEReader.h"
#include "SEAsyncCallbackManager.h"
-
+#include "plugin_config.h"
using namespace DeviceAPI::Common;
using namespace WrtDeviceApis::Commons;
JSValueRef* exception)
{
LogDebug("Entered ");
+
+ AceSecurityStatus status = SECURE_ELEMENT_CHECK_ACCESS(SECUREELEMENT_FUNCTION_API_FUNCS);
+ TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+
SEReaderPrivObject* privateObject = static_cast<SEReaderPrivObject*>(JSObjectGetPrivate(thisObject));
if (NULL == privateObject) {
LogError("private object is null");
{
LogDebug("Entered ");
+ AceSecurityStatus status = SECURE_ELEMENT_CHECK_ACCESS(SECUREELEMENT_FUNCTION_API_FUNCS);
+ TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+
Validator validator(context, exception);
if ((argumentCount < 1) || JSValueIsNull(context, arguments[0]) || JSValueIsUndefined(context, arguments[0]) || !validator.isCallback(arguments[0])) {
} Catch (ConversionException) {
LogError("ConversionException");
return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
- } Catch (InvalidArgumentException) {
- LogError("InvalidArgumentException");
- callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values"));
- return JSValueMakeUndefined(context);
- } Catch (PlatformException) {
- LogError("PlatformException: " << _rethrown_exception.GetMessage());
- callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::SERVICE_NOT_AVAILABLE, "Service Not Available"));
- return JSValueMakeUndefined(context);
} Catch (UnknownException) {
LogError("UnknownException: " << _rethrown_exception.GetMessage());
} Catch (WrtDeviceApis::Commons::Exception) {
JSValueRef* exception)
{
LogDebug("Entered ");
+
+ AceSecurityStatus status = SECURE_ELEMENT_CHECK_ACCESS(SECUREELEMENT_FUNCTION_API_FUNCS);
+ TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+
SEReaderPrivObject* privateObject = static_cast<SEReaderPrivObject*>(JSObjectGetPrivate(thisObject));
if (NULL == privateObject) {
LogError("private object is null");
#include "SEAsyncCallbackManager.h"
#include "SEListenerManager.h"
#include "SEConverter.h"
-
+#include "plugin_config.h"
using namespace DeviceAPI::Common;
using namespace WrtDeviceApis::Commons;
Validator validator(context, exception);
+ AceSecurityStatus status = SECURE_ELEMENT_CHECK_ACCESS(SECUREELEMENT_FUNCTION_API_FUNCS);
+ TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+
if ((argumentCount < 1) || JSValueIsNull(context, arguments[0]) || JSValueIsUndefined(context, arguments[0]) || !validator.isCallback(arguments[0])) {
/* 1st argument is mandatory. And 1st argument must be Callback. */
LogError("TypeMismatchException!");
} Catch (ConversionException) {
LogError("ConversionException");
return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
- } Catch (InvalidArgumentException) {
- LogError("InvalidArgumentException");
- callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values"));
- return JSValueMakeUndefined(context);
- } Catch (PlatformException) {
- LogError("PlatformException: " << _rethrown_exception.GetMessage());
- callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::SERVICE_NOT_AVAILABLE, "Service Not Available"));
- return JSValueMakeUndefined(context);
} Catch (UnknownException) {
LogError("UnknownException: " << _rethrown_exception.GetMessage());
} Catch (WrtDeviceApis::Commons::Exception) {
{
LogDebug("Entered ");
+ AceSecurityStatus status = SECURE_ELEMENT_CHECK_ACCESS(SECUREELEMENT_FUNCTION_API_FUNCS);
+ TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+
Validator validator(context, exception);
if ((argumentCount < 1) || JSValueIsNull(context, arguments[0]) || JSValueIsUndefined(context, arguments[0])) {
size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) {
LogDebug("Enter");
+ AceSecurityStatus status = SECURE_ELEMENT_CHECK_ACCESS(SECUREELEMENT_FUNCTION_API_FUNCS);
+ TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+
if ((argumentCount < 1) || JSValueIsNull(context, arguments[0]) || JSValueIsUndefined(context, arguments[0])) {
/* 1st argument is mandatory. And 1st argument must be Callback. */
LogError("TypeMismatchException!");
} Catch (NullPointerException) {
return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
} Catch (NotFoundException) {
- return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_FOUND_ERROR, "Not Found ID");
+ return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Not Found ID");
} Catch (WrtDeviceApis::Commons::Exception) {
LogError("Exception: " << _rethrown_exception.GetMessage());
}
{
LogDebug("Entered ");
+ AceSecurityStatus status = SECURE_ELEMENT_CHECK_ACCESS(SECUREELEMENT_FUNCTION_API_FUNCS);
+ TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+
SEServicePrivObject* privateObject = static_cast<SEServicePrivObject*>(JSObjectGetPrivate(thisObject));
if (NULL == privateObject) {
LogError("private object is null");
return JSValueMakeUndefined(context);
} Catch (UnknownException) {
LogError("Exception: " << _rethrown_exception.GetMessage());
- } Catch (PlatformException) {
- LogError("Exception: " << _rethrown_exception.GetMessage());
- return JSTizenExceptionFactory::postException(context, exception, JSTizenException::SERVICE_NOT_AVAILABLE, "Service Not Available");
} Catch (WrtDeviceApis::Commons::Exception) {
LogError("Exception: " << _rethrown_exception.GetMessage());
}
#include "JSSESession.h"
#include "SEConverter.h"
#include "SEAsyncCallbackManager.h"
-
+#include "plugin_config.h"
using namespace DeviceAPI::Common;
const JSValueRef arguments[],
JSValueRef* exception)
{
- SESessionPrivObject* privateObject = static_cast<SESessionPrivObject*>(JSObjectGetPrivate(thisObject));
- if (NULL == privateObject) {
- LogError("private object is null");
- return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
- }
+ AceSecurityStatus status = SECURE_ELEMENT_CHECK_ACCESS(SECUREELEMENT_FUNCTION_API_FUNCS);
+ TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
- ISESessionPtr seSession(privateObject->getObject());
- SEConverter convert(context);
- return convert.toJSValueRef(seSession->getATR());
+ Try {
+ SESessionPrivObject* privateObject = static_cast<SESessionPrivObject*>(JSObjectGetPrivate(thisObject));
+ if (NULL == privateObject) {
+ LogError("private object is null");
+ return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
+ }
+
+ ISESessionPtr seSession(privateObject->getObject());
+ SEConverter convert(context);
+ return convert.toJSValueRef(seSession->getATR());
+ } Catch (WrtDeviceApis::Commons::Exception) {
+ LogError("Exception: " << _rethrown_exception.GetMessage());
+ }
+ return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
}
JSValueRef JSSESession::close(JSContextRef context,
const JSValueRef arguments[],
JSValueRef* exception)
{
- SESessionPrivObject* privateObject = static_cast<SESessionPrivObject*>(JSObjectGetPrivate(thisObject));
- if (NULL == privateObject) {
- LogError("private object is null");
- return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
- }
+ AceSecurityStatus status = SECURE_ELEMENT_CHECK_ACCESS(SECUREELEMENT_FUNCTION_API_FUNCS);
+ TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
- ISESessionPtr seSession(privateObject->getObject());
- seSession->close();
- return JSValueMakeUndefined(context);
+ Try {
+ SESessionPrivObject* privateObject = static_cast<SESessionPrivObject*>(JSObjectGetPrivate(thisObject));
+ if (NULL == privateObject) {
+ LogError("private object is null");
+ return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
+ }
+
+ ISESessionPtr seSession(privateObject->getObject());
+ seSession->close();
+ return JSValueMakeUndefined(context);
+ } Catch (WrtDeviceApis::Commons::Exception) {
+ LogError("Exception: " << _rethrown_exception.GetMessage());
+ }
+ return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
}
JSValueRef JSSESession::closeChannels(JSContextRef context,
const JSValueRef arguments[],
JSValueRef* exception)
{
- SESessionPrivObject* privateObject = static_cast<SESessionPrivObject*>(JSObjectGetPrivate(thisObject));
- if (NULL == privateObject) {
- LogError("private object is null");
- return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
- }
+ AceSecurityStatus status = SECURE_ELEMENT_CHECK_ACCESS(SECUREELEMENT_FUNCTION_API_FUNCS);
+ TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
- ISESessionPtr seSession(privateObject->getObject());
- seSession->closeChannels();
- return JSValueMakeUndefined(context);
+ Try {
+ SESessionPrivObject* privateObject = static_cast<SESessionPrivObject*>(JSObjectGetPrivate(thisObject));
+ if (NULL == privateObject) {
+ LogError("private object is null");
+ return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
+ }
+
+ ISESessionPtr seSession(privateObject->getObject());
+ seSession->closeChannels();
+ return JSValueMakeUndefined(context);
+ } Catch (WrtDeviceApis::Commons::Exception) {
+ LogError("Exception: " << _rethrown_exception.GetMessage());
+ }
+ return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
}
JSValueRef JSSESession::openBasicChannel(JSContextRef context,
{
LogDebug("Entered ");
+ AceSecurityStatus status = SECURE_ELEMENT_CHECK_ACCESS(SECUREELEMENT_FUNCTION_API_FUNCS);
+ TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+
Validator validator(context, exception);
if ((argumentCount < 2) || JSValueIsNull(context, arguments[0]) || JSValueIsUndefined(context, arguments[0]) || !JSIsArrayValue(context, arguments[0])) {
Converter convert(context);
JSCallbackManagerPtr callbackManager = JSCallbackManager::createObject(privateObject->getContext(), onSuccessForCbm, onErrorForCbm, true, true);
Try {
- EventSEOpenChannelPtr event(new EventSEOpenChannel(convert.toVectorOfUChars(arguments[0]), true));
+ std::vector<unsigned char> aid = convert.toVectorOfUChars(arguments[0]);
+ if ((aid.size() < 5) || (aid.size() > 16)) {
+ LogError("wrong aid length : " << aid.size());
+ return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Wrong AID length");
+ }
+ EventSEOpenChannelPtr event(new EventSEOpenChannel(aid, true));
event->setPrivateData( StaticPointerCast<IEventPrivateData>(callbackManager) );
event->setForAsynchronousCall(&SEResponseDispatcher::getInstance());
} Catch (ConversionException) {
LogError("ConversionException");
return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
- } Catch (InvalidArgumentException) {
- LogError("InvalidArgumentException");
- callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values"));
- return JSValueMakeUndefined(context);
- } Catch (PlatformException) {
- LogError("PlatformException: " << _rethrown_exception.GetMessage());
- callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::SERVICE_NOT_AVAILABLE, "Service Not Available"));
- return JSValueMakeUndefined(context);
} Catch (UnknownException) {
LogError("UnknownException: " << _rethrown_exception.GetMessage());
} Catch (WrtDeviceApis::Commons::Exception) {
{
LogDebug("Entered ");
+ AceSecurityStatus status = SECURE_ELEMENT_CHECK_ACCESS(SECUREELEMENT_FUNCTION_API_FUNCS);
+ TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+
Validator validator(context, exception);
if ((argumentCount < 2) || JSValueIsNull(context, arguments[0]) || JSValueIsUndefined(context, arguments[0]) || !JSIsArrayValue(context, arguments[0])) {
Converter convert(context);
JSCallbackManagerPtr callbackManager = JSCallbackManager::createObject(privateObject->getContext(), onSuccessForCbm, onErrorForCbm, true, true);
Try {
- EventSEOpenChannelPtr event(new EventSEOpenChannel(convert.toVectorOfUChars(arguments[0]), false));
+ std::vector<unsigned char> aid = convert.toVectorOfUChars(arguments[0]);
+ if ((aid.size() < 5) || (aid.size() > 16)) {
+ LogError("wrong aid length : " << aid.size());
+ return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Wrong AID length");
+ }
+ EventSEOpenChannelPtr event(new EventSEOpenChannel(aid, false));
event->setPrivateData( StaticPointerCast<IEventPrivateData>(callbackManager) );
event->setForAsynchronousCall(&SEResponseDispatcher::getInstance());
} Catch (ConversionException) {
LogError("ConversionException");
return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
- } Catch (InvalidArgumentException) {
- LogError("InvalidArgumentException");
- callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values"));
- return JSValueMakeUndefined(context);
- } Catch (PlatformException) {
- LogError("PlatformException: " << _rethrown_exception.GetMessage());
- callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::SERVICE_NOT_AVAILABLE, "Service Not Available"));
- return JSValueMakeUndefined(context);
} Catch (UnknownException) {
LogError("UnknownException: " << _rethrown_exception.GetMessage());
} Catch (WrtDeviceApis::Commons::Exception) {
}
void SEChannel::transmitManualAnswer(unsigned char *buffer, unsigned int length, int error, const EventSEChannelTransmitPtr &event) {
+ SEUtil util;
if (error != 0) {
event->setResult(false);
- if (error == -4)
- event->setError(DeviceAPI::Common::JSTizenException::INVALID_VALUES_ERROR);
- else
- event->setError(DeviceAPI::Common::JSTizenException::UNKNOWN_ERROR);
+ event->setError(util.getErrorString(error));
+ event->setErrorMessage(util.getErrorMessage(error));
} else {
event->setResult(true);
- SEUtil util;
event->setResponse(util.toVector(buffer, length));
}
EventRequestReceiver<EventSEChannelTransmit>::ManualAnswer(event);
} catch (const WrtDeviceApis::Commons::Exception& ex) {
LogError("Exception: " << ex.GetMessage());
event->setResult(false);
-
+ event->setError(DeviceAPI::Common::JSTizenException::UNKNOWN_ERROR);
+ event->setErrorMessage("Unknown Error");
EventRequestReceiver<EventSEChannelTransmit>::ManualAnswer(event);
}
}
#include <CommonsJavaScript/Validator.h>
#include <CommonsJavaScript/JSUtils.h>
#include "SEConverter.h"
+#include <JSWebAPIError.h>
+#include <TizenExceptionData.h>
using namespace std;
using namespace WrtDeviceApis::CommonsJavaScript;
using namespace WrtDeviceApis;
+using namespace DeviceAPI::Common;
#define SE_LISTENER_ONSEREADY "onSEReady"
#define SE_LISTENER_ONSENOTREADY "onSENotReady"
return result;
}
+JSValueRef SEConverter::makeSeErrorObject(std::string error, std::string message) {
+ int code = JSWebAPIError::UNKNOWN_ERR;
+ if (error.compare("InvalidStateError") == 0)
+ code = JSWebAPIError::INVALID_STATE_ERR;
+ else
+ code = JSWebAPIError::convertToWebAPIErrorCode(error);
+
+ JSWebAPIError::PrivateObject::ObjectType data(new TizenExceptionData(code, error, message));
+ return JSUtils::makeObject(m_context, JSWebAPIError::getClassRef(), data);
+}
+
}
}
JSValueRef toJSValueRef(const std::vector<unsigned char>& arg);
SEListener toSEListener(const JSValueRef& arg);
+
+ JSValueRef makeSeErrorObject(std::string error, std::string message);
};
typedef WrtDeviceApis::CommonsJavaScript::ConverterFactory<SEConverter> SEConverterFactory;
#include <dpl/log/log.h>
#include <Commons/Exception.h>
-
+#include <JSTizenException.h>
#include "SEReader.h"
#include "SEUtil.h"
}
void SEReader::openSessionManualAnswer(void *session, int error, const EventSEOpenSessionPtr &event) {
- if ((error != 0) || session == NULL) {
+ SEUtil util;
+ if (error != SCARD_ERROR_OK) {
+ event->setResult(false);
+ event->setError(util.getErrorString(error));
+ event->setErrorMessage(util.getErrorMessage(error));
+ } else if (session == NULL) {
event->setResult(false);
+ event->setError(DeviceAPI::Common::JSTizenException::UNKNOWN_ERROR);
+ event->setErrorMessage("Unknown Error");
} else {
event->setSession(session);
event->setResult(true);
} catch (const WrtDeviceApis::Commons::Exception& ex) {
LogError("Exception: " << ex.GetMessage());
event->setResult(false);
-
+ event->setError(DeviceAPI::Common::JSTizenException::UNKNOWN_ERROR);
+ event->setErrorMessage("Unknown Error");
EventRequestReceiver<EventSEOpenSession>::ManualAnswer(event);
}
}
SEAsyncCallbackManagerSingleton::Instance().unregisterCallbackManager(cbm);
JSContextRef context = cbm->getContext();
-
+ SEConverter convert(context);
if (event->getResult()) {
LogDebug("result success");
std::vector<void *> readers = event->getListSEs();
for (std::size_t i = 0; i < readers.size(); i++)
ListSes.push_back(JSSEReader::createJSObject(context, readers[i]));
- Converter convert(context);
cbm->callOnSuccess(convert.toJSValueRef(ListSes));
return;
}
LogDebug("result fail");
- std::string error = event->getError();
- JSValueRef errorObject = NULL;
- if (error != "")
- errorObject = JSTizenExceptionFactory::makeErrorObject(cbm->getContext(), error, error);
- else
- errorObject = JSTizenExceptionFactory::makeErrorObject(cbm->getContext(), JSTizenException::UNKNOWN_ERROR,"Unknown Error");
- cbm->callOnError(errorObject);
+ cbm->callOnError(convert.makeSeErrorObject(event->getError(), event->getErrorMessage()));
}
void SEResponseDispatcher::OnAnswerReceived(const EventSEOpenSessionPtr &event)
SEAsyncCallbackManagerSingleton::Instance().unregisterCallbackManager(cbm);
JSContextRef context = cbm->getContext();
+ SEConverter convert(context);
if (event->getResult()) {
LogDebug("result success");
-
- Converter convert(context);
cbm->callOnSuccess(convert.toJSValueRef(JSSESession::createJSObject(context, event->getSession())));
return;
}
LogDebug("result fail");
- std::string error = event->getError();
- JSValueRef errorObject = NULL;
- if (error != "")
- errorObject = JSTizenExceptionFactory::makeErrorObject(cbm->getContext(), error, error);
- else
- errorObject = JSTizenExceptionFactory::makeErrorObject(cbm->getContext(), JSTizenException::UNKNOWN_ERROR,"Unknown Error");
- cbm->callOnError(errorObject);
+ cbm->callOnError(convert.makeSeErrorObject(event->getError(), event->getErrorMessage()));
}
SEAsyncCallbackManagerSingleton::Instance().unregisterCallbackManager(cbm);
JSContextRef context = cbm->getContext();
+ SEConverter convert(context);
if (event->getResult()) {
LogDebug("result success");
-
- Converter convert(context);
cbm->callOnSuccess(convert.toJSValueRef(JSSEChannel::createJSObject(context, event->getChannel())));
return;
}
LogDebug("result fail");
- std::string error = event->getError();
- JSValueRef errorObject = NULL;
- if (error != "")
- errorObject = JSTizenExceptionFactory::makeErrorObject(cbm->getContext(), error, error);
- else
- errorObject = JSTizenExceptionFactory::makeErrorObject(cbm->getContext(), JSTizenException::UNKNOWN_ERROR,"Unknown Error");
- cbm->callOnError(errorObject);
+ cbm->callOnError(convert.makeSeErrorObject(event->getError(), event->getErrorMessage()));
}
void SEResponseDispatcher::OnAnswerReceived(const EventSEChannelTransmitPtr &event)
SEAsyncCallbackManagerSingleton::Instance().unregisterCallbackManager(cbm);
JSContextRef context = cbm->getContext();
+ SEConverter convert(context);
if (event->getResult()) {
LogDebug("result success");
-
- SEConverter convert(context);
cbm->callOnSuccess(convert.toJSValueRef(event->getResponse()));
return;
}
LogDebug("result fail");
- std::string error = event->getError();
- JSValueRef errorObject = NULL;
-
- if (error == JSTizenException::INVALID_VALUES_ERROR)
- cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR,"Invalid APDU command"));
- else if (error != "")
- errorObject = JSTizenExceptionFactory::makeErrorObject(cbm->getContext(), error, error);
- else
- errorObject = JSTizenExceptionFactory::makeErrorObject(cbm->getContext(), JSTizenException::UNKNOWN_ERROR,"Unknown Error");
-
- cbm->callOnError(errorObject);
+ cbm->callOnError(convert.makeSeErrorObject(event->getError(), event->getErrorMessage()));
}
}
#include <dpl/log/log.h>
#include <Commons/Exception.h>
-
+#include <JSTizenException.h>
#include "SESession.h"
#include "SEUtil.h"
void SESession::openChannelManualAnswer(void * channel, int error, const EventSEOpenChannelPtr &event) {
- if ((error != 0) || channel == NULL) {
+ SEUtil util;
+ if (error != SCARD_ERROR_OK) {
event->setResult(false);
+ event->setError(util.getErrorString(error));
+ event->setErrorMessage(util.getErrorMessage(error));
+ } else if (channel == NULL) {
+ event->setResult(false);
+ event->setError(DeviceAPI::Common::JSTizenException::UNKNOWN_ERROR);
+ event->setErrorMessage("Unknown Error");
} else {
event->setChannel(channel);
event->setResult(true);
} catch (const WrtDeviceApis::Commons::Exception& ex) {
LogError("Exception: " << ex.GetMessage());
event->setResult(false);
-
+ event->setError(DeviceAPI::Common::JSTizenException::UNKNOWN_ERROR);
+ event->setErrorMessage("Unknown Error");
EventRequestReceiver<EventSEOpenChannel>::ManualAnswer(event);
}
}
#include "SEUtil.h"
#include <dpl/log/log.h>
-
+#include <JSTizenException.h>
+#include <smartcard-types.h>
namespace DeviceAPI {
namespace SecureElement {
return NULL;
}
+std::string SEUtil::getErrorString(const int errorCode) {
+ LogDebug ("Errorcode : " << errorCode);
+ switch(errorCode) {
+ case SCARD_ERROR_OK:
+ return "";
+ case SCARD_ERROR_NOT_ENOUGH_RESOURCE:
+ return "NoChannelError";
+ case SCARD_ERROR_OUT_OF_MEMORY:
+ case SCARD_ERROR_UNAVAILABLE:
+ case SCARD_ERROR_IPC_FAILED:
+ case SCARD_ERROR_OPERATION_TIMEOUT:
+ case SCARD_ERROR_UNKNOWN:
+ return DeviceAPI::Common::JSTizenException::IO_ERROR;
+ case SCARD_ERROR_ILLEGAL_STATE:
+ case SCARD_ERROR_ILLEGAL_REFERENCE:
+ return "InvalidStateError";
+ case SCARD_ERROR_ILLEGAL_PARAM:
+ return DeviceAPI::Common::JSTizenException::INVALID_VALUES_ERROR;
+ case SCARD_ERROR_SECURITY_NOT_ALLOWED:
+ return DeviceAPI::Common::JSTizenException::PERMISSION_DENIED_ERROR;
+ case SCARD_ERROR_IO_FAILED:
+ return DeviceAPI::Common::JSTizenException::NOT_FOUND_ERROR;
+ }
+ return DeviceAPI::Common::JSTizenException::UNKNOWN_ERROR;
+}
+
+std::string SEUtil::getErrorMessage(const int errorCode) {
+ LogDebug ("Errorcode : " << errorCode);
+ switch(errorCode) {
+ case SCARD_ERROR_OK:
+ return "";
+ case SCARD_ERROR_NOT_ENOUGH_RESOURCE:
+ return "Not Enough Resource";
+ case SCARD_ERROR_OUT_OF_MEMORY:
+ return "Out Of Memory";
+ case SCARD_ERROR_UNAVAILABLE:
+ return "Unavailable";
+ case SCARD_ERROR_IPC_FAILED:
+ return "Platform Error";
+ case SCARD_ERROR_OPERATION_TIMEOUT:
+ return "Operation Timeout";
+ case SCARD_ERROR_UNKNOWN:
+ return "Unknown Error";
+ case SCARD_ERROR_ILLEGAL_STATE:
+ return "Illegal state";
+ case SCARD_ERROR_ILLEGAL_REFERENCE:
+ return "Illegal reference";
+ case SCARD_ERROR_ILLEGAL_PARAM:
+ return "Illegal param";
+ case SCARD_ERROR_SECURITY_NOT_ALLOWED:
+ return "Security Not Allowed";
+ case SCARD_ERROR_IO_FAILED:
+ return "Not Exist In SE";
+ }
+ return "UnknownError";
+}
+
}
}
#define _SEUTIL_H_
#include <vector>
+#include <string>
namespace DeviceAPI {
namespace SecureElement {
virtual ~SEUtil() {}
std::vector<unsigned char> toVector(const unsigned char *ch, const int size);
unsigned char *toCharPtr(std::vector<unsigned char> vec) ;
+ std::string getErrorString(const int errorCode);
+ std::string getErrorMessage(const int errorCode);
};
}
<feature-root-fingerprint>AAAABBBBCCCCDDDEEEE0000</feature-root-fingerprint>
<api-feature>
+ <name>http://tizen.org/privilege/secureelement</name>
+ <device-capability>secureelement</device-capability>
+ </api-feature>
+
+ <api-feature>
<name>http://tizen.org/privilege/se</name>
<device-capability>se</device-capability>
</api-feature>
--- /dev/null
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 <map>
+#include <utility>
+#include <Commons/FunctionDefinition.h>
+#include <Commons/FunctionDeclaration.h>
+#include <Commons/Exception.h>
+
+#include "plugin_config.h"
+
+#define SECUREELEMENT_FEATURE_API_SECUREELEMENT "http://tizen.org/privilege/secureelement"
+#define SECUREELEMENT_FEATURE_API_SE "http://tizen.org/privilege/se"
+
+#define SECUREELEMENT_DEVICE_CAP_SECUREELEMENT "secureelement"
+#define SECUREELEMENT_DEVICE_CAP_SE "se"
+
+namespace DeviceAPI {
+namespace SecureElement {
+
+static WrtDeviceApis::Commons::FunctionMapping createSecureElementFunctions();
+
+static WrtDeviceApis::Commons::FunctionMapping SecureElementFunctions =
+ createSecureElementFunctions();
+
+DEFINE_FUNCTION_GETTER(SecureElement, SecureElementFunctions);
+
+static WrtDeviceApis::Commons::FunctionMapping createSecureElementFunctions()
+{
+ using namespace WrtDeviceApis::Commons;
+
+ /**
+ * Device capabilities
+ */
+ ACE_CREATE_DEVICE_CAP(DEVICE_CAP_SECUREELEMENT, SECUREELEMENT_DEVICE_CAP_SECUREELEMENT);
+ ACE_CREATE_DEVICE_CAP(DEVICE_CAP_SE, SECUREELEMENT_DEVICE_CAP_SE);
+
+ ACE_CREATE_DEVICE_CAPS_LIST(DEVICE_LIST_SECUREELEMENT);
+ ACE_ADD_DEVICE_CAP(DEVICE_LIST_SECUREELEMENT, DEVICE_CAP_SECUREELEMENT);
+ ACE_ADD_DEVICE_CAP(DEVICE_LIST_SECUREELEMENT, DEVICE_CAP_SE);
+
+ /**
+ * API features
+ */
+ ACE_CREATE_FEATURE(FEATURE_SECUREELEMENT, SECUREELEMENT_FEATURE_API_SECUREELEMENT);
+ ACE_CREATE_FEATURE(FEATURE_SE, SECUREELEMENT_FEATURE_API_SE);
+
+ ACE_CREATE_FEATURE_LIST(SECUREELEMENT_FEATURES_SECUREELEMENT);
+ ACE_ADD_API_FEATURE(SECUREELEMENT_FEATURES_SECUREELEMENT, FEATURE_SECUREELEMENT);
+ ACE_ADD_API_FEATURE(SECUREELEMENT_FEATURES_SECUREELEMENT, FEATURE_SE);
+
+ /**
+ * Functions
+ */
+
+ FunctionMapping SecureElementFunctions;
+
+ AceFunction seFunctions = ACE_CREATE_FUNCTION(
+ FUNCTION_SECUREELEMENT_FUNCTIONS,
+ SECUREELEMENT_FUNCTION_API_FUNCS,
+ SECUREELEMENT_FEATURES_SECUREELEMENT,
+ DEVICE_LIST_SECUREELEMENT);
+
+ SecureElementFunctions.insert(std::make_pair(
+ SECUREELEMENT_FUNCTION_API_FUNCS,
+ seFunctions));
+
+ return SecureElementFunctions;
+}
+}
+}
+
+#undef SECUREELEMENT_FEATURE_API_SE
+#undef SECUREELEMENT_FEATURE_API_SECUREELEMENT
+#undef SECUREELEMENT_DEVICE_CAP_SE
+#undef SECUREELEMENT_DEVICE_CAP_SECUREELEMENT
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 _SECUREELEMENT_PLUGIN_CONFIG_H_
+#define _SECUREELEMENT_PLUGIN_CONFIG_H_
+
+#include <Commons/FunctionDeclaration.h>
+
+namespace DeviceAPI {
+namespace SecureElement {
+
+#define SECUREELEMENT_FUNCTION_API_FUNCS "SecureElementFunctions"
+
+DECLARE_FUNCTION_GETTER(SecureElement);
+
+#define SECURE_ELEMENT_CHECK_ACCESS(functionName) \
+ aceCheckAccess<AceFunctionGetter, DefaultArgsVerifier<> >( \
+ getSecureElementFunctionData, \
+ functionName)
+}
+}
+
+#endif // _SECUREELEMENT_PLUGIN_CONFIG_H_
\ No newline at end of file
Network->networkType= "2.5";
} else if (networkType == VCONFKEY_TELEPHONY_SVCTYPE_3G || networkType == VCONFKEY_TELEPHONY_SVCTYPE_HSDPA) {
Network->networkType= "3G";
+ } else if (networkType == VCONFKEY_TELEPHONY_SVCTYPE_LTE) {
+ Network->networkType= "4G";
} else {
Network->networkType= "NONE";
}
int plmn = 0, cellid = 0, lac = 0, isRoaming = 0, isFlightMode = 0;
if (vconf_get_int(VCONFKEY_TELEPHONY_PLMN, &plmn) == 0) {
- cellularNetwork->mcc = plmn / 1000;
- cellularNetwork->mnc = plmn % 1000;
+ cellularNetwork->mcc = plmn / 100;
+ cellularNetwork->mnc = plmn % 100;
}
if (vconf_get_int(VCONFKEY_TELEPHONY_CELLID, &cellid) == 0) {
#include "JSFeatureParam.h"
-namespace DeviceAPI {\rnamespace Tizen {
+namespace DeviceAPI {
+namespace Tizen {
namespace {
const char* PLUGIN_NAME = "Feature";
const char* ATTRIBUTE_URI = "uri";
- const char* ATTRIBUTE_REQUIRED = "required";
- const char* ATTRIBUTE_PARAMS = "params";
}
JSClassDefinition JSFeature::m_classInfo =
JSStaticValue JSFeature::m_properties[] = {
{ ATTRIBUTE_URI, getProperty, NULL, kJSPropertyAttributeReadOnly },
- { ATTRIBUTE_REQUIRED, getProperty, NULL, kJSPropertyAttributeReadOnly },
- { ATTRIBUTE_PARAMS, getProperty, NULL, kJSPropertyAttributeReadOnly },
{ 0, 0, 0, 0 }
};
if (JSStringIsEqualToUTF8CString(propertyName, ATTRIBUTE_URI)) {
return converter.toJSValueRef(priv->getObject()->getName() );
}
- else if (JSStringIsEqualToUTF8CString(propertyName, ATTRIBUTE_REQUIRED)) {
- if (priv->getObject()->isRequestedByWidget()) {
- return converter.toJSValueRef(priv->getObject()->isRequired() );
- }
- return JSValueMakeNull(context);
- }
- else if (JSStringIsEqualToUTF8CString(propertyName, ATTRIBUTE_PARAMS)) {
- if (priv->getObject()->isRequestedByWidget()) {
- JSObjectRef jsResult = JSCreateArrayObject(context, 0, NULL);
- if (jsResult) {
- WrtDeviceApis::WidgetDB::Api::IWidgetFeature::Params params =
- priv->getObject()->getParams();
- WrtDeviceApis::WidgetDB::Api::IWidgetFeature::ParamsIterator it =
- params.begin();
- size_t i = 0;
- for (; it != params.end(); ++it, ++i) {
- std::pair<std::string, std::string> param = make_pair(it->first, it->second);
- JSFeatureParamPrivObject *priv = new JSFeatureParamPrivObject(context, param);
- JSObjectRef tempVal = JSObjectMake(context, JSFeatureParam::getClassRef(), priv);
- bool result = JSSetArrayElement(context, jsResult, i, tempVal);
- if(result == false)
- continue;
- }
- return jsResult;
- }
- }
- return JSValueMakeNull(context);
- }
}
Catch(WrtDeviceApis::Commons::Exception)
{