Update change log and spec for wrt-plugins-tizen_0.4.8
authorJihwa Park <jh7979.park@samsung.com>
Mon, 18 Mar 2013 14:09:06 +0000 (07:09 -0700)
committerJihwa Park <jh7979.park@samsung.com>
Mon, 18 Mar 2013 14:38:30 +0000 (07:38 -0700)
[Issue#] N/A
[Problem] N/A
[Cause] N/A
[Solution] [Common] add JSUtil::JSValuetoStringMap() and ArgumentValidator::toStringMap()

[Issue#] N/A
[Problem] Non object value was converted to object
[Cause] JSC was supporting convert from number , string to object
[Solution] check through JSValueIsObject API

[Issue#] N/A
[Problem] N/A
[Cause] N/A
[Solution] [Common] JSUtil fix error message of JSValueToTimeT

[Issue#] N/A
[Problem] Sometimes occured crash while getting existing ports
[Cause] Problems on searching existing port
[Solution] Fix compairing algorithm

[SCMRequest] N/A

Change-Id: I05e84701f20805d2aa155c9b9a95f60e587b5832

28 files changed:
packaging/wrt-plugins-tizen.spec
pkgconfigs/wrt-plugins-tizen-common.pc.in
src/Application/JSApplicationManager.cpp [changed mode: 0644->0755]
src/Common/ArgumentValidator.cpp
src/Common/ArgumentValidator.h
src/Common/JSUtil.cpp
src/Common/JSUtil.h
src/Contact/ContactManager.cpp
src/DataSync/DataSyncConverter.cpp
src/DataSync/DataSyncManager.cpp
src/DataSync/JSDataSyncManager.cpp
src/DataSync/JSSyncProfileInfo.cpp
src/MessagePort/MessagePortManagerProxy.cpp [changed mode: 0644->0755]
src/MessagePort/MessagePortManagerProxy.h [changed mode: 0644->0755]
src/Messaging/JSMessagingService.cpp [changed mode: 0644->0755]
src/NetworkBearerSelection/JSNetworkBearerSelection.cpp
src/Notification/JSStatusNotification.cpp
src/Notification/NotificationManager.cpp
src/Notification/StatusNotification.cpp
src/Package/JSPackageManager.cpp [changed mode: 0644->0755]
src/Package/PackageManager.cpp [changed mode: 0644->0755]
src/Package/PackageManager.h [changed mode: 0644->0755]
src/Power/PowerManager.cpp
src/Systeminfo/JSCellularNetworkInfo.cpp
src/Systeminfo/JSDeviceCapabilitiesInfo.cpp
src/Systeminfo/JSDeviceCapabilitiesInfo.h
src/Systeminfo/JSSIMInfo.cpp
src/Systeminfo/Systeminfo.cpp

index e139627..e53aeff 100755 (executable)
@@ -1,6 +1,6 @@
 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
index 567eecf..aafd529 100755 (executable)
@@ -2,12 +2,12 @@ prefix=/usr
 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
old mode 100644 (file)
new mode 100755 (executable)
index ebade08..892fe71
@@ -469,11 +469,20 @@ JSValueRef JSApplicationManager::launchAppControl(JSContextRef context,
                                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])) {
@@ -919,7 +928,8 @@ JSValueRef JSApplicationManager::addAppInfoEventListener(JSContextRef context,
        }
 
        Try {
-       if (argumentCount == 0) {
+       ApplicationUtil util(context, exception);
+       if ((argumentCount < 1) || (!util.isObject(arguments[0]))) {
                ThrowMsg(ConversionException, "Wrong parameter type.");
        }
 
@@ -930,16 +940,21 @@ JSValueRef JSApplicationManager::addAppInfoEventListener(JSContextRef context,
            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));
index 6d8d6a5..15e5dcf 100755 (executable)
@@ -54,29 +54,38 @@ JSValueRef ArgumentValidator::getArgument(int index, bool nullable){
     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");
     }
@@ -128,6 +137,9 @@ JSObjectRef ArgumentValidator::toObject(int index, bool nullable){
     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);
@@ -237,6 +249,14 @@ std::vector<JSValueRef> ArgumentValidator::toJSValueRefVector(int index, bool nu
     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);
+}
 
 
 }
index b128ad5..1ccd497 100755 (executable)
@@ -20,6 +20,7 @@
 
 #include <string>
 #include <vector>
+#include <map>
 #include <JavaScriptCore/JavaScript.h>
 #include <ctime>
 
@@ -31,7 +32,11 @@ public:
     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);
@@ -49,6 +54,8 @@ public:
     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;
index b049769..80a98ad 100755 (executable)
@@ -61,7 +61,6 @@ string JSUtil::JSStringToString(JSContextRef ctx, JSStringRef str){
         JSStringGetUTF8CString(str, buffer, jsSize);
         result = buffer;
     }
-    JSStringRelease(str);
     return result;
 }
 
