Name: wrt-plugins-tizen
Summary: JavaScript plugins for WebRuntime
-Version: 0.4.5
+Version: 0.4.8
Release: 0
Group: Development/Libraries
License: Apache License, Version 2.0
project_name=@CMAKE_PROJECT_NAME@
module_name=common
exec_prefix=${prefix}
-libdir=${prefix}/lib/wrt-plugins/tizen-${module_name}
+libdir=${prefix}/lib/wrt-plugins/tizen-tizen
includedir=${prefix}/include/${project_name}
Name: wrt-plugins-tizen-${module_name}
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-tizen
Cflags: -I${includedir}/${module_name}
\ No newline at end of file
JSValueRef onsuccess = JSUtils::getJSPropertyOrUndefined(context, cbObj, "onsuccess");
JSValueRef onfail = JSUtils::getJSPropertyOrUndefined(context, cbObj, "onfailure");
- if (!util.isFunction(onsuccess) || !util.isFunction(onfail)) {
+ if (!util.isNullOrUndefinedOrFunction(onsuccess) || !util.isNullOrUndefinedOrFunction(onfail)) {
ThrowMsg(ConversionException, "Wrong fifth parameter type.");
}
- callbackManagerReply = JSCallbackManager::createObject(gContext, onsuccess, onfail);
+ callbackManagerReply = JSCallbackManager::createObject(gContext);
+
+ if (util.isFunction(onsuccess)) {
+ callbackManagerReply->setOnSuccess(onsuccess);
+ }
+
+ if (util.isFunction(onfail)) {
+ callbackManagerReply->setOnError(onfail);
+ }
+
callbackManagerReply->setObject(thisObject);
} else if (!util.isNullOrUndefined(arguments[4])) {
}
Try {
- if (argumentCount == 0) {
+ ApplicationUtil util(context, exception);
+ if ((argumentCount < 1) || (!util.isObject(arguments[0]))) {
ThrowMsg(ConversionException, "Wrong parameter type.");
}
JSValueRef onUpdated = JSUtils::getJSPropertyOrUndefined(context, cbObj, "onupdated");
JSValueRef onUninstalled = JSUtils::getJSPropertyOrUndefined(context, cbObj, "onuninstalled");
- ApplicationUtil util(context, exception);
- if (!util.isFunction(onInstalled) || !util.isFunction(onUpdated) || !util.isFunction(onUninstalled)) {
+ if (!util.isNullOrUndefinedOrFunction(onInstalled) || !util.isNullOrUndefinedOrFunction(onUpdated) || !util.isNullOrUndefinedOrFunction(onUninstalled)) {
ThrowMsg(ConversionException, "Wrong first parameter type.");
}
JSApplicationEventCallbackManagerPtr callbackManager =
JSApplicationEventCallbackManager::createObject(gContext);
- callbackManager->setOnInstalled(onInstalled);
- callbackManager->setOnUpdated(onUpdated);
- callbackManager->setOnUninstalled(onUninstalled);
+ if (util.isFunction(onInstalled)) {
+ callbackManager->setOnInstalled(onInstalled);
+ }
+ if (util.isFunction(onUpdated)) {
+ callbackManager->setOnUpdated(onUpdated);
+ }
+ if (util.isFunction(onUninstalled)) {
+ callbackManager->setOnUninstalled(onUninstalled);
+ }
EventApplicationAppInfoEventListenerEmitterPtr emitter(new EventApplicationAppInfoEventListenerEmitter());
emitter->setEventPrivateData(DPL::StaticPointerCast<IEventPrivateData>(callbackManager));
return value;
}
-long ArgumentValidator::toLong(int index, bool nullable, long defaultvalue){
+double ArgumentValidator::toNumber(int index, bool nullable, double defaultvalue){
JSValueRef value = getArgument(index, nullable);
JSValueRef exception = NULL;
if( JSValueIsNull(mContext, value) && nullable){
return defaultvalue;
}
- long longvalue = (long)JSValueToNumber(mContext, value, &exception);
+ double numberValue = JSValueToNumber(mContext, value, &exception);
if(exception != NULL){
throw TypeMismatchException(mContext, exception);
}
- return longvalue;
+ return numberValue;
+}
+
+long ArgumentValidator::toLong(int index, bool nullable, long defaultvalue){
+ return static_cast<long>(toLongLong(index,nullable,defaultvalue));
+}
+
+unsigned long ArgumentValidator::toULong(int index, bool nullable, long defaultvalue){
+ return static_cast<unsigned long>(toULongLong(index,nullable,defaultvalue));
}
+long long ArgumentValidator::toLongLong(int index, bool nullable, long long defaultvalue){
+ return static_cast<long long>(toNumber(index,nullable,defaultvalue));
+}
+
+unsigned long long ArgumentValidator::toULongLong(int index, bool nullable, long long defaultvalue){
+ return static_cast<unsigned long long>(toNumber(index,nullable,defaultvalue));
+}
+
+
double ArgumentValidator::toDouble(int index, bool nullable, double defaultvalue){
- JSValueRef value = getArgument(index, nullable);
- JSValueRef exception = NULL;
- if( JSValueIsNull(mContext, value) && nullable){
- return defaultvalue;
- }
- double doublevalue = JSValueToNumber(mContext, value, &exception);
- if(exception != NULL){
- throw TypeMismatchException(mContext, exception);
- }
+ double doublevalue = toNumber(index,nullable,defaultvalue);
if( isnan(doublevalue)){
throw TypeMismatchException("Value is not number");
}
if( JSValueIsNull(mContext, value) && nullable){
return NULL;
}
+ if( !JSValueIsObject(mContext, value) ){
+ throw TypeMismatchException("Value is not Object");
+ }
JSValueRef exception = NULL;
JSObjectRef object = JSValueToObject(mContext, value, &exception);
return result;
}
+std::map<std::string, std::string> ArgumentValidator::toStringMap(int index, bool nullable){
+ JSObjectRef value = toObject(index, nullable);
+ if( value == NULL || JSValueIsNull(mContext, value) ){
+ return std::map<std::string, std::string>();
+ }
+
+ return JSUtil::JSValueToStringMap(mContext, value);
+}
}
#include <string>
#include <vector>
+#include <map>
#include <JavaScriptCore/JavaScript.h>
#include <ctime>
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);
std::vector<bool> toBoolVector(int index, bool nullable = false);
std::vector<JSValueRef> toJSValueRefVector(int index, bool nullable= false);
+ std::map<std::string, std::string> toStringMap(int index, bool nullable = false);
+
private:
JSValueRef getArgument(int index, bool nullable);
JSContextRef mContext;
JSStringGetUTF8CString(str, buffer, jsSize);
result = buffer;
}
- JSStringRelease(str);
return result;
}
}
long JSUtil::JSValueToLong(JSContextRef ctx, JSValueRef value){
+ return static_cast<long>(JSValueToLongLong(ctx,value));
+}
+
+unsigned long JSUtil::JSValueToULong(JSContextRef ctx, JSValueRef value){
+ return static_cast<unsigned long>(JSValueToULongLong(ctx,value));
+}
+
+
+long long JSUtil::JSValueToLongLong(JSContextRef ctx, JSValueRef value){
+ JSValueRef exception = NULL;
+ long long longvalue = static_cast<long long>(JSValueToNumber(ctx, value, &exception));
+ if(exception != NULL){
+ throw TypeMismatchException(ctx, exception);
+ }
+ return longvalue;
+}
+
+unsigned long long JSUtil::JSValueToULongLong(JSContextRef ctx, JSValueRef value){
JSValueRef exception = NULL;
- long longvalue = static_cast<long>(JSValueToNumber(ctx, value, &exception));
+ long long longvalue = static_cast<unsigned long long>(JSValueToNumber(ctx, value, &exception));
if(exception != NULL){
throw TypeMismatchException(ctx, exception);
}
}
+
double JSUtil::JSValueToDouble(JSContextRef ctx, JSValueRef value){
JSValueRef exception = NULL;
}
time_t JSUtil::JSValueToTimeT(JSContextRef ctx, JSValueRef value){
- printf("JSValueToTimeT\n");
JSObjectRef timeobj = NULL;
timeobj = JSUtil::JSValueToObject(ctx, value);
JSValueRef exception = NULL;
- JSObjectRef getTime = JSUtil::JSValueToObject(ctx, getProperty(ctx, timeobj, "getTime"));
+ JSObjectRef getTime = NULL;
+ try{
+ getTime = JSUtil::JSValueToObject(ctx, getProperty(ctx, timeobj, "getTime"));
+ }catch( const TypeMismatchException& err){
+ throw TypeMismatchException("Value is not Date Object");
+ }
+
JSValueRef timevalue = JSObjectCallAsFunction(ctx, getTime, timeobj, 0, NULL, &exception);
if( exception != NULL )
throw TypeMismatchException("Value is not Date Object");
JSValueRef exception = NULL;
JSObjectRef obj = ::JSValueToObject(ctx, value,&exception);
if( exception != NULL){
- throw TypeMismatchException("Value is not Object");
+ throw TypeMismatchException(ctx, exception);
}
return obj;
}
+std::map<std::string, std::string> JSUtil::JSValueToStringMap(JSContextRef ctx, JSValueRef value){
+ std::map<std::string, std::string> result;
+ JSObjectRef obj = JSUtil::JSValueToObject(ctx, value);
+ JSPropertyNameArrayRef jsPropNames = JSObjectCopyPropertyNames(ctx, obj);
+ for (std::size_t i = 0; i < JSPropertyNameArrayGetCount(jsPropNames); ++i) {
+ std::string propName = JSUtil::JSStringToString(ctx, JSPropertyNameArrayGetNameAtIndex(jsPropNames, i));
+ std::string propValue = JSUtil::JSValueToString(ctx, JSUtil::getProperty(ctx, obj, propName.c_str(), NULL));
+ result.insert(std::make_pair(propName, propValue));
+ }
+ JSPropertyNameArrayRelease(jsPropNames);
+ return result;
+}
+
JSObjectRef JSUtil::makeDateObject(JSContextRef ctx, const time_t value){
JSValueRef exception = NULL;
JSValueRef args[1];
return result;
}
+JSValueRef JSUtil::toJSValueRef(JSContextRef ctx, const unsigned long value){
+ return JSValueMakeNumber(ctx, value);
+}
+
JSValueRef JSUtil::toJSValueRef(JSContextRef ctx, const long value){
return JSValueMakeNumber(ctx, value);
}
+JSValueRef JSUtil::toJSValueRef(JSContextRef ctx, const unsigned long long value) {
+ return JSValueMakeNumber(ctx, value);
+}
+
+JSValueRef JSUtil::toJSValueRef(JSContextRef ctx, const long long value) {
+ return JSValueMakeNumber(ctx, value);
+}
+
JSValueRef JSUtil::toJSValueRef(JSContextRef ctx, const double value){
return JSValueMakeNumber(ctx, value);
}
return toJSValueRef_(ctx, value);
}
+JSValueRef JSUtil::toJSValueRef(JSContextRef ctx, const std::map<std::string, std::string>& value){
+ JSObjectRef obj = JSObjectMake(ctx, NULL, NULL);
+ std::map<std::string, std::string>::const_iterator iter;
+ for (iter = value.begin(); iter != value.end(); ++iter) {
+ std::string propName = iter->first;
+ JSUtil::setProperty(ctx, obj, propName.c_str(), JSUtil::toJSValueRef(ctx, iter->second), kJSPropertyAttributeNone);
+ }
+
+ return obj;
+}
vector<string> JSUtil::JSArrayToStringVector(JSContextRef ctx, JSValueRef value){
return JSArrayToType_<string>(ctx, value, JSUtil::JSValueToString);
#define _JSUTIL_H_
#include <JavaScriptCore/JavaScript.h>
#include <string>
+#include <map>
#include <vector>
#include "PlatformException.h"
#include <time.h>
static long JSValueToLong(JSContextRef ctx, JSValueRef value);
/**
+ * @brief Converts a JavaScript value to unsigned long number and returns the resulting unsigned long number.
+ *
+ * @param[in] ctx The execution context to use.
+ * @param[in] value The JSValue to convert.
+ *
+ * @return The result of conversion
+ *
+ * @exception TypeMismatchException
+ */
+ static unsigned long JSValueToULong(JSContextRef ctx, JSValueRef value);
+
+
+ /**
+ * @brief Converts a JavaScript value to long long number and returns the resulting long long number.
+ *
+ * @param[in] ctx The execution context to use.
+ * @param[in] value The JSValue to convert.
+ *
+ * @return The result of conversion
+ *
+ * @exception TypeMismatchException
+ */
+ static long long JSValueToLongLong(JSContextRef ctx, JSValueRef value);
+
+ /**
+ * @brief Converts a JavaScript value to unsigned long long number and returns the resulting unsigned long long number.
+ *
+ * @param[in] ctx The execution context to use.
+ * @param[in] value The JSValue to convert.
+ *
+ * @return The result of conversion
+ *
+ * @exception TypeMismatchException
+ */
+ static unsigned long long JSValueToULongLong(JSContextRef ctx, JSValueRef value);
+
+
+ /**
* @brief Converts a JavaScript value to double number and returns the resulting double number.
*
* @remarks TypeMismatchException is thrown when the result of conversion was NaN(Not a Number).
*/
static std::vector<bool> JSArrayToBoolVector(JSContextRef ctx, JSValueRef value);
+ /**
+ * @brief Converts a JavaScript value to map<string,string> and returns the resulting object.
+ *
+ * @remarks TypeMismatchException is thrown when the value was not Object type.
+ *
+ * @param[in] ctx The execution context to use.
+ * @param[in] value The JSValue to convert.
+ *
+ * @return The JSObject result of conversion
+ *
+ * @exception TypeMismatchException
+ */
+ static std::map<std::string, std::string> JSValueToStringMap(JSContextRef ctx, JSValueRef value);
/**
* @brief Creates a JavaScript value of the string type.
* @brief Creates a JavaScript value of the number type.
*
* @param[in] ctx The execution context to use.
+ * @param[in] value The unsigned long to assign to the newly created JSValue.
+ *
+ * @return A JSValue of the number type, representing the value of number.
+ */
+ static JSValueRef toJSValueRef(JSContextRef ctx, const unsigned long value);
+
+ /**
+ * @brief Creates a JavaScript value of the number type.
+ *
+ * @param[in] ctx The execution context to use.
+ * @param[in] value The long long to assign to the newly created JSValue.
+ *
+ * @return A JSValue of the number type, representing the value of number.
+ */
+ static JSValueRef toJSValueRef(JSContextRef ctx, const long long value);
+
+ /**
+ * @brief Creates a JavaScript value of the number type.
+ *
+ * @param[in] ctx The execution context to use.
+ * @param[in] value The unsigned long long to assign to the newly created JSValue.
+ *
+ * @return A JSValue of the number type, representing the value of number.
+ */
+ static JSValueRef toJSValueRef(JSContextRef ctx, const unsigned long long value);
+ /**
+ * @brief Creates a JavaScript value of the number type.
+ *
+ * @param[in] ctx The execution context to use.
* @param[in] value The double to assign to the newly created JSValue.
*
* @return A JSValue of the number type, representing the value of number.
static JSValueRef toJSValueRef(JSContextRef ctx, const std::vector<bool>& value);
/**
+ * @brief Creates a JavaScript value of the string map type.
+ *
+ * @remarks UnknownException is thrown when could not create Array object.\n
+ *
+ * @param[in] ctx The execution context to use.
+ * @param[in] value The string map to assign to the newly created JSValue
+ *
+ * @return A JSValue of the string map type
+ *
+ * @exception UnknownException
+ */
+ static JSValueRef toJSValueRef(JSContextRef ctx, const std::map<std::string, std::string>& value);
+
+ /**
* @brief Creates a JavaScript Date object with time_t value
*
* @remarks TypeMismatchException is thrown when could not create Date object.\n
m_eventMapAcc++;
- event->switchToManualAnswer();
+// event->switchToManualAnswer();
}
Catch (NotFoundException)
{
m_eventMapAcc++;
- event->switchToManualAnswer();
+// event->switchToManualAnswer();
}
Catch (InvalidArgumentException)
{
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);
+ if (!JSValueIsObjectOfClass(m_context, element, JSSyncServiceInfo::getClassRef())) {
+ ThrowMsg(ConversionException, "Wrong array element type.");
+ }
SyncServiceInfoPtr serviceInfo = JSSyncServiceInfo::getPrivateObject(toJSObjectRef(element));
resultVector.push_back(serviceInfo);
}
eventPtr->setResult(true);
- if (thisDataSyncManager->m_changeEmitters[profileDirName]) {
- thisDataSyncManager->m_changeEmitters[profileDirName]->emit(eventPtr);
- }
+ if(profileDirName) {
+ if (thisDataSyncManager->m_changeEmitters[profileDirName]) {
+ thisDataSyncManager->m_changeEmitters[profileDirName]->emit(eventPtr);
+ }
+ }
}
Catch (Exception)
{
eventPtr->setResult(true);
- if (thisDataSyncManager->m_changeEmitters[profileDirName]) {
- thisDataSyncManager->m_changeEmitters[profileDirName]->emit(eventPtr);
- }
+ if(profileDirName) {
+ if (thisDataSyncManager->m_changeEmitters[profileDirName]) {
+ thisDataSyncManager->m_changeEmitters[profileDirName]->emit(eventPtr);
+ }
+ }
}
Catch (Exception)
{
DataSyncConverter converter(context);
SyncProfileInfoPtr profile;
- if (!JSValueIsObjectOfClass(context, arguments[0], JSSyncProfileInfo::getClassRef())) {
- ThrowMsg(ConversionException, "Wrong parameter type.");
- }
+ if (argumentCount>=1) {
+ if (!JSValueIsObjectOfClass(context, arguments[0], JSSyncProfileInfo::getClassRef())) {
+ ThrowMsg(ConversionException, "Wrong parameter type.");
+ }
+ } else {
+ ThrowMsg(ConversionException, "Wrong parameter type.");
+ }
+
profile = JSSyncProfileInfo::getPrivateObject(JSValueToObject(context, arguments[0], NULL));
if (!profile) {
ThrowMsg(ConversionException, "Parameter conversion failed.");
DataSyncConverter converter(context);
SyncProfileInfoPtr profile;
- if (!JSValueIsObjectOfClass(context, arguments[0], JSSyncProfileInfo::getClassRef())) {
+ if (argumentCount>=1) {
+ if (!JSValueIsObjectOfClass(context, arguments[0], JSSyncProfileInfo::getClassRef())) {
+ ThrowMsg(ConversionException, "Wrong parameter type.");
+ }
+ } else {
ThrowMsg(ConversionException, "Wrong parameter type.");
- }
+ }
+
profile = JSSyncProfileInfo::getPrivateObject(JSValueToObject(context, arguments[0], NULL));
if (!profile) {
ThrowMsg(ConversionException, "Parameter conversion failed.");
syncProfileInfo->setProfileName(converter.toString(arguments[0]));
}
if (argumentCount>=2) {
+ if (!JSValueIsObjectOfClass(context, arguments[1], JSSyncInfo::getClassRef())) {
+ ThrowMsg(ConversionException, "Wrong second parameter type.");
+ }
syncProfileInfo->setSyncInfo(JSSyncInfo::getPrivateObject(JSValueToObject(context, arguments[1], exception)));
}
if (argumentCount>=3) {
+ if(!JSIsArrayValue(context, arguments[2])) {
+ ThrowMsg(ConversionException, "Wrong third parameter type.");
+ }
syncProfileInfo->setServiceInfo(converter.toServiceInfoList(arguments[2]));
}
LocalMessagePortKey key = { name, isTrusted };
LocalMessagePortMap::iterator iter = m_localMessagePortMap.find(key);
if(iter != m_localMessagePortMap.end())
+ {
localMessagePort = iter->second;
-
- if(localMessagePort != NULL)
LogDebug("Found cached LocalMessagePort");
+ }
return localMessagePort;
}
LocalMessagePortIdMap::iterator iter = m_localMessagePortIdMap.find(id);
if(iter != m_localMessagePortIdMap.end())
+ {
localMessagePort = iter->second;
-
- if(localMessagePort != NULL)
LogDebug("Found cached LocalMessagePort");
+ }
return localMessagePort;
}
RemoteMessagePortKey key = { appId, name, isTrusted };
RemoteMessagePortMap::iterator iter = m_remoteMessagePortMap.find(key);
if(iter != m_remoteMessagePortMap.end())
+ {
remoteMessagePort = iter->second;
-
- if(remoteMessagePort != NULL)
LogDebug("Found cached RemoteMessagePort");
+ }
return remoteMessagePort;
}
std::string name;
bool isTrusted;
bool operator<(const LocalMessagePortKey &t) const {
- return (name < t.name || isTrusted < t.isTrusted);
+ return (name < t.name || (name == t.name && isTrusted < t.isTrusted));
}
};
struct RemoteMessagePortKey {
std::string name;
bool isTrusted;
bool operator<(const RemoteMessagePortKey &t) const {
- return (appId < t.appId || name < t.name || isTrusted < t.isTrusted);
+ if(appId < t.appId) return true;
+ if(appId == t.appId) {
+ if(name < t.name) return true;
+ if(name == t.name && isTrusted < t.isTrusted)
+ return true;
+ }
+ return false;
}
};
typedef std::map<LocalMessagePortKey, LocalMessagePortPtr> LocalMessagePortMap;
}
else
{
- callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context,
- JSTizenException::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT));
- return JSValueMakeNull(context);
+ callbackManager->callOnSuccess(converter->toJSValueRef(msg));
+ return JSValueMakeNull(context);
}
privateData->setMessageJSValueRef(arguments[0]); //set Message JSValueRef.
return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage());
}
- JSNetworkBearerSelectionCallbackManagerPtr callbackManager = JSNetworkBearerSelectionCallbackManager::createObject(context);
+ JSNetworkBearerSelectionCallbackManagerPtr callbackManager = JSNetworkBearerSelectionCallbackManager::createObject(priv->getContext());
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::INVALID_VALUES_ERROR, "Invalid values error");
}
callbackManager->setOnSuccess(onsuccess);
return JSValueMakeNull(context);
}
- return converter->toJSValueRef(notification->getID());
}
else if (property == NOTIFICATION_TYPE)
{
if (noti && notification)
{
//set title.
- const char *titleStr = (notification->getTitle()).c_str();
- LogDebug("Title :" << titleStr);
+ //const char *titleStr = (notification->getTitle()).c_str();
+ LogDebug("Title :" << (notification->getTitle()).c_str());
- if (notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE, titleStr,
+ if (notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE, (notification->getTitle()).c_str(),
NULL, NOTIFICATION_VARIABLE_TYPE_NONE) != NOTIFICATION_ERROR_NONE)
{
LogDebug("set title Error");
//thumbnail.
//set icon
- const char *iconStr = (notification->getIconPath()).c_str();
- LogDebug("icon : " << iconStr);
+ //const char *iconStr = (notification->getIconPath()).c_str();
+ LogDebug("icon : " << (notification->getIconPath()).c_str());
- if (checkFilePath(iconStr) )
+ if (checkFilePath((notification->getIconPath()).c_str()) )
{
- if (notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON, iconStr)
+ if (notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON, (notification->getIconPath()).c_str())
!= NOTIFICATION_ERROR_NONE)
{
ThrowMsg(WrtDeviceApis::Commons::UnknownException, "set notification icon error");
}
//set sub icon.
- iconStr = (notification->getSubIconPath()).c_str();
- LogDebug("sub Icon : " << iconStr);
+ //iconStr = (notification->getSubIconPath()).c_str();
+ LogDebug("sub Icon : " << (notification->getSubIconPath()).c_str());
- if (notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON_SUB, iconStr)
+ if (notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON_SUB, (notification->getSubIconPath()).c_str())
!= NOTIFICATION_ERROR_NONE)
{
ThrowMsg(WrtDeviceApis::Commons::UnknownException, "set notification icon error");
}
//set background image
- iconStr = (notification->getBackground()).c_str();
- LogDebug("sub Icon : " << iconStr);
+ //iconStr = (notification->getBackground()).c_str();
+ LogDebug("sub Icon : " << (notification->getBackground()).c_str());
- if (notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_BACKGROUND, iconStr)
+ if (notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_BACKGROUND, (notification->getBackground()).c_str())
!= NOTIFICATION_ERROR_NONE)
{
ThrowMsg(WrtDeviceApis::Commons::UnknownException, "set notification icon error");
}
//set sound path.
- const char* sound = (notification->getSoundPath()).c_str();
- LogDebug("sound : " << sound);
- if ( checkFilePath(sound))
+ //const char* sound = (notification->getSoundPath()).c_str();
+ LogDebug("sound : " << (notification->getSoundPath()).c_str());
+ if ( checkFilePath((notification->getSoundPath()).c_str()))
{
- if ( notification_set_sound(noti, NOTIFICATION_SOUND_TYPE_USER_DATA, sound)
+ if ( notification_set_sound(noti, NOTIFICATION_SOUND_TYPE_USER_DATA, (notification->getSoundPath()).c_str())
!= NOTIFICATION_ERROR_NONE)
{
ThrowMsg(WrtDeviceApis::Commons::UnknownException, "set notification sound error");
}
else
{
- if ( notification_set_sound(noti, NOTIFICATION_SOUND_TYPE_DEFAULT, sound)
+ if ( notification_set_sound(noti, NOTIFICATION_SOUND_TYPE_DEFAULT, (notification->getSoundPath()).c_str())
!= NOTIFICATION_ERROR_NONE)
{
ThrowMsg(WrtDeviceApis::Commons::UnknownException, "set notification sound error");
}
//check layout.
- NotificationType type = notification->getNotiType();
+ int type = (int)notification->getNotiType();
notification_ly_type_e noti_layout = NOTIFICATION_LY_NONE;
switch (type)
else
{
notification_set_property(handle, 0);
- notification_set_execute_option(handle, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, NULL, NULL, service_data);
+ ret = notification_set_execute_option(handle, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, NULL, NULL, service_data);
+ if (ret != NOTIFICATION_ERROR_NONE)
+ {
+ LogError("notification_set_execute_option fail");
+ ThrowMsg(WrtDeviceApis::Commons::PlatformException, "set execute option fail, Error Code : " << ret);
+ }
bundle_free(service_data);
}
if ( notification->getUpdatedFlag())
{
- NotificationType type = notification->getNotiType();
+ int type = (int)notification->getNotiType();
notification_ly_type_e noti_layout = NOTIFICATION_LY_NONE;
switch (type)
ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Can't get noti list");
}
- INotificationPtr notification;
-
while ( noti_list != NULL)
{
noti = notification_list_get_data(noti_list);
int noti_priv = -1;
notification_get_id(noti, NULL, ¬i_priv);
LogDebug(" notification id = " << noti_priv);
-
INotificationPtr notification =
NotificationFactory::getInstance().getNotification(noti_priv);
data->setValue(keyValue);
(*appControl)->addAppControlData(data);
}
+
+ if(value)
+ free(value);
+
}
}
return true;
type = NOTIFICATION_IMAGE_TYPE_NONE;
}
- if ( type != NOTIFICATION_TEXT_TYPE_NONE)
+ if ( type != NOTIFICATION_IMAGE_TYPE_NONE)
{
if (getThumbnail(index).compare(thumb))
{
service_h service = NULL;
int retcode = 0;
- int error = 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)
{
JSObjectRef eventCBObj = validator.toObject(1, true);
JSObjectRef errCB = validator.toFunction(2, true);
- JSValueRef onprogress = JSUtils::getJSProperty(context, eventCBObj, "onprogress");
- JSValueRef oncomplete = JSUtils::getJSProperty(context, eventCBObj, "oncomplete");
+ JSValueRef onprogress = JSUtils::getJSPropertyOrUndefined(context, eventCBObj, "onprogress");
+ JSValueRef oncomplete = JSUtils::getJSPropertyOrUndefined(context, eventCBObj, "oncomplete");
+
+ CallbackUserData *onprogressCb = NULL;
+ CallbackUserData *oncompleteCb = NULL;
+ CallbackUserData *onerrorCb = NULL;
Converter converter(context);
- if (!JSObjectIsFunction(context, converter.toJSObjectRef(onprogress)) ||
- !JSObjectIsFunction(context, converter.toJSObjectRef(oncomplete))) {
- return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong second parameter type");
+ if (JSValueIsNull(context, onprogress) || JSValueIsUndefined(context, onprogress)) {
+ LogDebug("onprogress is not defined");
+ } else if (JSObjectIsFunction(context, converter.toJSObjectRef(onprogress))) {
+ onprogressCb = new CallbackUserData(GlobalContextManager::getInstance()->getGlobalContext(context));
+ onprogressCb->setSuccessCallback(onprogress);
+ } else {
+ return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "onprogress is not function");
}
- CallbackUserData *onprogressCb = new CallbackUserData(GlobalContextManager::getInstance()->getGlobalContext(context));
- onprogressCb->setSuccessCallback(onprogress);
-
- CallbackUserData *oncompleteCb = new CallbackUserData(GlobalContextManager::getInstance()->getGlobalContext(context));
- oncompleteCb->setSuccessCallback(oncomplete);
-
- if (argumentCount > 2) {
- oncompleteCb->setErrorCallback(errCB);
+ if (JSValueIsNull(context, oncomplete) || JSValueIsUndefined(context, oncomplete)) {
+ LogDebug("oncomplete is not defined");
+ } else if (JSObjectIsFunction(context, converter.toJSObjectRef(oncomplete))) {
+ oncompleteCb = new CallbackUserData(GlobalContextManager::getInstance()->getGlobalContext(context));
+ oncompleteCb->setSuccessCallback(oncomplete);
+ } else {
+ return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "oncomplete is not function");
}
- PackageInstallEventCallback *pkgInstallEventCB = new PackageInstallEventCallback(onprogressCb, oncompleteCb);
+ if (errCB) {
+ onerrorCb = new CallbackUserData(GlobalContextManager::getInstance()->getGlobalContext(context));
+ onerrorCb->setSuccessCallback(errCB);
+ }
+ PackageInstallEventCallback *pkgInstallEventCB = new PackageInstallEventCallback(GlobalContextManager::getInstance()->getGlobalContext(context), onprogressCb, oncompleteCb, onerrorCb);
+
PackageManager::getInstance()->install(path, pkgInstallEventCB);
} catch (const TypeMismatchException& err ) {
return JSWebAPIError::throwException(context, exception, err);
JSObjectRef eventCBObj = validator.toObject(1, true);
JSObjectRef errCB = validator.toFunction(2, true);
- JSValueRef onprogress = JSUtils::getJSProperty(context, eventCBObj, "onprogress");
- JSValueRef oncomplete = JSUtils::getJSProperty(context, eventCBObj, "oncomplete");
+ JSValueRef onprogress = JSUtils::getJSPropertyOrUndefined(context, eventCBObj, "onprogress");
+ JSValueRef oncomplete = JSUtils::getJSPropertyOrUndefined(context, eventCBObj, "oncomplete");
+
+ CallbackUserData *onprogressCb = NULL;
+ CallbackUserData *oncompleteCb = NULL;
+ CallbackUserData *onerrorCb = NULL;
Converter converter(context);
- if (!JSObjectIsFunction(context, converter.toJSObjectRef(onprogress)) ||
- !JSObjectIsFunction(context, converter.toJSObjectRef(oncomplete))) {
- return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong second parameter type");
+ if (JSValueIsNull(context, onprogress) || JSValueIsUndefined(context, onprogress)) {
+ LogDebug("onprogress is not defined");
+ } else if (JSObjectIsFunction(context, converter.toJSObjectRef(onprogress))) {
+ onprogressCb = new CallbackUserData(GlobalContextManager::getInstance()->getGlobalContext(context));
+ onprogressCb->setSuccessCallback(onprogress);
+ } else {
+ return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "onprogress is not function");
}
-
- CallbackUserData *onprogressCb = new CallbackUserData(GlobalContextManager::getInstance()->getGlobalContext(context));
- onprogressCb->setSuccessCallback(onprogress);
- CallbackUserData *oncompleteCb = new CallbackUserData(GlobalContextManager::getInstance()->getGlobalContext(context));
- oncompleteCb->setSuccessCallback(oncomplete);
+ if (JSValueIsNull(context, oncomplete) || JSValueIsUndefined(context, oncomplete)) {
+ LogDebug("oncomplete is not defined");
+ } else if (JSObjectIsFunction(context, converter.toJSObjectRef(oncomplete))) {
+ oncompleteCb = new CallbackUserData(GlobalContextManager::getInstance()->getGlobalContext(context));
+ oncompleteCb->setSuccessCallback(oncomplete);
+ } else {
+ return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "oncomplete is not function");
+ }
- if (argumentCount > 2) {
- oncompleteCb->setErrorCallback(errCB);
+ if (errCB) {
+ onerrorCb = new CallbackUserData(GlobalContextManager::getInstance()->getGlobalContext(context));
+ onerrorCb->setSuccessCallback(errCB);
}
- PackageInstallEventCallback *pkgInstallEventCB = new PackageInstallEventCallback(onprogressCb, oncompleteCb);
+ PackageInstallEventCallback *pkgInstallEventCB = new PackageInstallEventCallback(GlobalContextManager::getInstance()->getGlobalContext(context), onprogressCb, oncompleteCb, onerrorCb);
PackageManager::getInstance()->uninstall(id, pkgInstallEventCB);
} catch (const TypeMismatchException& err ) {
try {
ArgumentValidator validator(context, argumentCount, arguments);
-
- JSObjectRef eventCBObj = validator.toObject(0);
- JSValueRef oninstalled = JSUtils::getJSProperty(context, eventCBObj, "oninstalled");
- JSValueRef onupdated = JSUtils::getJSProperty(context, eventCBObj, "onupdated");
- JSValueRef onuninstalled = JSUtils::getJSProperty(context, eventCBObj, "onuninstalled");
- Converter converter(context);
- if (!JSObjectIsFunction(context, converter.toJSObjectRef(oninstalled)) ||
- !JSObjectIsFunction(context, converter.toJSObjectRef(onupdated)) ||
- !JSObjectIsFunction(context, converter.toJSObjectRef(onuninstalled))) {
- return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong second parameter type");
- }
+ JSObjectRef eventCBObj = validator.toObject(0);
+ JSValueRef oninstalled = JSUtils::getJSPropertyOrUndefined(context, eventCBObj, "oninstalled");
+ JSValueRef onupdated = JSUtils::getJSPropertyOrUndefined(context, eventCBObj, "onupdated");
+ JSValueRef onuninstalled = JSUtils::getJSPropertyOrUndefined(context, eventCBObj, "onuninstalled");
- CallbackUserData *oninstalledCb = new CallbackUserData(GlobalContextManager::getInstance()->getGlobalContext(context));
- oninstalledCb->setSuccessCallback(oninstalled);
+ CallbackUserData *oninstalledCb = NULL;
+ CallbackUserData *onupdatedCb = NULL;
+ CallbackUserData *onuninstalledCb = NULL;
- CallbackUserData *onupdatedCb = new CallbackUserData(GlobalContextManager::getInstance()->getGlobalContext(context));
- onupdatedCb->setSuccessCallback(onupdated);
+ Converter converter(context);
+ if (JSValueIsNull(context, oninstalled) || JSValueIsUndefined(context, oninstalled)) {
+ LogDebug("oninstalled is not defined");
+ } else if (JSObjectIsFunction(context, converter.toJSObjectRef(oninstalled))) {
+ oninstalledCb = new CallbackUserData(GlobalContextManager::getInstance()->getGlobalContext(context));
+ oninstalledCb->setSuccessCallback(oninstalled);
+ } else {
+ return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "oninstalled is not function");
+ }
+
+ if (JSValueIsNull(context, onupdated) || JSValueIsUndefined(context, onupdated)) {
+ LogDebug("onupdated is not defined");
+ } else if (JSObjectIsFunction(context, converter.toJSObjectRef(onupdated))) {
+ onupdatedCb = new CallbackUserData(GlobalContextManager::getInstance()->getGlobalContext(context));
+ onupdatedCb->setSuccessCallback(onupdated);
+ } else {
+ return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "onupdated is not function");
+ }
- CallbackUserData *onuninstalledCb = new CallbackUserData(GlobalContextManager::getInstance()->getGlobalContext(context));
- onuninstalledCb->setSuccessCallback(onuninstalled);
+ if (JSValueIsNull(context, onuninstalled) || JSValueIsUndefined(context, onuninstalled)) {
+ LogDebug("onuninstalled is not defined");
+ } else if (JSObjectIsFunction(context, converter.toJSObjectRef(onuninstalled))) {
+ onuninstalledCb = new CallbackUserData(GlobalContextManager::getInstance()->getGlobalContext(context));
+ onuninstalledCb->setSuccessCallback(onuninstalled);
+ } else {
+ return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "onuninstalled is not function");
+ }
PackageInfoEventCallback *pkginfoEventCB = new PackageInfoEventCallback(oninstalledCb, onupdatedCb, onuninstalledCb);
}
-PackageInstallEventCallback::PackageInstallEventCallback(CallbackUserData* onprogress, CallbackUserData* oncomplete)
+PackageInstallEventCallback::PackageInstallEventCallback(JSContextRef globalCtx, CallbackUserData* onprogress, CallbackUserData* oncomplete, CallbackUserData* onerror)
{
+ m_context = globalCtx;
m_onprogress = onprogress;
m_oncomplete = oncomplete;
+ m_onerror = onerror;
+
m_request_handle = NULL;
}
-
-
PackageInstallEventCallback::~PackageInstallEventCallback()
{
if (m_request_handle != NULL) {
return m_oncomplete;
}
+CallbackUserData* PackageInstallEventCallback::getOnError()
+{
+ return m_onerror;
+}
+
+JSContextRef PackageInstallEventCallback::getContext()
+{
+ return m_context;
+}
+
void PackageInstallEventCallback::setHandle(package_manager_request_h handle)
{
m_request_handle = handle;
pkgmgrinfo_appinfo_destroy_appinfo(handle);
CallbackUserData *callback = eventCB->getOnInstalled();
- callback->callSuccessCallback(JSPackageInformation::createJSObject(callback->getContext(), pkgInfo));
+ if (callback) {
+ callback->callSuccessCallback(JSPackageInformation::createJSObject(callback->getContext(), pkgInfo));
+ }
break;
}
case PACAKGE_MANAGER_EVENT_TYPE_UNINSTALL: {
- CallbackUserData *callback = eventCB->getOnUninstalled();
- Converter converter(callback->getContext());
LogDebug("uninstall : " << package);
- callback->callSuccessCallback(converter.toJSValueRef(package));
+ CallbackUserData *callback = eventCB->getOnUninstalled();
+ if (callback) {
+ Converter converter(callback->getContext());
+ callback->callSuccessCallback(converter.toJSValueRef(package));
+ }
break;
}
case PACAKGE_MANAGER_EVENT_TYPE_UPDATE: {
pkgmgrinfo_appinfo_destroy_appinfo(handle);
CallbackUserData *callback = eventCB->getOnUpdated();
- callback->callSuccessCallback(JSPackageInformation::createJSObject(callback->getContext(), pkgInfo));
+ if (callback) {
+ callback->callSuccessCallback(JSPackageInformation::createJSObject(callback->getContext(), pkgInfo));
+ }
break;
}
default:
{
LogDebug("install_request_cb ");
PackageInstallEventCallback *callback = (PackageInstallEventCallback *)user_data;
- JSContextRef context = callback->getOnComplete()->getContext();
+ JSContextRef context = callback->getContext();;
switch (event_state) {
case PACAKGE_MANAGER_EVENT_STATE_COMPLETED: {
- Converter converter(context);
- callback->getOnComplete()->callSuccessCallback(converter.toJSValueRef(package));
-
LogDebug("destroy client handle");
+ if (callback->getOnComplete()) {
+ Converter converter(context);
+ callback->getOnComplete()->callSuccessCallback(converter.toJSValueRef(package));
+ }
+
// this api is not supported from platform.
//package_manager_request_destroy(callback->getHandle());
package_manager_client_destroy(callback->getHandle());
jsError = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR,"platform exception");
}
- callback->getOnComplete()->callErrorCallback(jsError);
+ if (callback->getOnError()) {
+ callback->getOnError()->callSuccessCallback(jsError);
+ }
LogDebug("destroy client handle");
// this api is not supported from platform.
}
case PACAKGE_MANAGER_EVENT_STATE_STARTED:
case PACAKGE_MANAGER_EVENT_STATE_PROCESSING: {
- Converter converter(context);
- JSValueRef args[2] = {converter.toJSValueRef(package), converter.toJSValueRef(progress)};
- callback->getOnProgress()->callSuccessCallback(2, args);
+ if (callback->getOnProgress()) {
+ Converter converter(context);
+ JSValueRef args[2] = {converter.toJSValueRef(package), converter.toJSValueRef(progress)};
+ callback->getOnProgress()->callSuccessCallback(2, args);
+ }
break;
}
default:
JSValueRef error = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR,"platform exception");
- callback->getOnComplete()->callErrorCallback(error);
+ if (callback->getOnError()) {
+ callback->getOnError()->callSuccessCallback(error);
+ }
LogDebug("destroy client handle");
// this api is not supported from platform.
//package_manager_request_destroy(callback->getHandle());
int ret = 0;
int id = 0;
package_manager_request_h request_h;
- JSContextRef globalCtx = callback->getOnComplete()->getContext();
-
+ JSContextRef globalCtx = callback->getContext();
+ CallbackUserData* errCallback = callback->getOnError();
+
ret = package_manager_request_create(&request_h);
if (ret != PACKAGE_MANAGER_ERROR_NONE) {
- JSValueRef error =
- JSTizenExceptionFactory::makeErrorObject(globalCtx, JSTizenException::UNKNOWN_ERROR, "Platform Error");
- callback->getOnComplete()->callErrorCallback(error);
+ if (errCallback) {
+ JSValueRef error =
+ JSTizenExceptionFactory::makeErrorObject(globalCtx, JSTizenException::UNKNOWN_ERROR, "Platform Error");
+ errCallback->callSuccessCallback(error);
+ }
return;
}
ret = package_manager_request_install(request_h, pkgPath.c_str(), &id);
if (ret != PACKAGE_MANAGER_ERROR_NONE) {
LogDebug("error : " << pkgPath);
- JSValueRef error =
- JSTizenExceptionFactory::makeErrorObject(globalCtx, JSTizenException::NOT_FOUND_ERROR, "Not proper file");
- callback->getOnComplete()->callErrorCallback(error);
+ if (errCallback) {
+ JSValueRef error =
+ JSTizenExceptionFactory::makeErrorObject(globalCtx, JSTizenException::NOT_FOUND_ERROR, "Not proper file");
+ errCallback->callSuccessCallback(error);
+ }
return;
}
ret = package_manager_request_set_event_cb(request_h, install_request_cb, callback);
if (ret != PACKAGE_MANAGER_ERROR_NONE) {
- JSValueRef error =
- JSTizenExceptionFactory::makeErrorObject(globalCtx, JSTizenException::UNKNOWN_ERROR, "Platform Error");
- callback->getOnComplete()->callErrorCallback(error);
+ if (errCallback) {
+ JSValueRef error =
+ JSTizenExceptionFactory::makeErrorObject(globalCtx, JSTizenException::UNKNOWN_ERROR, "Platform Error");
+ errCallback->callSuccessCallback(error);
+ }
return;
}
}
int ret = 0;
int id = 0;
package_manager_request_h request_h;
- JSContextRef globalCtx = callback->getOnComplete()->getContext();
-
+ JSContextRef globalCtx = callback->getContext();
+ CallbackUserData* errCallback = callback->getOnError();
+
ret = package_manager_request_create(&request_h);
if (ret != PACKAGE_MANAGER_ERROR_NONE) {
- JSValueRef error =
- JSTizenExceptionFactory::makeErrorObject(globalCtx, JSTizenException::UNKNOWN_ERROR, "Platform Error");
- callback->getOnComplete()->callErrorCallback(error);
+ if (errCallback) {
+ JSValueRef error =
+ JSTizenExceptionFactory::makeErrorObject(globalCtx, JSTizenException::UNKNOWN_ERROR, "Platform Error");
+ errCallback->callSuccessCallback(error);
+ }
return;
}
ret = package_manager_request_uninstall(request_h, pkgPath.c_str(), &id);
if (ret != PACKAGE_MANAGER_ERROR_NONE) {
LogDebug("error : " << pkgPath);
- JSValueRef error =
- JSTizenExceptionFactory::makeErrorObject(globalCtx, JSTizenException::NOT_FOUND_ERROR, "Not proper file");
- // TODO: how can I handle about uninstallable package???
- callback->getOnComplete()->callErrorCallback(error);
+ if (errCallback) {
+ JSValueRef error =
+ JSTizenExceptionFactory::makeErrorObject(globalCtx, JSTizenException::NOT_FOUND_ERROR, "Not proper file");
+ // TODO: how can I handle about uninstallable package???
+ errCallback->callSuccessCallback(error);
+ }
return;
}
ret = package_manager_request_set_event_cb(request_h, install_request_cb, callback);
if (ret != PACKAGE_MANAGER_ERROR_NONE) {
- JSValueRef error =
- JSTizenExceptionFactory::makeErrorObject(globalCtx, JSTizenException::UNKNOWN_ERROR, "Platform Error");
- callback->getOnComplete()->callErrorCallback(error);
+ if (errCallback) {
+ JSValueRef error =
+ JSTizenExceptionFactory::makeErrorObject(globalCtx, JSTizenException::UNKNOWN_ERROR, "Platform Error");
+ errCallback->callSuccessCallback(error);
+ }
return;
}
}
class PackageInstallEventCallback
{
public:
- PackageInstallEventCallback(CallbackUserData* onprogress, CallbackUserData* oncomplete);
+ PackageInstallEventCallback(JSContextRef globalCtx, CallbackUserData* onprogress, CallbackUserData* oncomplete, CallbackUserData* onerror);
~PackageInstallEventCallback();
CallbackUserData* getOnProgress();
CallbackUserData* getOnComplete();
+ CallbackUserData* getOnError();
+ JSContextRef getContext();
void setHandle(package_manager_request_h handle);
package_manager_request_h getHandle();
private:
CallbackUserData* m_onprogress;
CallbackUserData* m_oncomplete;
+ CallbackUserData* m_onerror;
package_manager_request_h m_request_handle;
+ JSContextRef m_context;
};
void PowerManager::setScreenBrightness(double brightness){
int ret;
+ if( brightness > 1 || brightness < 0 )
+ throw InvalidValuesException("brightness should be 0 <= brightness <= 1");
ret = device_set_brightness(0, (int)(brightness*100));
if( DEVICE_ERROR_NONE!=ret )
throw UnknownException("Platform error while setting brightness.");
#include <memory>
#include <dpl/log/log.h>
+#include <JSTizenExceptionFactory.h>
+#include <JSTizenException.h>
+#include <SecurityExceptions.h>
#include "JSCellularNetworkInfo.h"
#include "plugin_config.h"
namespace Systeminfo {
using namespace WrtDeviceApis::CommonsJavaScript;
using namespace WrtDeviceApis::Commons;
+using namespace DeviceAPI::Common;
namespace {
const char* CELLULARNETWORK_STATUS_PROPERTY = "status";
return convert.toJSValueRef(cellularNetworkInfo->isFlightMode);
} else if (JSStringIsEqualToUTF8CString(propertyName, CELLULARNETWORK_IMEI_PROPERTY)) {
AceSecurityStatus status = SYSTEMINFO_CHECK_ACCESS(SYSTEMINFO_FUNCTION_API_GET_PROPERTY_IMEI_VALUE);
- if ((status == AceSecurityStatus::AccessDenied) || (status == AceSecurityStatus::InternalError)) {
- LogDebug("security error");
- }
- else {
- return convert.toJSValueRef(cellularNetworkInfo->imei);
- }
+ TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+ return convert.toJSValueRef(cellularNetworkInfo->imei);
}
}
Catch(Exception)
#include <memory>
#include <dpl/log/log.h>
+#include <JSTizenExceptionFactory.h>
+#include <JSTizenException.h>
+#include <SecurityExceptions.h>
#include "JSDeviceCapabilitiesInfo.h"
#include "plugin_config.h"
namespace Systeminfo {
using namespace WrtDeviceApis::CommonsJavaScript;
using namespace WrtDeviceApis::Commons;
+using namespace DeviceAPI::Common;
namespace {
const char* DEVICE_CAPABILITIES_BLUETOOTH = "bluetooth";
return convert.toJSValueRef(deviceCapabilitiesInfo->fmRadio);
} else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_PLATFORMVERSION)) {
AceSecurityStatus status = SYSTEMINFO_CHECK_ACCESS(SYSTEMINFO_FUNCTION_API_GET_CAPABILITIES);
- if ((status == AceSecurityStatus::AccessDenied) || (status == AceSecurityStatus::InternalError)) {
- LogDebug("security error");
- }
- else {
- return convert.toJSValueRef(deviceCapabilitiesInfo->platformVersion);
- }
+ TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+ return convert.toJSValueRef(deviceCapabilitiesInfo->platformVersion);
} else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_PLATFORMNAME)) {
return convert.toJSValueRef(deviceCapabilitiesInfo->platformName);
} else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_WEBAPIVERSION)) {
AceSecurityStatus status = SYSTEMINFO_CHECK_ACCESS(SYSTEMINFO_FUNCTION_API_GET_CAPABILITIES);
- if ((status == AceSecurityStatus::AccessDenied) || (status == AceSecurityStatus::InternalError)) {
- LogDebug("security error");
- }
- else {
- return convert.toJSValueRef(deviceCapabilitiesInfo->webApiVersion);
- }
+ TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+ return convert.toJSValueRef(deviceCapabilitiesInfo->webApiVersion);
} else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_NATIVEAPIVERSION)) {
AceSecurityStatus status = SYSTEMINFO_CHECK_ACCESS(SYSTEMINFO_FUNCTION_API_GET_CAPABILITIES);
- if ((status == AceSecurityStatus::AccessDenied) || (status == AceSecurityStatus::InternalError)) {
- LogDebug("security error");
- }
- else {
- return convert.toJSValueRef(deviceCapabilitiesInfo->nativeApiVersion);
- }
+ TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+ return convert.toJSValueRef(deviceCapabilitiesInfo->nativeApiVersion);
} else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_CAMERAFRONT)) {
return convert.toJSValueRef(deviceCapabilitiesInfo->cameraFront);
} else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_CAMERAFRONTFLASH)) {
#define WRTPLUGINS_TIZEN1_0_DEVICE_CAPABILITIES_INFO_H_
#include <JavaScriptCore/JavaScript.h>
-#include <SecurityExceptions.h>
#include "SysteminfoPropertyInfo.h"
namespace DeviceAPI {
#include <memory>
#include <dpl/log/log.h>
+#include <JSTizenExceptionFactory.h>
+#include <JSTizenException.h>
#include <SecurityExceptions.h>
#include "JSSIMInfo.h"
#include "plugin_config.h"
namespace Systeminfo {
using namespace WrtDeviceApis::CommonsJavaScript;
using namespace WrtDeviceApis::Commons;
+using namespace DeviceAPI::Common;
namespace {
const char* SIM_OPERATORNAME_PROPERTY = "operatorName";
}
AceSecurityStatus status = SYSTEMINFO_CHECK_ACCESS(SYSTEMINFO_FUNCTION_API_GET_PROPERTY_SIM_VALUE);
- if ((status == AceSecurityStatus::AccessDenied) || (status == AceSecurityStatus::InternalError)) {
- LogDebug("security error");
- return JSValueMakeUndefined(context);
- }
+ TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
Try
{
connection_profile_h profileHandle = NULL;
connection_address_family_e addressFamily = CONNECTION_ADDRESS_FAMILY_IPV4;
char* ipAddr = NULL;
- char* bssid = NULL;
+ char* essid = NULL;
int rssi = 0;
if (connection_get_type(connectionHandle, &connectionType) != CONNECTION_ERROR_NONE) {
return JSWifiNetworkInfo::createJSObject(context, wifiNetwork);
}
- if (connection_profile_get_wifi_bssid(profileHandle, &bssid) == CONNECTION_ERROR_NONE) {
- wifiNetwork->ssid = bssid;
- free(bssid);
+ if (connection_profile_get_wifi_essid(profileHandle, &essid) == CONNECTION_ERROR_NONE) {
+ wifiNetwork->ssid = essid;
+ free(essid);
}
if (connection_profile_get_ip_address(profileHandle, addressFamily, &ipAddr) == CONNECTION_ERROR_NONE) {