@@ -83,8 +82,26 @@ string JSUtil::JSValueToString(JSContextRef ctx, JSValueRef value){
 }
 
 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);
     }
@@ -92,6 +109,7 @@ long JSUtil::JSValueToLong(JSContextRef ctx, JSValueRef value){
 }
 
 
+
 double JSUtil::JSValueToDouble(JSContextRef ctx, JSValueRef value){
     JSValueRef exception = NULL;
 
@@ -110,11 +128,16 @@ bool JSUtil::JSValueToBoolean(JSContextRef ctx, JSValueRef value){
 }
 
 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");
@@ -128,11 +151,24 @@ JSObjectRef JSUtil::JSValueToObject(JSContextRef ctx, JSValueRef value){
     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];
@@ -154,10 +190,22 @@ JSValueRef JSUtil::toJSValueRef(JSContextRef ctx, const string& str){
     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);
 }
@@ -182,7 +230,17 @@ JSValueRef JSUtil::toJSValueRef(JSContextRef ctx, const std::vector<bool>& 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);
index 27c5f04..ca21527 100755 (executable)
@@ -19,6 +19,7 @@
 #define _JSUTIL_H_
 #include <JavaScriptCore/JavaScript.h>
 #include <string>
+#include <map>
 #include <vector>
 #include "PlatformException.h"
 #include <time.h>
@@ -95,6 +96,44 @@ public:
     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).
@@ -224,6 +263,19 @@ public:
      */
     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.
@@ -249,6 +301,35 @@ public:
      * @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.
@@ -326,6 +407,20 @@ public:
     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
index 24d566b..e6dcbdf 100755 (executable)
@@ -411,7 +411,7 @@ void ContactManager::managerUpdateBatch(const EventContactManagerUpdateBatchPtr
 
                m_eventMapAcc++;
 
-               event->switchToManualAnswer();
+//             event->switchToManualAnswer();
        }
        Catch (NotFoundException)
        {
@@ -626,7 +626,7 @@ void ContactManager::managerRemoveBatch(const EventContactManagerRemoveBatchPtr
 
                m_eventMapAcc++;
 
-               event->switchToManualAnswer();
+//             event->switchToManualAnswer();
        }
        Catch (InvalidArgumentException)
        {
index 27c8d7f..c123211 100755 (executable)
@@ -221,6 +221,9 @@ SyncServiceInfoListPtr DataSyncConverter::toServiceInfoList(JSValueRef serviceIn
     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);
     }
index 30afa26..b0a69a3 100755 (executable)
@@ -90,9 +90,11 @@ static int datasync_state_changed_cb(sync_agent_event_data_s* request, void *use
 
         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)
     {
@@ -173,9 +175,11 @@ static int datasync_progress_cb(sync_agent_event_data_s* request, void *user_dat
 
         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)
     {
index 2315b34..69e4df2 100755 (executable)
@@ -148,9 +148,14 @@ JSValueRef JSDataSyncManager::add(JSContextRef context,
         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.");
@@ -226,9 +231,14 @@ JSValueRef JSDataSyncManager::update(JSContextRef context,
         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.");
index 3ed9f3f..d523e04 100755 (executable)
@@ -159,9 +159,15 @@ JSObjectRef JSSyncProfileInfo::constructor(JSContextRef context,
                        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]));
         }
 
old mode 100644 (file)
new mode 100755 (executable)
index 702476e..d4c2358
@@ -231,10 +231,10 @@ LocalMessagePortPtr MessagePortManagerProxy::getCachedLocalMessagePort(string &n
        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;
 }
@@ -245,10 +245,10 @@ LocalMessagePortPtr MessagePortManagerProxy::getCachedLocalMessagePort(int id)
 
        LocalMessagePortIdMap::iterator iter = m_localMessagePortIdMap.find(id);
        if(iter != m_localMessagePortIdMap.end())
+       {
                localMessagePort = iter->second;
-
-       if(localMessagePort != NULL)
                LogDebug("Found cached LocalMessagePort");
+       }
 
        return localMessagePort;
 }
@@ -268,10 +268,10 @@ RemoteMessagePortPtr MessagePortManagerProxy::getCachedRemoteMessagePort(string
        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;
 }
old mode 100644 (file)
new mode 100755 (executable)
index b411f17..faaa789
@@ -69,7 +69,7 @@ private:
                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 {
@@ -77,7 +77,13 @@ private:
                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;
old mode 100644 (file)
new mode 100755 (executable)
index 374d47e..69d88de
@@ -578,9 +578,8 @@ JSValueRef JSMessagingService::loadMessageBody(JSContextRef context,
                                }
                                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.
index 748d649..56621d0 100755 (executable)
@@ -178,12 +178,12 @@ JSValueRef JSNetworkBearerSelection::requestRouteToHost(JSContextRef context, JS
         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);
index 2f487b8..4523122 100755 (executable)
@@ -379,7 +379,6 @@ JSValueRef JSStatusNotification::getProperty(JSContextRef context,
                                return JSValueMakeNull(context);
                        }
                        
-                       return converter->toJSValueRef(notification->getID());
                }
                else if (property == NOTIFICATION_TYPE)
                {
index 783221c..8df0cb0 100755 (executable)
@@ -310,10 +310,10 @@ void NotificationManager::updateNotification(notification_h noti, INotificationP
        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");
@@ -402,12 +402,12 @@ void NotificationManager::updateNotification(notification_h noti, INotificationP
                //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");
@@ -420,20 +420,20 @@ void NotificationManager::updateNotification(notification_h noti, INotificationP
                }
                
                //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");
@@ -456,11 +456,11 @@ void NotificationManager::updateNotification(notification_h noti, INotificationP
                }
 
                //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");
@@ -468,7 +468,7 @@ void NotificationManager::updateNotification(notification_h noti, INotificationP
                }
                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");
@@ -514,7 +514,7 @@ void NotificationManager::post(INotificationPtr notification)
                        }
 
                        //check layout.
-                       NotificationType type = notification->getNotiType();
+                       int type = (int)notification->getNotiType();
                        notification_ly_type_e noti_layout = NOTIFICATION_LY_NONE;
                        
                        switch (type)
@@ -804,7 +804,12 @@ void NotificationManager::post(INotificationPtr notification)
                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);
                }
 
@@ -888,7 +893,7 @@ void NotificationManager::update(INotificationPtr notification)
                        if ( notification->getUpdatedFlag())
                        {
 
-                               NotificationType type = notification->getNotiType();
+                               int type = (int)notification->getNotiType();
                                notification_ly_type_e noti_layout = NOTIFICATION_LY_NONE;
                                
                                switch (type)
@@ -1267,8 +1272,6 @@ std::vector<INotificationPtr> NotificationManager::getAll()
                ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Can't get noti list");
        }
 
-       INotificationPtr notification;
-
        while ( noti_list != NULL)
        {
                noti = notification_list_get_data(noti_list);
@@ -1277,7 +1280,6 @@ std::vector<INotificationPtr> NotificationManager::getAll()
                        int noti_priv = -1;
                        notification_get_id(noti, NULL, &noti_priv);
                        LogDebug(" notification id = " << noti_priv);
-
                        
                        INotificationPtr notification = 
                                        NotificationFactory::getInstance().getNotification(noti_priv); 
index 418b133..1203008 100755 (executable)
@@ -379,6 +379,10 @@ static bool service_extra_data_cb(service_h service, const char *key, void *user
                                data->setValue(keyValue);
                                (*appControl)->addAppControlData(data);
                        }
+                       
+                       if(value)
+                               free(value);
+                               
                }
        }
        return true;
@@ -1385,7 +1389,7 @@ void StatusNotification::setThumbnail( const std::string& thumb, int index)
                                type = NOTIFICATION_IMAGE_TYPE_NONE;
                }
 
-               if ( type != NOTIFICATION_TEXT_TYPE_NONE)
+               if ( type != NOTIFICATION_IMAGE_TYPE_NONE)
                {
                        
                        if (getThumbnail(index).compare(thumb))
@@ -1710,7 +1714,6 @@ DeviceAPI::Application::ApplicationControlPtr StatusNotification::getApplication
 {      
        service_h service = NULL;
        int retcode = 0;
-       int error = 0;
        char *tempStr = NULL;
        
        DeviceAPI::Application::ApplicationControlPtr appControl(new DeviceAPI::Application::ApplicationControl());
@@ -1960,7 +1963,7 @@ void StatusNotification::setApplicationControl(DeviceAPI::Application::Applicati
                }
                
                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());
 
@@ -2114,7 +2117,6 @@ void StatusNotification::setApplicationControl(DeviceAPI::Application::Applicati
 
 void StatusNotification::setApplicationId(const std::string& appId)
 {
-       int retcode = 0;
        LogDebug("m_service = " << m_service << " appId = " << appId);
        if (!m_service)
        {       
old mode 100644 (file)
new mode 100755 (executable)
index 07b1d66..079ee79
@@ -124,27 +124,39 @@ JSValueRef JSPackageManager::install(JSContextRef context,
                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);
@@ -181,26 +193,38 @@ JSValueRef JSPackageManager::uninstall(JSContextRef context,
                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 ) {
@@ -296,27 +320,43 @@ JSValueRef JSPackageManager::setPackageInfoEventListener(JSContextRef context,
 
        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);
 
old mode 100644 (file)
new mode 100755 (executable)
index 57b9774..6a660d6
@@ -115,15 +115,16 @@ CallbackUserData* PackageInfoEventCallback::getOnUninstalled()
 }
 
 
-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) {
@@ -143,6 +144,16 @@ CallbackUserData* PackageInstallEventCallback::getOnComplete()
        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;
@@ -404,14 +415,18 @@ static void package_event_cb(const char *type,    const char *package,
                        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: {
@@ -427,7 +442,9 @@ static void package_event_cb(const char *type,      const char *package,
                        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:
@@ -447,14 +464,16 @@ void install_request_cb(int id, const char *type, const char *package,
 {
        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());
@@ -468,7 +487,9 @@ void install_request_cb(int id, const char *type, const char *package,
                        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.
@@ -478,14 +499,18 @@ void install_request_cb(int id, const char *type, const char *package,
        }
        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());
@@ -502,22 +527,27 @@ void PackageManager::install(string pkgPath, PackageInstallEventCallback* callba
        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;
        }
 
@@ -525,9 +555,11 @@ void PackageManager::install(string pkgPath, PackageInstallEventCallback* callba
 
        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;
        }
 }
@@ -538,23 +570,28 @@ void PackageManager::uninstall(string pkgPath, PackageInstallEventCallback* call
        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;
        }
 
@@ -562,9 +599,11 @@ void PackageManager::uninstall(string pkgPath, PackageInstallEventCallback* call
 
        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;
        }
 }
old mode 100644 (file)
new mode 100755 (executable)
index 294b832..5d79112
@@ -72,17 +72,21 @@ private:
 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;
 };
 
 
index 3e7b77f..8c9e853 100755 (executable)
@@ -177,6 +177,8 @@ double PowerManager::getScreenBrightness(){
 
 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.");
index 8c2e024..8b3d521 100755 (executable)
@@ -17,6 +17,9 @@
 
 #include <memory>
 #include <dpl/log/log.h>
+#include <JSTizenExceptionFactory.h>
+#include <JSTizenException.h>
+#include <SecurityExceptions.h>
 #include "JSCellularNetworkInfo.h"
 #include "plugin_config.h"
 
@@ -24,6 +27,7 @@ namespace DeviceAPI {
 namespace Systeminfo {
 using namespace WrtDeviceApis::CommonsJavaScript;
 using namespace WrtDeviceApis::Commons;
+using namespace DeviceAPI::Common;
 
 namespace {
 const char* CELLULARNETWORK_STATUS_PROPERTY = "status";
@@ -150,12 +154,8 @@ JSValueRef JSCellularNetworkInfo::getProperty(JSContextRef context, JSObjectRef
             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)
index d7e9433..8ba4021 100755 (executable)
@@ -17,6 +17,9 @@
 
 #include <memory>
 #include <dpl/log/log.h>
+#include <JSTizenExceptionFactory.h>
+#include <JSTizenException.h>
+#include <SecurityExceptions.h>
 #include "JSDeviceCapabilitiesInfo.h"
 #include "plugin_config.h"
 
@@ -24,6 +27,7 @@ namespace DeviceAPI {
 namespace Systeminfo {
 using namespace WrtDeviceApis::CommonsJavaScript;
 using namespace WrtDeviceApis::Commons;
+using namespace DeviceAPI::Common;
 
 namespace {
 const char* DEVICE_CAPABILITIES_BLUETOOTH = "bluetooth";
@@ -196,30 +200,18 @@ JSValueRef JSDeviceCapabilitiesInfo::getProperty(JSContextRef context, JSObjectR
             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)) {
index 5efe9b9..89053ab 100755 (executable)
@@ -19,7 +19,6 @@
 #define WRTPLUGINS_TIZEN1_0_DEVICE_CAPABILITIES_INFO_H_
 
 #include <JavaScriptCore/JavaScript.h>
-#include <SecurityExceptions.h>
 #include "SysteminfoPropertyInfo.h"
 
 namespace DeviceAPI {
index 8a4d97a..df98b0f 100755 (executable)
@@ -17,6 +17,8 @@
 
 #include <memory>
 #include <dpl/log/log.h>
+#include <JSTizenExceptionFactory.h>
+#include <JSTizenException.h>
 #include <SecurityExceptions.h>
 #include "JSSIMInfo.h"
 #include "plugin_config.h"
@@ -25,6 +27,7 @@ namespace DeviceAPI {
 namespace Systeminfo {
 using namespace WrtDeviceApis::CommonsJavaScript;
 using namespace WrtDeviceApis::Commons;
+using namespace DeviceAPI::Common;
 
 namespace {
 const char* SIM_OPERATORNAME_PROPERTY = "operatorName";
@@ -117,10 +120,7 @@ JSValueRef JSSIMInfo::getProperty(JSContextRef context, JSObjectRef object, JSSt
     }
 
     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
     {
index 9c8930c..9447e0f 100755 (executable)
@@ -1398,7 +1398,7 @@ PROPERTY_GET_SYSTEMINFO_DEFINITION(WifiNetwork) {
     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) {
@@ -1416,9 +1416,9 @@ PROPERTY_GET_SYSTEMINFO_DEFINITION(WifiNetwork) {
         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) {