Update change log and spec for wrt-plugins-tizen_0.4.21
authorDongjin Choi <milkelf.choi@samsung.com>
Fri, 19 Apr 2013 12:02:33 +0000 (21:02 +0900)
committerDongjin Choi <milkelf.choi@samsung.com>
Fri, 19 Apr 2013 12:02:33 +0000 (21:02 +0900)
52 files changed:
CMakeLists.txt
packaging/wrt-plugins-tizen.spec
pkgconfigs/wrt-plugins-tizen-common.pc.in [changed mode: 0644->0755]
src/Alarm/JSAlarmAbsolute.cpp
src/Alarm/JSAlarmManager.cpp
src/Alarm/JSAlarmManager.h
src/Alarm/JSAlarmRelative.cpp
src/Application/AppManagerWrapper.cpp
src/Application/AppManagerWrapper.h
src/Application/ApplicationManager.cpp
src/Bluetooth/BluetoothAdapter.cpp
src/Bluetooth/BluetoothSocket.cpp
src/Bookmark/BookmarkManager.cpp
src/Bookmark/JSBookmarkFolder.cpp
src/Bookmark/JSBookmarkFolder.h
src/Bookmark/JSBookmarkItem.cpp
src/Bookmark/JSBookmarkItem.h
src/Calendar/CalendarConverter.cpp
src/Calendar/CalendarEvent.cpp
src/Calendar/CalendarEvent.h
src/Calendar/EventWrapper.cpp
src/Calendar/IEventWatchChanges.h
src/Common/ArgumentValidator.cpp [changed mode: 0644->0755]
src/Common/ArgumentValidator.h [changed mode: 0644->0755]
src/Common/StandaloneConsole/StandaloneConsole.cpp
src/Content/JSContentManager.cpp
src/Filesystem/Converter.cpp
src/Filesystem/Converter.h
src/Filesystem/INode.h
src/Filesystem/IStream.h
src/Filesystem/JSFilestream.cpp
src/Filesystem/Node.cpp
src/Filesystem/Node.h
src/Filesystem/NodeFilter.h
src/Filesystem/Stream.cpp
src/Filesystem/Stream.h
src/Messaging/ConverterMessage.cpp
src/NFC/NFCTag.cpp [changed mode: 0644->0755]
src/NFC/NFCTarget.cpp
src/NFC/NdefMessage.cpp
src/Notification/JSStatusNotification.cpp
src/Notification/StatusNotification.cpp
src/Notification/StatusNotification.h
src/Package/JSPackageManager.cpp
src/Package/PackageManager.cpp
src/Power/PowerManager.cpp
src/Power/PowerManager.h
src/TimeUtil/JSTZDate.cpp
src/TimeUtil/JSTZDate.h
src/TimeUtil/JSTimeDuration.cpp
src/TimeUtil/JSTimeDuration.h
src/TimeUtil/plugin_initializer.cpp

index a51c5e6..f1c0390 100755 (executable)
@@ -69,6 +69,7 @@ SET(CMAKE_CXX_FLAGS_RELEASE    "-O2 -std=c++0x -g")
 ADD_DEFINITIONS("-DCLIENT_IPC_THREAD")
 ADD_DEFINITIONS("-DEXPORT_API=")
 ADD_DEFINITIONS("-Wall")
+ADD_DEFINITIONS("-D_FILE_OFFSET_BITS=64")
 #ADD_DEFINITIONS("-Werror")
 #ADD_DEFINITIONS("-Wextra")
 ADD_DEFINITIONS("-DAPPLICATION_API_BACKWARD_COMPATIBILITY")
index 91241bb..fa98f9e 100755 (executable)
@@ -1,6 +1,6 @@
 Name:       wrt-plugins-tizen
 Summary:    JavaScript plugins for WebRuntime
-Version:    0.4.20
+Version:    0.4.21
 Release:    0
 Group:      Development/Libraries
 License:    Apache License, Version 2.0
old mode 100644 (file)
new mode 100755 (executable)
index aafd529..7880649
@@ -9,5 +9,5 @@ Name: wrt-plugins-tizen-${module_name}
 Description: wrt-plugins-tizen-${module_name}
 Version: @CMAKE_PROJECT_VERSION@
 Requires:
-Libs: -L${libdir} -lwrt-plugins-tizen-tizen
+Libs: -L${libdir} -lwrt-plugins-tizen-${module_name}
 Cflags: -I${includedir}/${module_name}
\ No newline at end of file
index 4664038..c3a9755 100755 (executable)
@@ -34,6 +34,7 @@
 #include "AlarmConverter.h"
 #include <app.h>
 #include <time.h>
+#include <JSUtil.h>
 
 #include "plugin_config.h"
 #include "JSAlarmAbsolute.h"
@@ -144,7 +145,11 @@ JSObjectRef JSAlarmAbsolute::constructor(JSContextRef ctx, JSObjectRef construct
                     priv->setByDayRecurrence(daysOfTheWeek);    
                 }
                        } else {
-                               unsigned long long interval = validator.toULongLong(1);
+                               long interval = validator.toLong(1);
+                               if (interval < 0) {
+                                       throw InvalidValuesException("period can not be negative value");
+                               }
+
                                if (!JSValueIsNull(ctx, arguments[1])) {
                                        priv->setInterval(interval);
                                } else {
@@ -320,12 +325,11 @@ JSValueRef JSAlarmAbsolute::getInterval(JSContextRef ctx,
         AbsoluteRecurrence::Type alarmType = privateData->getRecurrenceType();
        
         if(alarmType == AbsoluteRecurrence::Interval) {
-                   Converter converter(ctx);
-            int interval = privateData->getInterval();
+            long interval = privateData->getInterval();
                        if (interval == -1 ) {
                                return JSValueMakeNull(ctx);
                        } else {
-                   return converter.toJSValueRef(interval);
+                   return DeviceAPI::Common::JSUtil::toJSValueRef(ctx, interval);
                        }
         } else {
             return JSValueMakeNull(ctx);    
@@ -358,7 +362,7 @@ JSValueRef JSAlarmAbsolute::getDaysOfTheWeek(JSContextRef ctx,
         std::vector<std::string> daysOfTheWeek = privateData->getByDayRecurrence();
 
         if(daysOfTheWeek.size() > 0) {
-            for(unsigned int i=0; i<daysOfTheWeek.size(); i++) {
+            for(size_t i = 0; i<daysOfTheWeek.size(); i++) {
                 JSValueRef val = converter.toJSValueRef(daysOfTheWeek.at(i));
                 if(!JSSetArrayElement(ctx, jsResult, i, val)) {
                                        throw UnknownException("Could not insert value into js array");
index ddf1899..eef8a6a 100755 (executable)
@@ -222,7 +222,7 @@ JSValueRef JSAlarmManager::add(JSContextRef ctx, JSObjectRef object, JSObjectRef
                        }
 
                        delay = alarmPtr->getDelay();
-                       int interval = alarmPtr->getPeriod();
+                       long interval = alarmPtr->getPeriod();
                        service = alarmPtr->getService();
                        service_set_app_id(service, appId.c_str());
 
@@ -423,13 +423,10 @@ JSValueRef JSAlarmManager::remove(JSContextRef ctx, JSObjectRef object, JSObject
                int ret = alarm_cancel(alarmId);
                TIME_TRACER_ITEM_END("(remove)alarm_cancel", 0);
 
-               if (ret == ALARM_ERROR_NONE) {
-                       // no error;
-               } else if (ret == ALARM_ERROR_INVALID_PARAMETER) {
+               if (ret != ALARM_ERROR_NONE) {
                        throw NotFoundException("Alarm not found");
-               } else {
-                       throw UnknownException("Platform thrown unknown error");
                }
+               
                TIME_TRACER_ITEM_END(__FUNCTION__, 0);
                return JSValueMakeUndefined(ctx);
        } catch (const BasePlatformException &err) {
@@ -474,6 +471,11 @@ JSValueRef JSAlarmManager::get(JSContextRef ctx, JSObjectRef object, JSObjectRef
                int alarmId = 0;
                std::stringstream(id) >> alarmId;       
 
+               if (alarmId <= 0) {
+                       LogError("id is wrong : " << alarmId);
+                       throw InvalidValuesException("Invalid ID");
+               }
+
                TIME_TRACER_ITEM_BEGIN("(get)alarm_get_service", 0);
                int ret = alarm_get_service(alarmId, &service);
                TIME_TRACER_ITEM_END("(get)alarm_get_service", 0);
@@ -522,63 +524,6 @@ JSValueRef JSAlarmManager::get(JSContextRef ctx, JSObjectRef object, JSObjectRef
         DeviceAPI::Common::UnknownException err("Unknown Error in ApplicationManager.getAppSharedURI().");
         return JSWebAPIException::throwException(ctx, exception, err);
     }
-
-#if 0          
-        if(argumentCount <1) {
-            ThrowMsg(ConversionException, "Wrong parameter type.");
-        } else {
-            alarmId = converter.toInt(arguments[0]);
-        }
-
-        service_h handle = NULL;
-        char* alarmType = NULL;
-        int error = alarm_get_service(alarmId, &handle);
-        if(error != ALARM_ERROR_NONE) {
-            ThrowMsg(NotFoundException, "Alarm not found");
-        }
-
-               error =service_get_extra_data(handle, ALARM_TYPE_KEY, &alarmType);
-               if(SERVICE_ERROR_NONE!=error) {
-                       LogInfo("Getting data failed: "<<error);
-                       service_destroy(handle);
-            ThrowMsg(PlatformException, "Unknown error occurred.");
-               }
-
-        if(!strcmp(alarmType, ALARM_TYPE_ABSOLUTE_VALUE)) 
-        {
-            AlarmAbsolutePtr privateData = AlarmAbsolutePtr(new AlarmAbsolute(handle));
-            if(converter.toAlarmAbsolutePtr(alarmId, handle, privateData) == false) {
-                ThrowMsg(ConversionException, "Absolute alarm conversion failed.");
-            }
-            
-            return JSAlarmAbsolute::createJSObject(ctx, privateData);
-
-        } else if( !strcmp(alarmType, ALARM_TYPE_RELATIVE_VALUE)) {
-            AlarmRelativePtr privateData = AlarmRelativePtr(new AlarmRelative(handle));
-            if(converter.toAlarmRelativePtr(alarmId, handle, privateData) == false) {
-                ThrowMsg(ConversionException, "Relative alarm conversion failed.");
-            }
-            return JSAlarmRelative::createJSObject(ctx, privateData);    
-        }
-       } Catch(ConversionException) {
-               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(ctx, exception, JSTizenException::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage());
-       } Catch(UnsupportedException) {
-               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(ctx, exception, JSTizenException::NOT_SUPPORTED_ERROR, _rethrown_exception.GetMessage());
-       } Catch(InvalidArgumentException) {
-               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(ctx, exception, JSTizenException::INVALID_VALUES_ERROR, _rethrown_exception.GetMessage());
-       } Catch (NotFoundException) {
-               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(ctx, exception, JSTizenException::NOT_FOUND_ERROR, _rethrown_exception.GetMessage());
-       } Catch(Exception) {
-               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(ctx, exception, JSTizenException::UNKNOWN_ERROR, _rethrown_exception.GetMessage());
-       }
-
-    return JSValueMakeUndefined(ctx);
-#endif
 }
 
 
@@ -666,77 +611,6 @@ JSValueRef JSAlarmManager::getAll(JSContextRef ctx, JSObjectRef object, JSObject
         DeviceAPI::Common::UnknownException err("Unknown Error in ApplicationManager.getAppSharedURI().");
         return JSWebAPIException::throwException(ctx, exception, err);
     }
-#if 0          
-        int elementIndex = 0;
-
-        LogInfo("Alarms id size: " << alarmIds.size());
-        for(unsigned int i = 0; i < alarmIds.size(); i++)
-        {
-            service_h handle = NULL;
-            char* alarmType = NULL;
-            error = alarm_get_service(alarmIds.at(i), &handle);
-            if(ALARM_ERROR_NONE!=error) {
-                LogInfo("Getting service failed: "<<error);
-                continue;
-            }
-
-            error =service_get_extra_data(handle, ALARM_TYPE_KEY, &alarmType);
-            if(SERVICE_ERROR_NONE!=error) {
-                LogInfo("Getting data failed: "<<error);
-                service_destroy(handle);
-                continue;
-            }
-
-            LogInfo("Alarm id: " << alarmIds.at(i));
-            LogInfo("Alarm Type: " << alarmType);
-
-            if(!strcmp(alarmType, ALARM_TYPE_ABSOLUTE_VALUE)) {
-                LogInfo("Enter getAll Natvie alarm id = " << alarmIds.at(i));
-                AlarmAbsolutePtr privateData = AlarmAbsolutePtr(new AlarmAbsolute(handle));
-                LogInfo("Success to make Native alarmPtr");
-
-                if(converter.toAlarmAbsolutePtr(alarmIds.at(i), handle, privateData) == false) {
-                    ThrowMsg(ConversionException, "Absolute alarm conversion failed.");
-                }
-
-                JSValueRef obj = JSAlarmAbsolute::createJSObject(ctx, privateData);
-                if(!JSSetArrayElement(ctx, jsResult, elementIndex, obj))
-                {
-                   ThrowMsg(UnknownException, "JS array creation failed.");
-                }
-            } else if( !strcmp(alarmType, ALARM_TYPE_RELATIVE_VALUE)) {
-                AlarmRelativePtr privateData = AlarmRelativePtr(new AlarmRelative(handle));
-                if(converter.toAlarmRelativePtr(alarmIds.at(i), handle, privateData) == false) {
-                    ThrowMsg(ConversionException, "Relative alarm conversion failed.");
-                }
-                JSValueRef obj = JSAlarmRelative::createJSObject(ctx, privateData);
-                if(!JSSetArrayElement(ctx, jsResult, elementIndex, obj))
-                {
-                    ThrowMsg(UnknownException, "JS array creation failed.");
-                }
-            }
-            service_destroy(handle);
-            elementIndex++;
-        }
-        return jsResult;
-
-    } Catch(ConversionException) {
-        LogWarning("Exception: "<<_rethrown_exception.GetMessage());
-        return JSTizenExceptionFactory::postException(ctx, exception, JSTizenException::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage());
-    } Catch(UnsupportedException) {
-        LogWarning("Exception: "<<_rethrown_exception.GetMessage());
-        return JSTizenExceptionFactory::postException(ctx, exception, JSTizenException::NOT_SUPPORTED_ERROR, _rethrown_exception.GetMessage());
-    } Catch(InvalidArgumentException) {
-        LogWarning("Exception: "<<_rethrown_exception.GetMessage());
-        return JSTizenExceptionFactory::postException(ctx, exception, JSTizenException::INVALID_VALUES_ERROR, _rethrown_exception.GetMessage());
-    } Catch (NotFoundException) {
-        LogWarning("Exception: "<<_rethrown_exception.GetMessage());
-        return JSTizenExceptionFactory::postException(ctx, exception, JSTizenException::NOT_FOUND_ERROR, _rethrown_exception.GetMessage());
-    } Catch(Exception) {
-        LogWarning("Exception: "<<_rethrown_exception.GetMessage());
-        return JSTizenExceptionFactory::postException(ctx, exception, JSTizenException::UNKNOWN_ERROR, _rethrown_exception.GetMessage());
-    }
-#endif
 }
 
 JSValueRef JSAlarmManager::getProperty(JSContextRef context,
@@ -746,13 +620,13 @@ JSValueRef JSAlarmManager::getProperty(JSContextRef context,
 {
     try {
         if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_ALARM_CONSTANT_PERIOD_MINUTE)) {
-                       return JSUtil::toJSValueRef(context, (unsigned long long)60);
+            return JSUtil::toJSValueRef(context, (long)60);
         } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_ALARM_CONSTANT_PERIOD_HOUR)) {
-            return JSUtil::toJSValueRef(context, (unsigned long long)3600);
+            return JSUtil::toJSValueRef(context, (long)3600);
         } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_ALARM_CONSTANT_PERIOD_DAY)) {
-            return JSUtil::toJSValueRef(context, (unsigned long long)86400);
+            return JSUtil::toJSValueRef(context, (long)86400);
         } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_ALARM_CONSTANT_PERIOD_WEEK)) {
-            return JSUtil::toJSValueRef(context, (unsigned long long)604800);
+            return JSUtil::toJSValueRef(context, (long)604800);
         }
     } catch (const BasePlatformException &err) {
         LogWarning("Getting property is failed. %s", err.getMessage().c_str());
@@ -761,98 +635,6 @@ JSValueRef JSAlarmManager::getProperty(JSContextRef context,
     return NULL;
 }
 
-#if 0
-JSValueRef JSAlarmManager::getMin(JSContextRef ctx,
-               JSObjectRef object,
-               JSStringRef propertyName,
-               JSValueRef* exception)
-{
-    Converter converter(ctx);
-    return converter.toJSValueRef(60);
-}
-
-
-JSValueRef JSAlarmManager::getHour(JSContextRef ctx,
-               JSObjectRef object,
-               JSStringRef propertyName,
-               JSValueRef* exception)
-{
-    Converter converter(ctx);
-    return converter.toJSValueRef(3600);
-}
-
-JSValueRef JSAlarmManager::getDay(JSContextRef ctx,
-               JSObjectRef object,
-               JSStringRef propertyName,
-               JSValueRef* exception)
-{
-    Converter converter(ctx);
-    return converter.toJSValueRef(86400);
-}
-
-JSValueRef JSAlarmManager::getWeek(JSContextRef ctx,
-               JSObjectRef object,
-               JSStringRef propertyName,
-               JSValueRef* exception)
-{
-    Converter converter(ctx);
-    return converter.toJSValueRef(604800);
-}
-
-static ail_cb_ret_e appinfoCallback(const ail_appinfo_h appinfo, void *user_data)
-{
-       if (appinfo == NULL || user_data == NULL) {
-               return AIL_CB_RET_CANCEL;
-       }
-
-       char** pkgStrPtr = (char**)user_data;
-       char* tmpStr = NULL;
-       ail_error_e ret;
-
-       ret = ail_appinfo_get_str(appinfo, AIL_PROP_PACKAGE_STR, &tmpStr);
-       if (ret != AIL_ERROR_OK) {
-               return AIL_CB_RET_CONTINUE;
-       }
-
-       if (tmpStr != NULL) {
-               *pkgStrPtr = strdup(tmpStr);
-       }
-       return AIL_CB_RET_CANCEL;
-}
-
-// get package name by id
-char* JSAlarmManager::getPackageById(const char* appId)
-{
-       LogDebug("<<< appId:[" << appId << "]");
-
-       ail_filter_h filter;
-       ail_error_e ret;
-       char* pkg = NULL;
-
-       if (appId == NULL) {
-               return NULL;
-       }
-
-
-       ret = ail_filter_new(&filter);
-       if (ret != AIL_ERROR_OK) {
-               return NULL;
-       }
-
-       ret = ail_filter_add_str(filter, AIL_PROP_X_SLP_PACKAGEID_STR , appId);
-       if (ret != AIL_ERROR_OK) {
-               ail_filter_destroy(filter);
-               return NULL;
-       }
-
-       ail_filter_list_appinfo_foreach(filter, appinfoCallback, &pkg);
-       ail_filter_destroy(filter);
-
-       LogDebug(">>> pkg:[" << pkg << "]");
-       return pkg;
-}
-#endif
-
 } // Alarm
 } // TizenApis
 
index dc35175..a54768f 100755 (executable)
@@ -53,13 +53,6 @@ private:
             JSObjectRef object,
             JSStringRef propertyName,
             JSValueRef* exception);    
-#if 0  
-    static JSValueRef getMin(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception);
-    static JSValueRef getHour(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception);
-    static JSValueRef getDay(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception);
-    static JSValueRef getWeek(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception);
-    static char* getPackageById(const char* appId);
-#endif
 
     static JSClassDefinition m_jsClassInfo;
     static JSClassRef m_jsClassRef;
index c12ed5c..315a290 100755 (executable)
@@ -37,6 +37,8 @@
 #include "JSAlarmRelative.h"
 #include "JSAlarmManager.h"
 
+#include <JSUtil.h>
+
 #include <app.h>
 #include <time.h>
 
@@ -116,8 +118,14 @@ JSObjectRef JSAlarmRelative::constructor(JSContextRef ctx, JSObjectRef construct
        try {
            ArgumentValidator validator(ctx, argumentCount, arguments);
 
-               unsigned long long delay = validator.toULongLong(0);
-               unsigned long long period = validator.toULongLong(1, true, 0);
+               long delay = validator.toLong(0);
+               if (delay < 0) {
+                       throw InvalidValuesException("delay cannot be negative value");
+               }
+               long period = validator.toLong(1, true, 0);
+               if (period < 0) {
+                       throw InvalidValuesException("period cannot be negative value");
+               }
 
                if ((argumentCount > 1) && !JSValueIsNull(ctx, arguments[1])) {
                        return JSValueToObject(ctx, createJSObject(ctx, delay, period), exception);
@@ -154,6 +162,7 @@ JSValueRef JSAlarmRelative::createJSObject(JSContextRef context, AlarmRelativePt
     return JSObjectMake(context, getClassRef(), static_cast<void*>(priv));
 }
 
+
 JSValueRef JSAlarmRelative::createJSObject(JSContextRef context, int delay, int interval)
 {
     AlarmRelativePtr privateData = AlarmRelativePtr(new AlarmRelative());
@@ -173,7 +182,6 @@ JSValueRef JSAlarmRelative::getRemainingSeconds(JSContextRef ctx, JSObjectRef fu
     struct tm current;
     time_t currentTime;
     time_t nextTime;
-    Converter converter(ctx);
     int id;
 
     try {
@@ -195,7 +203,7 @@ JSValueRef JSAlarmRelative::getRemainingSeconds(JSContextRef ctx, JSObjectRef fu
         nextTime = mktime(&date);
         currentTime = mktime(&current);
 
-        int result = nextTime - currentTime;
+        long result = nextTime - currentTime;
 
         LogDebug("nextTime: "<<nextTime<<", currentTime: "<<currentTime<<", result: "<<result);
 
@@ -204,8 +212,7 @@ JSValueRef JSAlarmRelative::getRemainingSeconds(JSContextRef ctx, JSObjectRef fu
             throw UnknownException("Unknown exception occurred.");
         }
 
-        JSValueRef jsResult = converter.toJSValueRef(result);
-        return jsResult;       
+               return DeviceAPI::Common::JSUtil::toJSValueRef(ctx, result);
        } catch (const BasePlatformException &err) {
         return JSWebAPIException::throwException(ctx, exception, err);
     } catch (...) {
@@ -247,8 +254,7 @@ JSValueRef JSAlarmRelative::getDelay(JSContextRef ctx,
                JSStringRef propertyName,
                JSValueRef* exception)
 {
-    Converter converter(ctx);
-    int delay;
+    long delay;
 
        try {
         AlarmRelativePtr privateData = getPrivData(object);
@@ -258,12 +264,7 @@ JSValueRef JSAlarmRelative::getDelay(JSContextRef ctx,
                
         delay = privateData->getDelay();
         LogInfo("JSAlarmRelative delay = " << delay);
-        if(delay >= 0) {
-            return converter.toJSValueRef(delay);
-        } else {
-            // Impossible
-            throw UnknownException("Invalid delay value.");
-        }
+        return DeviceAPI::Common::JSUtil::toJSValueRef(ctx, delay);
     } catch (const BasePlatformException &err) {
         return JSWebAPIException::throwException(ctx, exception, err);
     } catch (...) {
@@ -277,9 +278,7 @@ JSValueRef JSAlarmRelative::getPeriod(JSContextRef ctx,
                JSStringRef propertyName,
                JSValueRef* exception)
 {
-
-    Converter converter(ctx);
-    int period =0;
+    long period =0;
 
        try {
         AlarmRelativePtr privateData = getPrivData(object);
@@ -289,10 +288,10 @@ JSValueRef JSAlarmRelative::getPeriod(JSContextRef ctx,
                
         period = privateData->getPeriod();
         LogInfo("JSAlarmRelative interval = " << period);
-         if(period < 0) {
+         if(period == -1) {
             return JSValueMakeNull(ctx);
         } else {
-            return converter.toJSValueRef(period);
+               return DeviceAPI::Common::JSUtil::toJSValueRef(ctx, period);
         }
        } catch (const BasePlatformException &err) {
                return JSWebAPIException::throwException(ctx, exception, err);
index 2a139ab..4b1c005 100644 (file)
@@ -35,14 +35,14 @@ using namespace WrtDeviceApis::Commons;
 
 
 AppManagerWrapper::AppManagerWrapper() :
-               m_registeredCallback(false),
+               m_manager_handle(NULL),
                m_watchIdAcc(0)
 {
 }
 
 AppManagerWrapper::~AppManagerWrapper()
 {
-       if(m_registeredCallback)
+       if(m_manager_handle != NULL)
        {
                unregisterAppListChangedCallbacks();
        }
@@ -56,7 +56,7 @@ void AppManagerWrapper::registerAppListChangedCallbacks(IAppManagerAppListChange
                return;
        }
 
-       if(!m_registeredCallback)
+       if(!m_manager_handle)
        {
                registerAppListChangedCallbacks();
        }
@@ -107,44 +107,40 @@ bool AppManagerWrapper::app_callback(package_info_app_component_type_e comp_type
                return true;
        }
 
-       std::vector<std::string> *applist = (std::vector<std::string> *)user_data;
-       applist->push_back(app_id);
+       if(user_data == NULL) {
+               LogWarning("No user data to store appId");
+               return true;
+       }
+       
+       AppManagerWrapper *appManager = (AppManagerWrapper *)user_data;
+       appManager->applist.push_back(app_id);
 
        return true;
 }
 
-
-void AppManagerWrapper::appListChangedCallback(app_manger_event_type_e event_type,
-                                               const char *appId,
-                                               void *user_data)
+void AppManagerWrapper::appListChangedCallback(app_manger_event_type_e event_type, const char *pkgId, void *user_data)
 {
-       if(user_data == NULL)
-       {
-               LogWarning("app_manager listener passed NULL user_data");
+       if(user_data == NULL) {
+               LogWarning("No user data to store appId");
                return;
        }
 
        AppManagerWrapper *appManager = (AppManagerWrapper *)user_data;
 
-       appManager->appListChangedCallback(event_type, appId);
-}
-
-void AppManagerWrapper::appListChangedCallback(app_manger_event_type_e event_type,
-                                               const char *appId)
-{
-       package_info_h package_info;
-       std::vector<std::string> applist;
-
        if (event_type == APP_MANAGER_EVENT_UNINSTALLED) {
-               appListAppUninstalled(appId);
+               for (size_t i = 0; i < appManager->applist.size(); i++) {
+                       appListAppUninstalled(appManager->applist.at(i).c_str());
+               }
        } else {
-               int ret = package_manager_get_package_info(appId, &package_info);
+               package_info_h package_info;
+       
+               int ret = package_manager_get_package_info(pkgId, &package_info);
                if (ret != PACKAGE_MANAGER_ERROR_NONE) {
-                       LogDebug("Cannot create package info by : " << appId);
+                       LogDebug("Cannot create package info by : " << pkgId);
                        return;
                }
 
-               ret = package_info_foreach_app_from_package(package_info, PACKAGE_INFO_ALLAPP, app_callback, (void *)&applist);
+               ret = package_info_foreach_app_from_package(package_info, PACKAGE_INFO_ALLAPP, app_callback, user_data);
                if (ret != PACKAGE_MANAGER_ERROR_NONE) {
                        LogDebug("failed while getting appids");
                        return;
@@ -155,14 +151,14 @@ void AppManagerWrapper::appListChangedCallback(app_manger_event_type_e event_typ
                        LogDebug("Cannot destroy package info");
                }
 
-               for (size_t i = 0; i < applist.size(); i++) {
+               for (size_t i = 0; i < appManager->applist.size(); i++) {
                        switch(event_type)
                        {
                        case APP_MANAGER_EVENT_INSTALLED:
-                               appListAppInstalled(applist.at(i).c_str());
+                               appListAppInstalled(appManager->applist.at(i).c_str());
                                break;
                        case APP_MANAGER_EVENT_UPDATED:
-                               appListAppUpdated(applist.at(i).c_str());
+                               appListAppUpdated(appManager->applist.at(i).c_str());
                                break;
                        default:
                                LogWarning("app_manager listener gave wrong event_type : " << event_type);
@@ -170,6 +166,9 @@ void AppManagerWrapper::appListChangedCallback(app_manger_event_type_e event_typ
                        }
                }
        }
+
+       // clean-up applist
+       appManager->applist.clear();
 }
 
 
@@ -206,38 +205,75 @@ void AppManagerWrapper::appListAppUpdated(const char *appId)
        }
 }
 
+
+
+int AppManagerWrapper::app_list_changed_cb_broker(int id, const char *type, const char *package, const char *key, const char *val, const void *msg, void *data)
+{
+       static app_manger_event_type_e event_type;
+
+       if (!strcasecmp(key, "start")) {
+               if (!strcasecmp(val, "install")) {
+                       event_type = APP_MANAGER_EVENT_INSTALLED;
+               } else if (!strcasecmp(val, "uninstall"))       {
+                       // After uninstallation, we cannot get app ids from package name.
+                       // So, we have to store app ids which is included to target package.
+                       package_info_h package_info;
+
+                       int ret = package_manager_get_package_info(package, &package_info);
+                       if (ret != PACKAGE_MANAGER_ERROR_NONE) {
+                               LogDebug("Cannot create package info by : " << package);
+                       }
+
+                       ret = package_info_foreach_app_from_package(package_info, PACKAGE_INFO_ALLAPP, app_callback, data);
+                       if (ret != PACKAGE_MANAGER_ERROR_NONE) {
+                               LogDebug("failed while getting appids");
+                       }
+
+                       ret = package_info_destroy(package_info);
+                       if (ret != PACKAGE_MANAGER_ERROR_NONE) {
+                               LogDebug("Cannot destroy package info");
+                       }
+                       event_type = APP_MANAGER_EVENT_UNINSTALLED;
+               } else if (!strcasecmp(val, "update")) {
+                       event_type = APP_MANAGER_EVENT_UPDATED;
+               }
+       } else if (!strcasecmp(key, "end") && !strcasecmp(val, "ok"))   {
+               if (event_type >= 0) {
+                       if (data != NULL) {
+                               AppManagerWrapper *appManager = (AppManagerWrapper *)data;
+                               appManager->appListChangedCallback(event_type, package, data);
+                       }
+               }
+       }
+
+       return APP_MANAGER_ERROR_NONE;
+}
+
+
 void AppManagerWrapper::registerAppListChangedCallbacks()
 {
-       if(m_registeredCallback)
-       {
+       if (m_manager_handle != NULL) {
                LogWarning("Callback already registered.");
                return;
        }
 
-       // AppManagerWrapper will be used as a singleton object,
-       // so this pointer of it can be passed as a parameter of a async function.
-       int result = app_manager_set_app_list_changed_cb(appListChangedCallback, this);
-       if (result != APP_MANAGER_ERROR_NONE)
-       {
-               LogWarning("app_manager_set_app_list_changed_cb() returns APP_MANAGER_ERROR_INVALID_PARAMETER");
-
+       m_manager_handle = pkgmgr_client_new(PC_LISTENING);
+       if (m_manager_handle == NULL) {
                ThrowMsg(InvalidArgumentException, "Error while registering listener to app_manager");
        }
 
-       m_registeredCallback = true;
+       pkgmgr_client_listen_status(m_manager_handle, app_list_changed_cb_broker, this);
 }
 
 void AppManagerWrapper::unregisterAppListChangedCallbacks()
 {
-       if(!m_registeredCallback)
-       {
-               LogWarning("Callback already unregistered.");
+       if (m_manager_handle == NULL) {
+               LogWarning("No callback registered");
                return;
        }
 
-       app_manager_unset_app_list_changed_cb();
-
-       m_registeredCallback = false;
+       pkgmgr_client_free(m_manager_handle);
+       m_manager_handle = NULL;
 }
 
 // @20130125-wscho: current pkgmanager has a problem while db operation.
index 03f5359..d5644eb 100644 (file)
@@ -71,14 +71,8 @@ public:
 private:
 
        static bool app_callback(package_info_app_component_type_e comp_type, const char *app_id, void *user_data);
-
-       // callback for app_manager_set_app_list_changed_cb
-       static void appListChangedCallback(app_manger_event_type_e event_type,
-                                          const char *package,
-                                          void *user_data);
-
-       void appListChangedCallback(app_manger_event_type_e event_type,
-                                   const char *package);
+       void appListChangedCallback(app_manger_event_type_e event_type, const char *pkgId, void *user_data);
+       static int app_list_changed_cb_broker(int id, const char *type, const char *package, const char *key, const char *val, const void *msg, void *data);
 
        void appListAppInstalled(const char *appId);
        void appListAppUninstalled(const char *appId);
@@ -89,11 +83,13 @@ private:
 
        typedef std::set<IAppManagerAppListChangedCallbacks *> AppListChangedCallbacksSet;
        AppListChangedCallbacksSet m_callbacks;
-       bool m_registeredCallback;
-
+       pkgmgr_client *m_manager_handle;
        long m_watchIdAcc;
 
 public:
+       std::vector<std::string> applist;
+
+public:
        friend class DPL::Singleton<AppManagerWrapper>;
 };
 
index d9b92e0..091297b 100644 (file)
@@ -961,6 +961,13 @@ void ApplicationManager::OnRequestReceived(const EventApplicationKillPtr& event)
                        return;
                }
 
+               // if kill request is come for current context, throw InvalidValueException by spec
+               if (pid == getppid())
+               {
+                       event->setExceptionCode(Commons::ExceptionCodes::InvalidArgumentException);
+                       return;
+               }
+
                char *appIdCStr = NULL;
                ret = app_manager_get_app_id(pid, &appIdCStr);
                if (ret != APP_MANAGER_ERROR_NONE)
index 5a97e77..87bc205 100644 (file)
@@ -53,6 +53,7 @@ void BluetoothAdapter::onStateChangedCB(int result, bt_adapter_state_e adapterSt
         }
         
         MultiCallbackUserDataPtr callback = static_cast<MultiCallbackUserDataPtr>(object->mUserDataList[SET_POWERED]);
+        object->mUserDataList[SET_POWERED].reset();
         
         if(result == BT_ERROR_NONE) {
             if(callback)
@@ -72,8 +73,6 @@ void BluetoothAdapter::onStateChangedCB(int result, bt_adapter_state_e adapterSt
                 callback->invokeCallback("error", JSWebAPIError::makeJSWebAPIError(context, error));        
             }
         }
-        
-        object->mUserDataList[SET_POWERED].reset();
     }
     else {  // unexpected event
         LogWarning("Bluetooth state is changed unexpectedly");
@@ -92,10 +91,10 @@ void BluetoothAdapter::onNameChangedCB(char *name, void *userData)
 
     if(object->mUserDataList[SET_NAME] != NULL && !strcmp(object->mRequestedName.c_str(), name)) {  // requested event      
         MultiCallbackUserDataPtr callback = static_cast<MultiCallbackUserDataPtr>(object->mUserDataList[SET_NAME]);
+        object->mUserDataList[SET_NAME].reset();
         if(callback)
-            callback->invokeCallback("success");
+            callback->invokeCallback("success");        
         
-        object->mUserDataList[SET_NAME].reset();
         bt_adapter_unset_name_changed_cb();
     }
     else {  // unexpected event
@@ -121,6 +120,7 @@ void BluetoothAdapter::onVisibilityChangedCB(int result, bt_adapter_visibility_m
         }    
     
         MultiCallbackUserDataPtr callback = static_cast<MultiCallbackUserDataPtr>(object->mUserDataList[SET_VISIBLE]);
+        object->mUserDataList[SET_VISIBLE].reset();
         
         if(result == BT_ERROR_NONE) {
             if(callback)
@@ -132,9 +132,8 @@ void BluetoothAdapter::onVisibilityChangedCB(int result, bt_adapter_visibility_m
                 UnknownException error("Unknown error");
                 callback->invokeCallback("error", JSWebAPIError::makeJSWebAPIError(context, error));        
             }
-        }
+        }        
         
-        object->mUserDataList[SET_VISIBLE].reset();
         bt_adapter_unset_visibility_mode_changed_cb();
     }
     else {  // unexpected event
@@ -177,15 +176,18 @@ void BluetoothAdapter::onDiscoveryStateChangedCB(int result, bt_adapter_device_d
                 }
                 else {
                     if(callback) {
-                        JSContextRef context = callback->getContext();
-                        UnknownException error("Unknown error");
-                        callback->invokeCallback("error", JSWebAPIError::makeJSWebAPIError(context, error));
                         LogDebug("Reset DISCOVER_DEVICES");
                         object->mUserDataList[DISCOVER_DEVICES].reset();
-                    }
                     
+                        JSContextRef context = callback->getContext();
+                        UnknownException error("Unknown error");                        
+                        callback->invokeCallback("error", JSWebAPIError::makeJSWebAPIError(context, error));                   
+                    }
+
+                    /*
                     if(object->mUserDataList[STOP_DISCOVERY] == NULL)    // because same core API callback is used 
                         bt_adapter_unset_device_discovery_state_changed_cb();
+                    */    
                 }            
             }
             else {  // unexpected event
@@ -222,6 +224,9 @@ void BluetoothAdapter::onDiscoveryStateChangedCB(int result, bt_adapter_device_d
                                 JSObjectRef deviceObj = JSBluetoothDevice::createJSObject(callback->getContext(), object->mFoundDevices[i]);                        
                                 devices[i] = deviceObj;
                             }
+                            
+                            LogDebug("Reset DISCOVER_DEVICES");
+                            object->mUserDataList[DISCOVER_DEVICES].reset();
                         
                             callback->invokeCallback(
                                     "onfinished",
@@ -229,13 +234,14 @@ void BluetoothAdapter::onDiscoveryStateChangedCB(int result, bt_adapter_device_d
                         }
                         else {  // There is no found device
                             LogDebug("There is no found device");
+
+                            LogDebug("Reset DISCOVER_DEVICES");
+                            object->mUserDataList[DISCOVER_DEVICES].reset();                
+                            
                             callback->invokeCallback(
                                     "onfinished",
                                     JSObjectMakeArray(callback->getContext(), 0, NULL, NULL) );
                         }
-
-                        LogDebug("Reset DISCOVER_DEVICES");
-                        object->mUserDataList[DISCOVER_DEVICES].reset();                
                     }
                 }
 
@@ -246,12 +252,12 @@ void BluetoothAdapter::onDiscoveryStateChangedCB(int result, bt_adapter_device_d
 
                     if(callback) {
                         LogDebug("Call successCallback of stopDiscovery()");
-                        callback->invokeCallback("success");
                         object->mUserDataList[STOP_DISCOVERY].reset();
+                        callback->invokeCallback("success");                        
                     }
                 }
 
-                bt_adapter_unset_device_discovery_state_changed_cb();
+                //bt_adapter_unset_device_discovery_state_changed_cb();
             }
             else {
                 LogWarning("result MUST be BT_ERROR_NONE or BT_ERROR_CANCELLED when BT_ADAPTER_DEVICE_DISCOVERY_FINISHED");
@@ -360,6 +366,7 @@ void BluetoothAdapter::onBondCreatedCB(int result, bt_device_info_s *deviceInfo,
             !strcmp(object->mCreateBondingAddress.c_str(), deviceInfo->remote_address)) {  // requested event
     
         MultiCallbackUserDataPtr callback = static_cast<MultiCallbackUserDataPtr>(object->mUserDataList[CREATE_BONDING]);
+        object->mUserDataList[CREATE_BONDING].reset();
         
         if(result == BT_ERROR_NONE && deviceInfo != NULL) {
             if(callback) {
@@ -375,9 +382,8 @@ void BluetoothAdapter::onBondCreatedCB(int result, bt_device_info_s *deviceInfo,
                 UnknownException error("Unknown error");
                 callback->invokeCallback("error", JSWebAPIError::makeJSWebAPIError(context, error));        
             }
-        }
+        }        
         
-        object->mUserDataList[CREATE_BONDING].reset();
         bt_device_unset_bond_created_cb();
         object->mCreateBondingAddress.clear();
     }
@@ -400,6 +406,7 @@ void BluetoothAdapter::onBondDestroyedCB(int result, char *remoteAddress, void *
             !strcmp(object->mDestroyBondingAddress.c_str(), remoteAddress)) {  // requested event
     
         MultiCallbackUserDataPtr callback = static_cast<MultiCallbackUserDataPtr>(object->mUserDataList[DESTROY_BONDING]);
+        object->mUserDataList[DESTROY_BONDING].reset();
         
         if(result == BT_ERROR_NONE) {
             if(callback)
@@ -411,9 +418,8 @@ void BluetoothAdapter::onBondDestroyedCB(int result, char *remoteAddress, void *
                 UnknownException error("Unknown error");
                 callback->invokeCallback("error", JSWebAPIError::makeJSWebAPIError(context, error));        
             }
-        }
+        }        
         
-        object->mUserDataList[DESTROY_BONDING].reset();
         bt_device_unset_bond_destroyed_cb();
         object->mDestroyBondingAddress.clear();
     }
@@ -495,30 +501,31 @@ void BluetoothAdapter::onSocketConnected(int result, bt_socket_connection_state_
         }        
     }
     else if(connection->local_role == BT_SOCKET_CLIENT) {
-        std::string remoteAddress(connection->remote_address);
-        ConnReqMultiMapT::iterator iter;
-        do {
-            iter = object->mConnReqMap.find(remoteAddress);
-            if(iter != object->mConnReqMap.end() && !strcmp(iter->second->mUUID.c_str(), connection->service_uuid)) {
-                LogDebug("Find");
-                break;
+
+        if(state == BT_SOCKET_CONNECTED) {  // connected when Client
+            std::string remoteAddress(connection->remote_address);
+            ConnReqMultiMapT::iterator iter;
+            do {
+                iter = object->mConnReqMap.find(remoteAddress);
+                if(iter != object->mConnReqMap.end() && !strcmp(iter->second->mUUID.c_str(), connection->service_uuid)) {
+                    LogDebug("Find");
+                    break;
+                }
+            } while(iter != object->mConnReqMap.end());
+
+            if(iter == object->mConnReqMap.end()) {
+                LogWarning("Connection state is changed unexpectedly");
+                return;
             }
-        } while(iter != object->mConnReqMap.end());
-        
-        if(iter == object->mConnReqMap.end()) {
-            LogWarning("Connection state is changed unexpectedly");
-            return;    
-        }
 
-        MultiCallbackUserDataPtr callback = static_cast<MultiCallbackUserDataPtr>(iter->second->mUserData);
+            MultiCallbackUserDataPtr callback = static_cast<MultiCallbackUserDataPtr>(iter->second->mUserData);
 
-        if(state == BT_SOCKET_CONNECTED) {  // connected when Client
             if(result == BT_ERROR_NONE) {
                 // Update mConnectedSocket
                 BluetoothSocketPtr socket = new BluetoothSocket(connection);
                 object->mConnectedSocket.insert(std::pair<int, BluetoothSocketPtr>(connection->socket_fd, socket));
                 bt_socket_set_data_received_cb(onSocketReceivedCB, userData);
-                
+
                 // Call successcallback of connectToServiceByUUID 
                 JSContextRef context = callback->getContext();
                 JSObjectRef socketObj = JSBluetoothSocket::createJSObject(context, socket);
@@ -526,17 +533,17 @@ void BluetoothAdapter::onSocketConnected(int result, bt_socket_connection_state_
                     callback->invokeCallback("success", socketObj);
 
                 // Update mConnReqMap
-                object->mConnReqMap.erase(iter);         
+                object->mConnReqMap.erase(iter);
             }
             else {
-                // Call errorcallback of connectToServiceByUUID 
-                JSContextRef context = callback->getContext();                
-                InvalidValuesException error("Invalid value");
+                // Call errorcallback of connectToServiceByUUID
+                JSContextRef context = callback->getContext();
+                NotFoundException error("Not found");
                 if(callback)
                     callback->invokeCallback("error", JSWebAPIError::makeJSWebAPIError(context, error));
 
                 // Update mConnReqMap
-                object->mConnReqMap.erase(iter);                
+                object->mConnReqMap.erase(iter);
             }
             return;
         }
@@ -629,6 +636,10 @@ BluetoothAdapter::BluetoothAdapter():
     if(bt_adapter_set_state_changed_cb(onStateChangedCB, this) != BT_ERROR_NONE) {
         LogError("bt_adapter_set_state_changed_cb() failed");
     }
+
+    if(bt_adapter_set_device_discovery_state_changed_cb(onDiscoveryStateChangedCB, this) != BT_ERROR_NONE) {
+        LogError("bt_adapter_set_device_discovery_state_changed_cb() failed");
+    }    
 }
 
 BluetoothAdapter::~BluetoothAdapter()
@@ -1087,9 +1098,11 @@ void BluetoothAdapter::discoverDevices(MultiCallbackUserDataPtr userData)
 
     if(mUserDataList[DISCOVER_DEVICES] == NULL) {
         mUserDataList[DISCOVER_DEVICES] = userData;
-        
+
+        /*
         if(mUserDataList[STOP_DISCOVERY] == NULL)
             bt_adapter_set_device_discovery_state_changed_cb(onDiscoveryStateChangedCB, this);     
+        */    
     } else {
         LogError("Already requested");
         UnknownException *error = new UnknownException("Already requested");
@@ -1103,7 +1116,7 @@ void BluetoothAdapter::discoverDevices(MultiCallbackUserDataPtr userData)
             case BT_ERROR_NONE:
             {
                 LogDebug("bt_adapter_start_device_discovery() succeeded");
-                return;            
+                return;
             }
             default:
             {
@@ -1119,9 +1132,11 @@ void BluetoothAdapter::discoverDevices(MultiCallbackUserDataPtr userData)
     }
 
     mUserDataList[DISCOVER_DEVICES].reset(); 
+    /*
     if(mUserDataList[STOP_DISCOVERY] == NULL) {
         bt_adapter_unset_device_discovery_state_changed_cb();
-    }    
+    }
+    */
 }
 
 void BluetoothAdapter::stopDiscovery(MultiCallbackUserDataPtr userData)
@@ -1139,9 +1154,11 @@ void BluetoothAdapter::stopDiscovery(MultiCallbackUserDataPtr userData)
 
         if(mUserDataList[STOP_DISCOVERY] == NULL) {
             mUserDataList[STOP_DISCOVERY] = userData;
-            
+
+            /*
             if(mUserDataList[DISCOVER_DEVICES] == NULL)
                 bt_adapter_set_device_discovery_state_changed_cb(onDiscoveryStateChangedCB, this);     
+            */
         } else {
             LogDebug("Already requested");
             UnknownException *error = new UnknownException("Already requested");
@@ -1164,9 +1181,11 @@ void BluetoothAdapter::stopDiscovery(MultiCallbackUserDataPtr userData)
         }
 
         mUserDataList[STOP_DISCOVERY].reset(); 
+        /*
         if(mUserDataList[DISCOVER_DEVICES] == NULL) {
             bt_adapter_unset_device_discovery_state_changed_cb();
-        }        
+        }
+        */
     } else {   // Not enabled
         ServiceNotAvailableException *error =  new ServiceNotAvailableException("Bluetooth device is turned off");
         BluetoothCallbackUtil::syncToAsyncErrorCallback(userData, error);
index 664575b..4684a62 100644 (file)
@@ -237,13 +237,10 @@ void BluetoothSocket::close()
     
     if(bt_socket_disconnect_rfcomm(mConnectedSocket) != BT_ERROR_NONE) {
         LogError("bt_socket_disconnect_rfcomm() failed");
-        return;
+        throw UnknownException("Unknown error");
     }    
 
     mIsConnected = false;
-    if(!BluetoothAdapter::getInstance()->closeConnectedSocket(mConnectedSocket)) {
-        throw UnknownException("Unknown error");
-    }
 }
 
 } // Bluetooth
index a331bfe..657f7aa 100755 (executable)
@@ -214,7 +214,7 @@ void BookmarkManager::remove(BookmarkSearchDataPtr &searchData) {
                        std::vector<BookmarkDataPtr> deletebookmarks = _getCompleteCB(searchData);
                        result = favorites_bookmark_delete_bookmark((searchData->m_bookmark)->m_id);
                        if (result == FAVORITES_ERROR_NONE) {
-                               for (int i = 0; i < deletebookmarks.size(); ++i) {
+                               for (std::size_t i = 0; i < deletebookmarks.size(); ++i) {
                                        result = favorites_bookmark_delete_bookmark(deletebookmarks[i]->m_id);
                                        if (result != FAVORITES_ERROR_NONE)
                                                break;
index 4ed6095..44cac31 100755 (executable)
@@ -53,7 +53,7 @@ JSClassDefinition JSBookmarkFolder::m_jsClassInfo = {
     NULL, //getPropertyNames
     NULL, // callAsFunction
     NULL, // constructor
-    JSBookmarkFolder::hasInstance,
+    NULL,
     NULL // convertToType
 };
 
@@ -93,17 +93,21 @@ void JSBookmarkFolder::finalize(JSObjectRef object)
     }
 }
 
-bool JSBookmarkFolder::hasInstance(JSContextRef context, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception) {
-    return JSValueIsObjectOfClass(context, possibleInstance, getClassRef());
-}
-
 JSObjectRef JSBookmarkFolder::constructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception){
     LogDebug("Enter");
        try{
                ArgumentValidator validator(ctx, argumentCount, arguments);
 
                std::string title = validator.toString(0);
-           return createJSObject(ctx, title);
+           JSObjectRef bookmarkFolder = createJSObject(ctx, title);
+               if (bookmarkFolder) {
+                       JSStringRef ctorName = JSStringCreateWithUTF8CString("constructor");
+                   JSObjectSetProperty(ctx, bookmarkFolder, ctorName, constructor,
+                       kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete | kJSPropertyAttributeDontEnum, NULL);
+               JSStringRelease(ctorName);
+                       return bookmarkFolder;
+               } else
+                       throw TypeMismatchException("Can't create BookmarkFolder");
     } catch(const BasePlatformException& err){
         JSObjectRef error = JSWebAPIException::makeJSWebAPIException(ctx, err);
         *exception = error;
index cd28971..2ce2599 100755 (executable)
@@ -37,7 +37,6 @@ class JSBookmarkFolder
        static JSObjectRef createJSObject(JSContextRef context, void * priv);
 #endif
        static JSValueRef getParent(JSContextRef context, JSObjectRef object);
-       static bool hasInstance(JSContextRef context, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception);
        static JSValueRef getProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception);
   private:
 
index 0f287cc..51edb4a 100755 (executable)
@@ -54,7 +54,7 @@ JSClassDefinition JSBookmarkItem::m_jsClassInfo = {
     NULL, //getPropertyNames
     NULL, // callAsFunction
     NULL, // constructor
-    JSBookmarkItem::hasInstance,
+    NULL,
     NULL // convertToType
 };
 
@@ -96,17 +96,21 @@ void JSBookmarkItem::finalize(JSObjectRef object)
     }
 }
 
-bool JSBookmarkItem::hasInstance(JSContextRef context, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception) {
-    return JSValueIsObjectOfClass(context, possibleInstance, getClassRef());
-}
-
 JSObjectRef JSBookmarkItem::constructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception){
     LogDebug("JSBookmarkItem::constructor()");
     ArgumentValidator validator(ctx, argumentCount, arguments);
     try{
         std::string title = validator.toString(0);
                std::string url = validator.toString(1);
-               return createJSObject(ctx, title, url);
+           JSObjectRef bookmarkItem = createJSObject(ctx, title, url);
+               if (bookmarkItem) {
+                       JSStringRef ctorName = JSStringCreateWithUTF8CString("constructor");
+                   JSObjectSetProperty(ctx, bookmarkItem, ctorName, constructor,
+                       kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete | kJSPropertyAttributeDontEnum, NULL);
+               JSStringRelease(ctorName);
+                       return bookmarkItem;
+               } else
+                       throw TypeMismatchException("Can't create BookmarkItem");
     }catch(const BasePlatformException& err){
         JSObjectRef error = JSWebAPIException::makeJSWebAPIException(ctx, err);
         *exception = error;
index 75ae5fb..7a0e110 100755 (executable)
@@ -36,7 +36,6 @@ class JSBookmarkItem
 #if 0
        static JSObjectRef createJSObject(JSContextRef context, void * priv);
 #endif
-       static bool hasInstance(JSContextRef context, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception);
        static JSValueRef getProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception);
   private:
 
index 35606f0..6260ee0 100755 (executable)
@@ -778,7 +778,16 @@ CalendarEventPtr CalendarConverter::toItem(const JSValueRef value, bool updateMo
 
        if(updateMode) {
                LogDebug("Update mode.");
-        result = JSCalendarEvent::getPrivateObject(arg);
+           CalendarEventPtr resultPtr(new CalendarEvent());
+               result = resultPtr;
+
+               // Set the unparsed attributes.
+        CalendarEventPtr oldItem = JSCalendarEvent::getPrivateObject(arg);
+               result->setId(oldItem->getId());
+               result->setParentId(oldItem->getParentId());
+               result->setCalendarId(oldItem->getCalendarId());
+               result->setRecurrenceId(oldItem->getRecurrenceId());
+               result->setCalendarType(oldItem->getCalendarType());
        } else {
                LogDebug("Constructor mode.");
            CalendarEventPtr resultPtr(new CalendarEvent());
@@ -838,7 +847,7 @@ CalendarEventPtr CalendarConverter::toItem(const JSValueRef value, bool updateMo
     }
 
     //It's important to set startTime before duration to set end date
-    if (!JSValueIsUndefined(m_context, startTimeData)) {
+    if (!JSValueIsUndefined(m_context, startTimeData) && !JSValueIsNull(m_context, startTimeData)) {
         result->setStartTime((long long int) (timeUtilConverter.getTimeInMilliseconds(startTimeData)/1000));
         result->setTimeZone(timeUtilConverter.getPropertiesInTZDate(startTimeData).timezone);
         LogInfo("start time converted from TZDate: "<<result->getStartTime()<<", time zone: "<<result->getTimeZone());
@@ -846,7 +855,7 @@ CalendarEventPtr CalendarConverter::toItem(const JSValueRef value, bool updateMo
        LogDebug("Start time undefined.");
     }
 
-    if (!JSValueIsUndefined(m_context, durationData)) {
+    if (!JSValueIsUndefined(m_context, durationData) && !JSValueIsNull(m_context, durationData)) {
         long long length = timeUtilConverter.getDurationLength(durationData);
         int unit = timeUtilConverter.getDurationUnit(durationData);
         LogDebug("duration length: "<<length<<", unit "<<unit);
@@ -873,7 +882,7 @@ CalendarEventPtr CalendarConverter::toItem(const JSValueRef value, bool updateMo
         *categories = toVectorOfStrings(categoriesData);
         result->setCategories(categories);
     }
-    
+
     if (!JSValueIsUndefined(m_context, statusData)) {
         result->setStatus(toEventStatus(toString(statusData)));
     } else {
@@ -893,39 +902,37 @@ CalendarEventPtr CalendarConverter::toItem(const JSValueRef value, bool updateMo
         EventAttendeeListPtr attendees = toVectorOfAttendeesFromReference(attendeesData);
         result->setAttendees(attendees);
     }
-    if (!JSValueIsUndefined(m_context, geolocationData)) {
+
+    if (!JSValueIsUndefined(m_context, geolocationData) && !JSValueIsNull(m_context, geolocationData)) {
         DeviceAPI::Tizen::SimpleCoordinatesPtr geoLocation = DeviceAPI::Tizen::JSSimpleCoordinates::getSimpleCoordinates(m_context, geolocationData);
         result->setGeolocation(geoLocation);
     }
+
     if (!JSValueIsUndefined(m_context, visibilityData)) {
         result->setVisibility(toEventVisibility(toString(visibilityData)));
     }
     if (!JSValueIsUndefined(m_context, availabilityData)) {
         result->setAvailability(toEventAvailability(toString(availabilityData)));
     }
-    if (!JSValueIsUndefined(m_context, recurrenceRuleData)) {
-               if(updateMode) {
-                       result->setRecurrenceRule(toEventRecurrenceRule(recurrenceRuleData));
-               } else {
-               result->setRecurrenceRule(JSCalendarRecurrenceRule::getPrivateObject(JSValueToObject(m_context, recurrenceRuleData, NULL)));
-               }
+    if (!JSValueIsUndefined(m_context, recurrenceRuleData) && !JSValueIsNull(m_context, recurrenceRuleData)) {
+        result->setRecurrenceRule(JSCalendarRecurrenceRule::getPrivateObject(JSValueToObject(m_context, recurrenceRuleData, NULL)));
     }
     if (!JSValueIsUndefined(m_context, priorityData)) {
         result->setPriority(toTaskPriority(toString(priorityData)));
     }
-    if (!JSValueIsUndefined(m_context, endDateData)) {
+    if (!JSValueIsUndefined(m_context, endDateData) && !JSValueIsNull(m_context, endDateData)) {
         if( result->getTimeZone().empty() ) {
             result->setTimeZone(timeUtilConverter.getPropertiesInTZDate(endDateData).timezone);
         }
         result->setEndTime((long long int) (timeUtilConverter.getTimeInMilliseconds(endDateData)/1000));
     }
-    if (!JSValueIsUndefined(m_context, dueDateData)) {
+    if (!JSValueIsUndefined(m_context, dueDateData) && !JSValueIsNull(m_context, dueDateData)) {
         if( result->getTimeZone().empty() ) {
             result->setTimeZone(timeUtilConverter.getPropertiesInTZDate(dueDateData).timezone);
         }
         result->setEndTime((long long int) (timeUtilConverter.getTimeInMilliseconds(dueDateData)/1000));
     }
-    if (!JSValueIsUndefined(m_context, completedDateData)) {
+    if (!JSValueIsUndefined(m_context, completedDateData) && !JSValueIsNull(m_context, completedDateData)) {
         if( result->getTimeZone().empty() ) {
             result->setTimeZone(timeUtilConverter.getPropertiesInTZDate(completedDateData).timezone);
         }
index 91cdf32..4c50a33 100755 (executable)
@@ -42,7 +42,6 @@ CalendarEvent::CalendarEvent():
     m_recurrenceId(UNDEFINED_TIME),
     m_attendees(new EventAttendeeList()),
     m_isDetached(false),
-    m_attributesOfInterest(new AttributeList()),
     m_geolocation(new DeviceAPI::Tizen::SimpleCoordinates(UNDEFINED_GEO, UNDEFINED_GEO)),
     m_timeZone(DEFAULT_TIMEZONE),
     m_priority(LOW_PRIORITY),
@@ -133,10 +132,6 @@ CalendarEvent::CalendarEvent(const CalendarEvent &original)
 
     m_isDetached = original.getIsDetached();
 
-    AttributeListPtr attributesPtr( new AttributeList() );
-    m_attributesOfInterest = attributesPtr;
-    *m_attributesOfInterest = *(original.getAttributesOfInterest());
-
     DeviceAPI::Tizen::SimpleCoordinatesPtr geolocationPtr( new DeviceAPI::Tizen::SimpleCoordinates(original.getGeolocation()->getLatitude(), original.getGeolocation()->getLongitude()));
     m_geolocation = geolocationPtr;
 
@@ -427,16 +422,6 @@ void CalendarEvent::setIsDetached(bool value)
     m_isDetached = value;
 }
 
-AttributeListPtr CalendarEvent::getAttributesOfInterest() const
-{
-    return m_attributesOfInterest;
-}
-
-void CalendarEvent::setAttributesOfInterest(AttributeListPtr value)
-{
-    m_attributesOfInterest = value;
-}
-
 DeviceAPI::Tizen::SimpleCoordinatesPtr CalendarEvent::getGeolocation() const
 {
     return m_geolocation;
index 78f6706..d25d1e8 100755 (executable)
@@ -40,9 +40,6 @@ namespace Calendar {
 #define UNDEFINED_GEO CALENDAR_RECORD_NO_COORDINATE
 #define UNDEFINED_ID "-1"
 
-typedef std::vector<std::string> AttributeList;
-typedef DPL::SharedPtr<AttributeList> AttributeListPtr;
-
 /* This object represents a single calendar event */
 class CalendarEvent
 {
@@ -172,9 +169,6 @@ class CalendarEvent
     bool getIsDetached() const;
     void setIsDetached(bool value);
 
-    void setAttributesOfInterest(AttributeListPtr value);
-    AttributeListPtr getAttributesOfInterest() const;
-
     DeviceAPI::Tizen::SimpleCoordinatesPtr getGeolocation() const;
     void setGeolocation(DeviceAPI::Tizen::SimpleCoordinatesPtr value);
 
@@ -222,7 +216,6 @@ class CalendarEvent
     long long int m_recurrenceId;
     EventAttendeeListPtr m_attendees;
     bool m_isDetached;
-    AttributeListPtr m_attributesOfInterest;
        DeviceAPI::Tizen::SimpleCoordinatesPtr m_geolocation;
     std::string m_timeZone;
     TaskPriority m_priority;
index 2f03209..2af7e10 100755 (executable)
@@ -523,14 +523,12 @@ void EventWrapper::setRecurrenceRuleToPlatformEvent()
 
     EventRecurrenceRulePtr rrule  = m_abstractEvent->getRecurrenceRule();
     if (NULL==rrule) {
-        LogDebug("rrule is not set.");
+        LogWarning("No way! Rrule is not set!");
         return;
     } else if(EventRecurrenceRule::NO_RECURRENCE==rrule->getFrequency()) {
         LogDebug("No recurrence frequency.");
-        return;
     } else if(EventRecurrenceRule::UNDEFINED_RECURRENCE==rrule->getFrequency()) {
         LogDebug("Undefined recurrence frequency.");
-        return;
     } else {
         LogDebug("frequency "<<rrule->getFrequency());
     }
@@ -538,6 +536,7 @@ void EventWrapper::setRecurrenceRuleToPlatformEvent()
     // set frequency
     switch (rrule->getFrequency()) {
     case EventRecurrenceRule::NO_RECURRENCE:
+    case EventRecurrenceRule::UNDEFINED_RECURRENCE:
         if(CALENDAR_ERROR_NONE!=calendar_record_set_int(m_platformEvent, _calendar_event.freq, CALENDAR_RECURRENCE_NONE)) {
             LogWarning("Failed setting frequency.");
         }
@@ -568,7 +567,6 @@ void EventWrapper::setRecurrenceRuleToPlatformEvent()
         }
         break;
     }
-    case EventRecurrenceRule::UNDEFINED_RECURRENCE:
     default:
         LogWarning("Invalid reccurence rule frequency "<<rrule->getFrequency());
         break;
index 5fef48a..07d7427 100755 (executable)
@@ -29,7 +29,6 @@ namespace Calendar {
 
 class IEventWatchChanges : public WrtDeviceApis::Commons::IEvent<IEventWatchChanges>
 {
-    AttributeListPtr m_attributesOfInterest;
     bool m_result;
     long m_watchId;
     OnEventsChangedEmitterPtr m_emitter;
@@ -44,15 +43,6 @@ class IEventWatchChanges : public WrtDeviceApis::Commons::IEvent<IEventWatchChan
         return m_result;
     }
 
-    void             setAttributes(AttributeListPtr value)
-    {
-        m_attributesOfInterest = value;
-    }
-    AttributeListPtr getAttributes() const
-    {
-        return m_attributesOfInterest;
-    }
-
     void             setWatchId(long value)
     {
         m_watchId = value;
old mode 100644 (file)
new mode 100755 (executable)
index e73df7d..9bb827e
@@ -57,6 +57,24 @@ JSValueRef ArgumentValidator::getArgument(int index, bool nullable) const{
     return value;
 }
 
+bool ArgumentValidator::isOmitted(int index){
+    if( index < mArgc)
+        return false;
+    return true;
+}
+bool ArgumentValidator::isNull(int index){
+    if( !isOmitted(index) && JSValueIsNull(mContext, mArgv[index]) ){
+        return true;
+    }
+    return false;
+}
+bool ArgumentValidator::isUndefined(int index){
+    if( !isOmitted(index) && JSValueIsUndefined(mContext, mArgv[index]) ){
+        return true;
+    }
+    return false;
+}
+
 double ArgumentValidator::toNumber(int index, bool nullable, double defaultvalue) const{
     JSValueRef value = getArgument(index, nullable);
     if( JSValueIsNull(mContext, value) && nullable){
old mode 100644 (file)
new mode 100755 (executable)
index a38f05a..fcbc385
@@ -49,6 +49,10 @@ public:
     JSObjectRef toArrayObject(int index, bool nullable = false) const;
     JSValueRef toJSValueRef(int index, bool nullable = false) const;
 
+    bool isOmitted(int index);
+    bool isNull(int index);
+    bool isUndefined(int index);
+
     JSObjectRef toCallbackObject(int index, bool nullable, const char *callback, ...) const;
 
     std::vector<std::string> toStringVector(int index, bool nullable = false) const;
index 39c04fe..c7720d8 100755 (executable)
@@ -404,7 +404,9 @@ class LineBuffer{
     vector<string> mHistory;
     string mLine;
     int mHistoryIndex;
-    char mCurrentPos;
+    int mCurrentPos;
+    int mCurrentPosTmp;
+    int mLineLength;
 public:
     LineBuffer():mHistoryIndex(0), mCurrentPos(0){
         tcgetattr(0, &gSave);
@@ -421,17 +423,43 @@ public:
             putchar('\b');
         }
     }
+
+    void cleanLine(){
+        int diff = mLineLength - mCurrentPosTmp;
+        while( diff-- > 0 ){
+            moveCursor(false);
+        }
+        backSpace(mLineLength);
+    }
+
     void applyHistory( unsigned int index ){
         if( mHistory.size() > index ){
             mLine = mHistory[index];
             mCurrentPos = mLine.size();
         }
     }
+
+    void moveCursor( bool Left ){
+        putchar(27);putchar(91);
+        if( Left )
+            putchar(68);
+        else
+            putchar(67);
+    }
+
+    void moveCurrentCursorPosition(){
+        int diff = mLine.size() - mCurrentPos;
+
+        while( diff-- > 0 ){
+            moveCursor(true);
+        }
+    }
+
     bool checkSpecialKeys(int a){
         if( a == 8 ){
-            if( mLine.size() != 0){
+            if( mLine.size() != 0 && mCurrentPos != 0){
                 mCurrentPos--;
-                mLine.erase(mCurrentPos);
+                mLine.erase(mCurrentPos,1);
             }
             return true;
         }
@@ -453,13 +481,29 @@ public:
                     break;
                 case 67:
                     //RIGHT
+                    if( mCurrentPos < mLine.size())
+                        mCurrentPos++;
                     break;
                 case 68:
                     //LEFT
+                    if( mCurrentPos > 0 )
+                        mCurrentPos--;
                     break;
                 case 51:
+                    //delete
+                    getch();
+                    if( mCurrentPos < mLine.size())
+                        mLine.erase(mCurrentPos,1);
+                    break;
+                case 52:
+                    //end
+                    getch();
+                    mCurrentPos = mLine.size();
+                    break;
+                case 49:
+                    //home
+                    mCurrentPos = 0;
                     getch();
-                    backSpace(1);
                     break;
                 default:
                     getch();
@@ -474,9 +518,11 @@ public:
         printf("%s", prompt);
         mCurrentPos = 0;
         mLine.clear();
+        mLineLength = mLine.size();
+        mCurrentPosTmp = mCurrentPos;
         while(1){
             int a = getch();
-            backSpace(mLine.size());
+            cleanLine();
             if( a == 10 )
                 break;
 
@@ -485,6 +531,9 @@ public:
                 mCurrentPos++;
             }
             cout << mLine;
+            moveCurrentCursorPosition();
+            mLineLength = mLine.size();
+            mCurrentPosTmp = mCurrentPos;
         }
         cout << mLine;
         if( mLine.size() > 0 ){
index 41140e0..b13041b 100755 (executable)
@@ -266,8 +266,8 @@ JSValueRef JSMediacontentManager::findItems(
         sortModeObj= argValidator.toObject(4,true);
 
         // count
-        if(argumentCount >= 6){        
-//            if(!JSValueIsNull(context, arguments[5]) && !JSValueIsUndefined(context, arguments[5])){
+        if(argumentCount >= 6){
+            if(!JSValueIsNull(context, arguments[5])){
                 long count = argValidator.toLong(5, true, 0);
                 if( count >= 0L ){
                     dplEvent->setLimit(count);
@@ -275,7 +275,7 @@ JSValueRef JSMediacontentManager::findItems(
                 else{
                     throw InvalidValuesException( "count should be positive.");
                 }
-//            }
+            }
         }
         if(argumentCount >= 7){
             // offset
index 7326c6a..7cfea33 100755 (executable)
@@ -118,6 +118,13 @@ JSValueRef Converter::toJSValueRef(unsigned char* data, std::size_t num)
        return result;
 }
 
+JSValueRef Converter::toJSValueRef(unsigned long long arg)
+{
+    return JSValueMakeNumber(m_context, arg);
+}
+
+
+
 IPathPtr Converter::toPath(const JSValueRef& arg)
 {
        Try {
index f7a41cc..0e11502 100755 (executable)
@@ -49,6 +49,7 @@ public:
             JSContextRef context);     
        JSValueRef toJSValueRef(unsigned char* data,
                std::size_t num);
+       JSValueRef toJSValueRef(unsigned long long arg);
 
        IPathPtr toPath(const JSValueRef& arg);
 
index 1a2d5b4..91ca0b0 100755 (executable)
@@ -143,7 +143,7 @@ class INode : public WrtDeviceApis::Commons::EventRequestReceiver<EventListNodes
      * Gets size of this node.
      * @return Size.
      */
-    virtual std::size_t getSize() const = 0;
+    virtual unsigned long long getSize() const = 0;
 
     /**
      * Gets creation date of this node.
index d30bf4d..3e782f1 100755 (executable)
@@ -118,7 +118,7 @@ class IStream : private DPL::Noncopyable
      * Gets stream's size.
      * @return Size or -1 if unavailable (e.g. stream is write-only).
      */
-    virtual long getSize() const = 0;
+    virtual unsigned long long getSize() const = 0;
     virtual void setCharSet(const std::string &charSet) = 0;
     virtual  std::string getCharSet() const = 0; 
        
index 7fd1982..a80d699 100755 (executable)
@@ -133,8 +133,8 @@ JSValueRef JSFilestream::getProperty(JSContextRef context,
                        }
                        return converter.toJSValueRef(static_cast<unsigned long>(pos));
                } else if (JSStringIsEqualToUTF8CString(propertyName, PROPERTY_BYTES_AVAILABLE)) {
-                       long bytes = stream->getSize() - stream->getPosition();
-                       return converter.toJSValueRef(static_cast<unsigned long>(bytes));
+                       unsigned long long bytes = stream->getSize() - stream->getPosition();
+                       return converter.toJSValueRef(static_cast<unsigned long long>(bytes));
                }
        } catch (const WrtDeviceApis::Commons::ConversionException& ex) {
                LogWarning("trying to get incorrect value");
index 7f088bd..06f6581 100755 (executable)
@@ -277,7 +277,7 @@ void Node::remove(int options)
     }
 }
 
-std::size_t Node::getSize() const
+unsigned long long Node::getSize() const
 {
     if (m_type == NT_DIRECTORY) {
         ThrowMsg(Commons::PlatformException,
index 4b976cd..233d7b1 100755 (executable)
@@ -46,7 +46,7 @@ class Node : public INode,
     NodeType getType() const;
     int getPermissions() const;
     void setPermissions(int perms);
-    std::size_t getSize() const;
+    unsigned long long getSize() const;
     std::time_t getCreated() const;
     std::time_t getModified() const;
     INodePtr getParent() const;
index 6c5da12..ffa8c64 100755 (executable)
@@ -31,7 +31,7 @@ namespace DeviceAPI {
 namespace Filesystem {
 typedef DPL::Optional<std::string> OptionalString;
 typedef DPL::Optional<std::time_t> OptionalDate;
-typedef DPL::Optional<std::size_t> OptionalSize;
+typedef DPL::Optional<unsigned long long> OptionalSize;
 
 class NodeFilter
 {
index 76fbaea..64098b8 100755 (executable)
@@ -232,7 +232,7 @@ void Stream::setPosition(long position)
     }
 }
 
-long Stream::getSize() const
+unsigned long long Stream::getSize() const
 {
     std::fstream::streampos pos = m_stream.tellg();
     if (pos == -1) {
@@ -243,7 +243,7 @@ long Stream::getSize() const
         return -1;
     }
 
-    long result = m_stream.tellg();
+    unsigned long long result = m_stream.tellg();
     m_stream.seekg(pos, std::_S_beg);
 
     return (result == -1 ? result : result + 1);
index 23aae10..7c40f07 100755 (executable)
@@ -75,7 +75,7 @@ class Stream : public IStream,
 
     int getMode() const;
 
-    long getSize() const;
+    unsigned long long getSize() const;
 
   private:
     template<typename T>
index 1231492..3c54588 100644 (file)
@@ -475,7 +475,7 @@ MessageType ConverterMessage::toMessageType(std::string arg)
     else
     {
         std::string message = "Message type " + arg + " not supported.";
-        throw DeviceAPI::Common::InvalidValuesException(message.c_str());
+        throw DeviceAPI::Common::TypeMismatchException(message.c_str());
     }
 
 }
old mode 100644 (file)
new mode 100755 (executable)
index 7e993ac..a05f153
@@ -57,10 +57,12 @@ namespace
                                EventTagActionReadPtr event = ((EventNFCPtrs<EventTagActionRead> *)data)->getEventPtrs();
                                LogDebug("message handler :" << message);
 
-                               unsigned char *rawdata;
+                               unsigned char *rawdata = NULL;
                                int size;
                                if (nfc_ndef_message_get_rawdata(message, &rawdata, &size) != NFC_ERROR_NONE) {
                                        LogError("Can't get record's rawdata");
+                                       if (rawdata)
+                                               free(rawdata);
                                        return;
                                }
 
index 67bdce6..6adcc90 100755 (executable)
@@ -41,10 +41,12 @@ namespace
        static void TargetReceivedCallback(nfc_p2p_target_h target, nfc_ndef_message_h message, void *user_data) {
                LogDebug("Callback TargetReceivedCallback.");
                if (user_data) {
-                       unsigned char *rawdata;
+                       unsigned char *rawdata = NULL;
                        int size;
                        if (nfc_ndef_message_get_rawdata(message, &rawdata, &size) != NFC_ERROR_NONE) {
                                LogError("Can't get rawdata of message");
+                               if (rawdata)
+                                       free(rawdata);
                                return;
                        }
 
index 707a89b..4dbef30 100755 (executable)
@@ -145,7 +145,7 @@ long NdefMessage::getRecordCount() {
 }
 
 std::vector<unsigned char> NdefMessage::toByte() {
-       unsigned char *rawdata;
+       unsigned char *rawdata = NULL;
        int size;
        NFCUtil util;
 
@@ -154,9 +154,11 @@ std::vector<unsigned char> NdefMessage::toByte() {
 
        int result = nfc_ndef_message_get_rawdata(handle, &rawdata, &size);
 
-       if (result != NFC_ERROR_NONE)
+       if (result != NFC_ERROR_NONE) {
+               if (rawdata)
+                       free(rawdata);
                util.throwNFCException(result, "Can't get serial bytes of NDEF message");
-
+       }
        LogDebug(rawdata);
        std::vector<unsigned char> byteData = util.toVector(rawdata, size);
        if (rawdata)
index edea7c8..64743c2 100755 (executable)
@@ -110,7 +110,6 @@ bool JSStatusNotification::setProperty(JSContextRef context,
                        priv->setProgressType(progType);        //set progress Type
 
                        return true;
-
                   }
                   else if ( property == STATUS_NOTIFICATION_PROGRESS_VALUE)
                   {
@@ -155,7 +154,6 @@ JSValueRef JSStatusNotification::getProperty(JSContextRef context,
        }
 
        try {
-
                    std::string property;
                    size_t jsSize = JSStringGetMaximumUTF8CStringSize(propertyName);
                    if (jsSize > 0) {
@@ -186,25 +184,31 @@ JSValueRef JSStatusNotification::getProperty(JSContextRef context,
                   
                   }
                   else if ( property == STATUS_NOTIFICATION_PROGRESS_VALUE)
-                  {
-                               // progressValue
-
-                               LogInfo("Progress Type=" << priv->getProgressType());
-                               
-                                  // progressValue
-                               unsigned long progressVal = 0;  
-                               if ( NOTI_PROGRESS_TYPE_PERCENTAGE ==  priv->getProgressType())
-                               {
-                                       progressVal = (unsigned long)( (priv->getProgressValue()*100) );
-                               }
-                               else if ( NOTI_PROGRESS_TYPE_SIZE==   priv->getProgressType())
-                               {
-                                       progressVal = (unsigned long)priv->getProgressValue();
-                               }
-                               
-                               LogInfo("Progress Value=" << progressVal);      
-                  
+                  {                            
+                       // progressValue
+                       LogInfo("Progress Type=" << priv->getProgressType());
+                       
+                          // progressValue
+                       unsigned long progressVal = 0;  
+                       if ( NOTI_PROGRESS_TYPE_PERCENTAGE ==  priv->getProgressType())
+                       {
+                               progressVal = (unsigned long)( (priv->getProgressValue()*100) );
+                       }
+                       else if ( NOTI_PROGRESS_TYPE_SIZE==   priv->getProgressType())
+                       {
+                               progressVal = (unsigned long)priv->getProgressValue();
+                       }
+                       
+                       LogInfo("Progress Value=" << progressVal);
+
+                       if( priv->getNotiType() != NOTI_TYPE_PROGRESS && progressVal == 0)
+                       {
+                               return JSValueMakeNull(context);
+                       }
+                       else
+                       {                                  
                                return  JSUtil::toJSValueRef(context, progressVal);
+                       }
                   }
 
     }
@@ -213,7 +217,8 @@ JSValueRef JSStatusNotification::getProperty(JSContextRef context,
         LogWarning(" notification convertion is failed. "   << err.getName().c_str() << ":"  << err.getMessage().c_str());
        return NULL;
     }
-                
+
+   return NULL;
 }
 
 
@@ -261,8 +266,9 @@ JSObjectRef JSStatusNotification::constructor(JSContextRef context,
     JSObjectSetProperty(context, obj, ctorName, constructor,
                kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete | kJSPropertyAttributeDontEnum, NULL);
     JSStringRelease(ctorName);
-
+       
     try {
+       //Status Notification Type.
         NotificationType notiType = NOTI_TYPE_NONE;
         std::string strStatusType = validator.toString(0, false, "");
         LogInfo("Notification Type : " << strStatusType);
@@ -276,229 +282,213 @@ JSObjectRef JSStatusNotification::constructor(JSContextRef context,
         else if( strStatusType.compare(TIZEN_STATUS_NOTIFICATION_TYPE_PROGRESS) == 0)
             notiType = NOTI_TYPE_PROGRESS;
         else
-            throw TypeMismatchException("status type mismatch.");
+            throw TypeMismatchException("notification status type mismatch.");
         
         StatusNotification *priv = new StatusNotification(notiType);
         
         priv->setTitle(validator.toString(1, false, ""));    //title
         
-            JSObjectRef notiInitDict = validator.toObject(2, true);
+        JSObjectRef notiInitDict = validator.toObject(2, true);
        
-            if (notiInitDict)
-            {
-                //content
-                try {             
-                    JSValueRef contentValue = JSUtil::getProperty(context, notiInitDict, NOTIFICATION_CONTENT);
-                    if (!JSValueIsUndefined(context, contentValue))
-                        priv->setContent(JSUtil::JSValueToString(context, contentValue));
-                }
-                catch ( const BasePlatformException& err) 
+        if (notiInitDict)
+        {
+            LogInfo("Set Notification Init Dictionary");
+            //content
+            JSValueRef contentValue = JSUtil::getProperty(context, notiInitDict, NOTIFICATION_CONTENT);
+           if (!JSValueIsUndefined(context, contentValue))
+            {          
+               priv->setContent(JSUtil::JSValueToString(context, contentValue));
+           }
+                    
+            //icon
+            try {                 
+                JSValueRef iconValue = JSUtil::getProperty(context, notiInitDict, STATUS_NOTIFICATION_ICON_PATH);
+                if (!JSValueIsUndefined(context, iconValue))
                 {
-                    LogWarning("notification's content convertion is failed."  << err.getMessage().c_str());
+                    DeviceAPI::Filesystem::IPathPtr path = DeviceAPI::Filesystem::Utils::fromVirtualPath(context, JSUtil::JSValueToString(context, iconValue));
+                    priv->setIconPath(path->getFullPath());
                 }
+            }
+           catch (...)
+           {
+               throw InvalidValuesException("Icon file path is invaild");
+           }
+#if 0                  
+            catch ( const BasePlatformException& err) 
+            {
+                LogWarning("notification's icon path convertion is failed."  << err.getMessage());
+            }
+#endif
             
-                //icon
-                try {             
-                    JSValueRef iconValue = JSUtil::getProperty(context, notiInitDict, STATUS_NOTIFICATION_ICON_PATH);
-                    if (!JSValueIsUndefined(context, iconValue))
-                    {
-                        DeviceAPI::Filesystem::IPathPtr path = DeviceAPI::Filesystem::Utils::fromVirtualPath(context, JSUtil::JSValueToString(context, iconValue));
-                        priv->setIconPath(path->getFullPath());
-                    }
-                }
-                catch ( const BasePlatformException& err) 
+            //sound
+            try {                 
+                JSValueRef soundValue   = JSUtil::getProperty(context, notiInitDict, STATUS_NOTIFICATION_SOUND_PATH);     
+                if (!JSValueIsUndefined(context, soundValue))
                 {
-                    LogWarning("notification's icon path convertion is failed."  << err.getMessage().c_str());
-                }
-                
-                //sound
-                try {             
-                    JSValueRef soundValue   = JSUtil::getProperty(context, notiInitDict, STATUS_NOTIFICATION_SOUND_PATH);         
-                    if (!JSValueIsUndefined(context, soundValue))
-                    {
-                        DeviceAPI::Filesystem::IPathPtr path = DeviceAPI::Filesystem::Utils::fromVirtualPath(context, JSUtil::JSValueToString(context, soundValue));
-                        priv->setSoundPath(path->getFullPath());
-                    }
-                }
-                catch ( const BasePlatformException& err) 
-                {
-                    LogWarning("notification's sound path convertion is failed."  << err.getMessage().c_str());
-                }
-                
-                //vibration
-                try {             
-                    JSValueRef vibrationValue = JSUtil::getProperty(context, notiInitDict, STATUS_NOTIFICATION_VIBRATION);
-                    if (!JSValueIsUndefined(context, vibrationValue))
-                    {
-                        priv->setDefaultVibration(JSUtil::JSValueToBoolean(context, vibrationValue));
-                    }
-                }
-                catch ( const BasePlatformException& err) 
-                {
-                    LogWarning("notification's vibration value convertion is failed."  << err.getMessage().c_str());
-                }              
-                
-                //appControl
-                try {             
-                    JSValueRef appControlValue  = JSUtil::getProperty(context, notiInitDict, STATUS_NOTIFICATION_APP_CONTROL);  
-                    if (!JSValueIsUndefined(context, appControlValue))
-                    {
-                       priv->setApplicationControl(DeviceAPI::Application::JSApplicationControl::getApplicationControl(context, JSUtil::JSValueToObject(context, appControlValue) ));
-                    }
-                }
-                catch ( const BasePlatformException& err) 
-                {
-                    LogWarning("notification's App Control convertion is failed."  << err.getMessage().c_str());
-                }
-        
-                //appID
-                try {             
-                    JSValueRef appIdValue         = JSUtil::getProperty(context, notiInitDict, STATUS_NOTIFICATION_APP_ID);
-                    if (!JSValueIsUndefined(context, appIdValue))
-                    {
-                        priv->setApplicationId(JSUtil::JSValueToString(context, appIdValue));
-                    }
-                }
-                catch ( const BasePlatformException& err) 
-                {
-                    LogWarning("notification's icon path convertion is failed."  << err.getMessage().c_str());
+                    DeviceAPI::Filesystem::IPathPtr path = DeviceAPI::Filesystem::Utils::fromVirtualPath(context, JSUtil::JSValueToString(context, soundValue));
+                    priv->setSoundPath(path->getFullPath());
                 }
+            }
+           catch (...)
+            {
+                throw InvalidValuesException("sound file path is invaild");
+           }
+       
+            //vibration
+            JSValueRef vibrationValue = JSUtil::getProperty(context, notiInitDict, STATUS_NOTIFICATION_VIBRATION);
+            priv->setDefaultVibration(JSUtil::JSValueToBoolean(context, vibrationValue));
+            
+            //appControl
+            JSValueRef appControlValue  = JSUtil::getProperty(context, notiInitDict, STATUS_NOTIFICATION_APP_CONTROL);
+           if (!JSValueIsUndefined(context, appControlValue))
+               priv->setApplicationControl(DeviceAPI::Application::JSApplicationControl::getApplicationControl(context, JSUtil::JSValueToObject(context, appControlValue) ));
+            
+            //appID               
+            JSValueRef appIdValue = JSUtil::getProperty(context, notiInitDict, STATUS_NOTIFICATION_APP_ID);
+            if (!JSValueIsUndefined(context, appIdValue))
+                priv->setApplicationId(JSUtil::JSValueToString(context, appIdValue));
+                          
+            //progressType
+            NotificationProgressType progressType = NOTI_PROGRESS_TYPE_PERCENTAGE;
+
+           JSStringRef propertyName = JSStringCreateWithUTF8CString(STATUS_NOTIFICATION_PROGRESS_TYPE);
+            bool has = JSObjectHasProperty(context, notiInitDict, propertyName);
+            JSStringRelease(propertyName);
+           if (has)
+           {
+                JSValueRef progressTypeValue = JSUtil::getProperty(context, notiInitDict, STATUS_NOTIFICATION_PROGRESS_TYPE);
+               std::string strProgressType = JSUtil::JSValueToString(context, progressTypeValue);
+               LogInfo("==Progress Type : " << strProgressType);       
+               if( strProgressType.compare(TIZEN_NOTIFICATION_PROGRESS_TYPE_PERCENTAGE) == 0)
+                       progressType = NOTI_PROGRESS_TYPE_PERCENTAGE;
+               else if( strProgressType.compare(TIZEN_NOTIFICATION_PROGRESS_TYPE_BYTE) == 0)
+                       progressType = NOTI_PROGRESS_TYPE_SIZE;
+               else
+                       throw TypeMismatchException("Invalid Progress Type.");          
+           }
+           priv->setProgressType(progressType);
 
-                          
-                //progressType
-                NotificationProgressType progressType = NOTI_PROGRESS_TYPE_PERCENTAGE;
-                try {
-                    JSValueRef progressTypeValue = JSUtil::getProperty(context, notiInitDict, STATUS_NOTIFICATION_PROGRESS_TYPE);
-                    if (!JSValueIsUndefined(context, progressTypeValue))
-                    {
-                        std::string strProgressType = JSUtil::JSValueToString(context, progressTypeValue);
-                        LogInfo("Progress Type : " << strProgressType);
-                        
-                        
-                        if( strProgressType.compare(TIZEN_NOTIFICATION_PROGRESS_TYPE_PERCENTAGE) == 0)
-                            progressType = NOTI_PROGRESS_TYPE_PERCENTAGE;
-                        else if( strProgressType.compare(TIZEN_NOTIFICATION_PROGRESS_TYPE_BYTE) == 0)
-                            progressType = NOTI_PROGRESS_TYPE_SIZE;
-                        else
-                            throw InvalidValuesException("Invalid Progress Type.");
-                            
-                        priv->setProgressType(progressType);
-                    }
-                }
-                catch ( const BasePlatformException& err) 
-                {
-                    LogWarning("notification's icon path convertion is failed."  << err.getMessage().c_str());
-                }
-    
-                //ProgressValue
-                try {             
-                    JSValueRef progressValue    = JSUtil::getProperty(context, notiInitDict, STATUS_NOTIFICATION_PROGRESS_VALUE);         
-                    if (!JSValueIsUndefined(context, progressValue))
-                    {
-                        if ( progressType == NOTI_PROGRESS_TYPE_PERCENTAGE)
-                           {
-                               if ( 100 < JSUtil::JSValueToULong(context, progressValue) )
-                                               throw InvalidValuesException("The percentage progress value must be between 0 and 100");
-                               priv->setProgressValue((double)JSUtil::JSValueToULong(context, progressValue)/(double)100);
-                           }
-                           else 
-                           {
-                               priv->setProgressValue((double)JSUtil::JSValueToULong(context, progressValue));
-                           }
-                               
-                    }
-                }
-                catch ( const BasePlatformException& err) 
-                {
-                    LogWarning("notification's icon path convertion is failed."  << err.getMessage().c_str());
-                }   
-    
-                //DetailInfo
-                try {  
-                    JSValueRef detailInfoValue  = JSUtil::getProperty(context, notiInitDict, STATUS_NOTIFICATION_DETAIL_INFO);
-    
-                    std::vector<NotificationDetailInfo*> detailInfos;
-                    if (JSIsArrayValue(context, detailInfoValue))
-                    {
-                        JSObjectRef arrayobj = JSUtil::JSValueToObject(context, detailInfoValue);
-                        for(std::size_t i = 0; i < JSGetArrayLength(context, arrayobj); ++i)
-                        {
-                            JSValueRef element = JSGetArrayElement(context, arrayobj, i);
-                           JSObjectRef object = JSUtil::JSValueToObject(context, element);
-                           if (object)
-                           {
-                               NotificationDetailInfo* item = static_cast<NotificationDetailInfo*>(JSObjectGetPrivate(object));
-                               std::string main = item->getMainText();
-                               std::string sub = item->getSubText();
-                               LogInfo("Main : " << main << " Sub : " << sub);
-               
-                               NotificationDetailInfo *detailinfo = new NotificationDetailInfo(NULL, (int)i, main, sub);
-                               detailInfos.push_back(detailinfo);      
-                           }
-                        }
-                    }
-                    priv->setDetailInfos(detailInfos);
-                }
-                catch ( const BasePlatformException& err) 
-                {
-                    LogWarning("notification's icon path convertion is failed."  << err.getMessage().c_str());
-                }
-        
-                //backgroundimage
-                try {             
-                    JSValueRef backgroundImageValue = JSUtil::getProperty(context, notiInitDict, STATUS_NOTIFICATION_BACKGROUND_IMAGE_PATH);
-                    if (!JSValueIsUndefined(context, backgroundImageValue))
-                    {
-                        DeviceAPI::Filesystem::IPathPtr path = DeviceAPI::Filesystem::Utils::fromVirtualPath(context, JSUtil::JSValueToString(context, backgroundImageValue));
-                        priv->setBackground(path->getFullPath());
-                    }
-                }
-                catch ( const BasePlatformException& err) 
+#if 0                  
+            JSValueRef progressTypeValue = JSUtil::getProperty(context, notiInitDict, STATUS_NOTIFICATION_PROGRESS_TYPE);
+           if (progressTypeValue)
+           {
+
+           }
+            if (!JSValueIsUndefined(context, progressTypeValue))
+            {      
+                   std::string strProgressType = JSUtil::JSValueToString(context, progressTypeValue);
+                   LogInfo("==Progress Type : " << strProgressType);   
+                   if( strProgressType.compare(TIZEN_NOTIFICATION_PROGRESS_TYPE_PERCENTAGE) == 0)
+                          progressType = NOTI_PROGRESS_TYPE_PERCENTAGE;
+                   else if( strProgressType.compare(TIZEN_NOTIFICATION_PROGRESS_TYPE_BYTE) == 0)
+                           progressType = NOTI_PROGRESS_TYPE_SIZE;
+                   else
+                           throw TypeMismatchException("Invalid Progress Type.");
+            }
+            priv->setProgressType(progressType);
+#endif                                         
+            //ProgressValue
+            JSValueRef progressValue    = JSUtil::getProperty(context, notiInitDict, STATUS_NOTIFICATION_PROGRESS_VALUE);         
+            if (!JSValueIsUndefined(context, progressValue))
+            {
+               if ( progressType == NOTI_PROGRESS_TYPE_PERCENTAGE)
+              {
+                   if ( 100 < JSUtil::JSValueToULong(context, progressValue) )
+                       throw TypeMismatchException("The percentage progress value must be between 0 and 100");
+                   priv->setProgressValue((double)JSUtil::JSValueToULong(context, progressValue)/(double)100);
+               }
+               else 
+              {
+                   priv->setProgressValue((double)JSUtil::JSValueToULong(context, progressValue));
+              }
+            }
+             
+            //DetailInfo
+            JSValueRef detailInfoValue  = JSUtil::getProperty(context, notiInitDict, STATUS_NOTIFICATION_DETAIL_INFO);
+
+            std::vector<NotificationDetailInfo*> detailInfos;
+            if (JSIsArrayValue(context, detailInfoValue))
+            {
+                JSObjectRef arrayobj = JSUtil::JSValueToObject(context, detailInfoValue);
+                for(std::size_t i = 0; i < JSGetArrayLength(context, arrayobj); ++i)
                 {
-                    LogWarning("notification's icon path convertion is failed."  << err.getMessage().c_str());
+                    JSValueRef element = JSGetArrayElement(context, arrayobj, i);
+                   JSObjectRef object = JSUtil::JSValueToObject(context, element);
+                   if (object)
+                   {
+                       NotificationDetailInfo* item = static_cast<NotificationDetailInfo*>(JSObjectGetPrivate(object));
+                       std::string main = item->getMainText();
+                       std::string sub = item->getSubText();
+                       LogInfo("Main : " << main << " Sub : " << sub);
+            
+                       NotificationDetailInfo *detailinfo = new NotificationDetailInfo(NULL, (int)i, main, sub);
+                       detailInfos.push_back(detailinfo);      
+                   }
                 }
+            }
+            priv->setDetailInfos(detailInfos);  
     
-                //number
-                try {             
-                    JSValueRef numberValue  = JSUtil::getProperty(context, notiInitDict, STATUS_NOTIFICATION_NUMBER);
-                    if (!JSValueIsUndefined(context, numberValue))
-                    {
-                        priv->setNumber(JSUtil::JSValueToLong(context, numberValue));
-                    }
-                }
-                catch ( const BasePlatformException& err) 
+            //backgroundimage
+            try {                 
+                JSValueRef backgroundImageValue = JSUtil::getProperty(context, notiInitDict, STATUS_NOTIFICATION_BACKGROUND_IMAGE_PATH);
+                if (!JSValueIsUndefined(context, backgroundImageValue))
                 {
-                    LogWarning("notification's icon path convertion is failed."  << err.getMessage().c_str());
-                } 
-
-                //thumbnail
-                try {             
-                    JSValueRef thumbnailsValue  = JSUtil::getProperty(context, notiInitDict, STATUS_NOTIFICATION_THUMBNAILS);
-                    if (!JSValueIsUndefined(context, thumbnailsValue))
-                    {
-                        priv->setThumbnails(JSUtil::JSArrayToStringVector(context, thumbnailsValue));
-                    }
+                    DeviceAPI::Filesystem::IPathPtr path = DeviceAPI::Filesystem::Utils::fromVirtualPath(context, JSUtil::JSValueToString(context, backgroundImageValue));
+                    priv->setBackground(path->getFullPath());
                 }
-                catch ( const BasePlatformException& err) 
+            }
+           catch(...)
+           {
+                throw TypeMismatchException("The backgound image path is invalid : ");
+           }
+       
+            //number
+            JSValueRef numberValue  = JSUtil::getProperty(context, notiInitDict, STATUS_NOTIFICATION_NUMBER);
+           if (!JSValueIsUndefined(context, numberValue))
+           {
+                 priv->setNumber(JSUtil::JSValueToLong(context, numberValue));
+           }
+           
+            //thumbnail
+            try {                 
+                JSValueRef thumbnailsValue  = JSUtil::getProperty(context, notiInitDict, STATUS_NOTIFICATION_THUMBNAILS);
+                if (!JSValueIsUndefined(context, thumbnailsValue))
                 {
-                    LogWarning("notification's icon path convertion is failed."  << err.getMessage().c_str());
-                }
-    
-                //subIconPath
-                try {             
-                    JSValueRef subIconPathValue = JSUtil::getProperty(context, notiInitDict, STATUS_NOTIFICATION_SUB_ICON_PATH);
-                    if (!JSValueIsUndefined(context, subIconPathValue))
-                    {
-                        DeviceAPI::Filesystem::IPathPtr path = DeviceAPI::Filesystem::Utils::fromVirtualPath(context, JSUtil::JSValueToString(context, subIconPathValue));
-                        priv->setSubIconPath( path->getFullPath());
-                    }
+
+                   std::vector<std::string> thumbnailPaths;
+                   if( JSIsArrayValue(context, thumbnailsValue)){
+                       JSObjectRef arrayobj = JSUtil::JSValueToObject(context, thumbnailsValue);        
+                       for (std::size_t i = 0; i < JSGetArrayLength(context, arrayobj); ++i) {
+                                JSValueRef element = JSGetArrayElement(context, arrayobj, i);
+                                        DeviceAPI::Filesystem::IPathPtr thumbnailPath = 
+                                                DeviceAPI::Filesystem::Utils::fromVirtualPath(context, JSUtil::JSValueToString(context, element));
+                                        LogInfo("thumbnail Path = " << thumbnailPath->getFullPath());
+                                        thumbnailPaths.push_back(thumbnailPath->getFullPath());
+                       }
+                   }           
+                   priv->setThumbnails(thumbnailPaths);                
                 }
-                catch ( const BasePlatformException& err) 
+            }
+            catch ( ... ) 
+            {
+                throw TypeMismatchException("thumbnail path convertion is failed.");
+            }
+
+            //subIconPath
+            try {                 
+                JSValueRef subIconPathValue = JSUtil::getProperty(context, notiInitDict, STATUS_NOTIFICATION_SUB_ICON_PATH);
+                if (!JSValueIsUndefined(context, subIconPathValue))
                 {
-                    LogWarning("notification's icon path convertion is failed."  << err.getMessage().c_str());
+                    DeviceAPI::Filesystem::IPathPtr path = DeviceAPI::Filesystem::Utils::fromVirtualPath(context, JSUtil::JSValueToString(context, subIconPathValue));
+                    priv->setSubIconPath( path->getFullPath());
                 }
-                        
             }
+            catch (...) 
+            {
+                throw TypeMismatchException("subIcon path convertion is failed.");
+            }
+                    
+        }
                
         setPrivateObject(context, obj, priv);
                
@@ -508,7 +498,7 @@ JSObjectRef JSStatusNotification::constructor(JSContextRef context,
         LogWarning(" notification convertion is failed. "   << err.getName().c_str() << ":"  << err.getMessage().c_str());
        JSObjectRef error = JSWebAPIError::makeJSWebAPIError(context, err);
        *exception = error;
-       return NULL;
+       return error;
     }
 
     return obj;      
@@ -676,6 +666,8 @@ void JSStatusNotification::setPrivateObject(JSContextRef context, JSObjectRef ob
     if (priv) {
         JSObjectSetPrivate(object, static_cast<void*>(priv));
     }
+    else
+       throw TypeMismatchException("StatusNotification object is invaild.");
 
     //type
     std::string typeVal(NOTIFICATION_TYPE_VALUE);
@@ -698,7 +690,6 @@ void JSStatusNotification::setPrivateObject(JSContextRef context, JSObjectRef ob
        
     JSUtil::setProperty(context, object, STATUS_NOTIFICATION_STATUS_TYPE,
             JSUtil::toJSValueRef(context, type), kJSPropertyAttributeReadOnly);
-
     //id
     if (priv->getID() >= 0)
     {
@@ -734,27 +725,42 @@ void JSStatusNotification::setPrivateObject(JSContextRef context, JSObjectRef ob
             JSUtil::toJSValueRef(context, priv->getTitle()), kJSPropertyAttributeNone);
 
     //content
-    JSUtil::setProperty(context, object, NOTIFICATION_CONTENT,
-            JSUtil::toJSValueRef(context, priv->getContent()), kJSPropertyAttributeNone);
+    if (priv->getStrContent())
+       JSUtil::setProperty(context, object, NOTIFICATION_CONTENT,
+                 JSUtil::toJSValueRef(context, priv->getContent()), kJSPropertyAttributeNone);
+    else
+       JSUtil::setProperty(context, object, NOTIFICATION_CONTENT, JSValueMakeNull(context), kJSPropertyAttributeNone);   
 
     //iconPath
-    JSUtil::setProperty(context, object, STATUS_NOTIFICATION_ICON_PATH,
-            JSUtil::toJSValueRef(context, DeviceAPI::Filesystem::Utils::toVirtualPath(context, priv->getIconPath())), kJSPropertyAttributeNone);
+    if (!priv->getIconPath().empty())
+        JSUtil::setProperty(context, object, STATUS_NOTIFICATION_ICON_PATH,
+                JSUtil::toJSValueRef(context, DeviceAPI::Filesystem::Utils::toVirtualPath(context, priv->getIconPath())), kJSPropertyAttributeNone);
+    else
+        JSUtil::setProperty(context, object, STATUS_NOTIFICATION_ICON_PATH, JSValueMakeNull(context), kJSPropertyAttributeNone);
 
     //subIconPath
-    JSUtil::setProperty(context, object, STATUS_NOTIFICATION_SUB_ICON_PATH,
-            JSUtil::toJSValueRef(context, DeviceAPI::Filesystem::Utils::toVirtualPath(context, priv->getSubIconPath())), kJSPropertyAttributeNone);
+    if ( !priv->getSubIconPath().empty())
+        JSUtil::setProperty(context, object, STATUS_NOTIFICATION_SUB_ICON_PATH,
+               JSUtil::toJSValueRef(context, DeviceAPI::Filesystem::Utils::toVirtualPath(context, priv->getSubIconPath())), kJSPropertyAttributeNone);
+    else 
+        JSUtil::setProperty(context, object, STATUS_NOTIFICATION_SUB_ICON_PATH,  JSValueMakeNull(context), kJSPropertyAttributeNone);
 
     //number
-    JSUtil::setProperty(context, object, STATUS_NOTIFICATION_NUMBER,
-            JSUtil::toJSValueRef(context, (unsigned long)priv->getNumber()), kJSPropertyAttributeNone);
+    if (priv->getStrNumber()){
+       JSUtil::setProperty(context, object, STATUS_NOTIFICATION_NUMBER,
+            JSUtil::toJSValueRef(context, priv->getNumber()), kJSPropertyAttributeNone);       
+    }
+    else
+       JSUtil::setProperty(context, object, STATUS_NOTIFICATION_NUMBER, JSValueMakeNull(context), kJSPropertyAttributeNone);                   
 
      // backgroundImagePath
-    JSUtil::setProperty(context, object, STATUS_NOTIFICATION_BACKGROUND_IMAGE_PATH,
+    if ( !priv->getBackground().empty()) 
+        JSUtil::setProperty(context, object, STATUS_NOTIFICATION_BACKGROUND_IMAGE_PATH,
             JSUtil::toJSValueRef(context, DeviceAPI::Filesystem::Utils::toVirtualPath(context, priv->getBackground())), kJSPropertyAttributeNone);
-
+    else
+       JSUtil::setProperty(context, object, STATUS_NOTIFICATION_BACKGROUND_IMAGE_PATH, JSValueMakeNull(context), kJSPropertyAttributeNone);
+       
     // thumbnails
-
     std::vector<std::string> thumbnails = priv->getThumbnails();
     LogInfo("Thumbnail Size : " << thumbnails.size());
      JSValueRef tumbnailvalueArray[thumbnails.size()];
@@ -776,16 +782,22 @@ void JSStatusNotification::setPrivateObject(JSContextRef context, JSObjectRef ob
            jsThumbnails, kJSPropertyAttributeNone);
 
     // soundPath
-    JSUtil::setProperty(context, object, STATUS_NOTIFICATION_SOUND_PATH,
+    if ( !priv->getSoundPath().empty() )
+        JSUtil::setProperty(context, object, STATUS_NOTIFICATION_SOUND_PATH,
             JSUtil::toJSValueRef(context, DeviceAPI::Filesystem::Utils::toVirtualPath(context, priv->getSoundPath())), kJSPropertyAttributeNone);
+    else
+       JSUtil::setProperty(context, object, STATUS_NOTIFICATION_SOUND_PATH, JSValueMakeNull(context), kJSPropertyAttributeNone);
 
     // vibration
     JSUtil::setProperty(context, object, STATUS_NOTIFICATION_VIBRATION,
             JSUtil::toJSValueRef(context, priv->getDefaultVibration()), kJSPropertyAttributeNone);
 
     // appId
-    JSUtil::setProperty(context, object, STATUS_NOTIFICATION_APP_ID,
-            JSUtil::toJSValueRef(context, priv->getApplicationId()), kJSPropertyAttributeNone);            
+    if (!priv->getApplicationId().empty())
+        JSUtil::setProperty(context, object, STATUS_NOTIFICATION_APP_ID,
+            JSUtil::toJSValueRef(context, priv->getApplicationId()), kJSPropertyAttributeNone);
+    else
+       JSUtil::setProperty(context, object, STATUS_NOTIFICATION_APP_ID, JSValueMakeNull(context), kJSPropertyAttributeNone);
 
 #if 0
     // progressType   & Value
@@ -837,12 +849,14 @@ void JSStatusNotification::setPrivateObject(JSContextRef context, JSObjectRef ob
            jsResult, kJSPropertyAttributeNone);
 
     // appControl
-    DeviceAPI::Application::JSApplicationControlPriv *appCtrlPriv = new DeviceAPI::Application::JSApplicationControlPriv(context, priv->getApplicationControl());
-    if (appCtrlPriv)
-    {
+    if (  !(priv->getApplicationControl())->getOperation().empty())
+    {  
+           DeviceAPI::Application::JSApplicationControlPriv *appCtrlPriv = new DeviceAPI::Application::JSApplicationControlPriv(context, priv->getApplicationControl());
            JSObjectRef jsAppCtrl = JSObjectMake(context, DeviceAPI::Application::JSApplicationControl::getClassRef(), appCtrlPriv);
            JSUtil::setProperty(context, object, STATUS_NOTIFICATION_APP_CONTROL,  jsAppCtrl, kJSPropertyAttributeNone);
     }
+    else
+          JSUtil::setProperty(context, object, STATUS_NOTIFICATION_APP_CONTROL,   JSValueMakeNull(context), kJSPropertyAttributeNone);
   
 }
 
index 870633d..1087157 100755 (executable)
@@ -510,6 +510,26 @@ std::string StatusNotification::getContent()
        
 }
 
+char* StatusNotification::getStrContent()
+{
+       LogInfo("get Content handle: " << m_notiHandle);
+       if (m_notiHandle)
+       {
+               char *content = NULL;
+
+               if (notification_get_text(m_notiHandle, NOTIFICATION_TEXT_TYPE_CONTENT, &content) != NOTIFICATION_ERROR_NONE)
+               {
+                       throw UnknownException("get notification Content error");
+               }
+               
+               return content;
+       }
+       else
+       {
+               throw UnknownException("notification handle is null");
+       }
+}
+
 void StatusNotification::setContent(std::string content)
 {
        LogInfo("Content : " << content);
@@ -934,7 +954,7 @@ void StatusNotification::setApplicationId(const std::string& appId)
                if (service_create(&m_service) != SERVICE_ERROR_NONE)
                {
                        LogWarning("Create Service Failed..");
-                       throw DeviceAPI::Common::UnknownException ("service creation error");
+                       throw UnknownException("service creation error");
                }
        }
 
@@ -945,7 +965,7 @@ void StatusNotification::setApplicationId(const std::string& appId)
                        m_launchFlag = true;
                        if (service_set_app_id(m_service, appId.c_str())!= SERVICE_ERROR_NONE)
                        {
-                               throw DeviceAPI::Common::UnknownException ("service set appId error");  
+                               throw UnknownException("service set appId error");      
                        }
                }
        }
@@ -973,13 +993,13 @@ std::string StatusNotification::getApplicationId()
                        {
                                LogWarning("UI_NOTIFICATION_ERROR_INVALID_PARAMETER");
                        }
-                       throw DeviceAPI::Common::UnknownException ("get notification service error ");
+                       throw UnknownException ("get notification service error ");
                }
                else
                {
                        if (service == NULL)
                        {
-                               throw DeviceAPI::Common::UnknownException ("get notification service ok, but service null");                    
+                               throw UnknownException ("get notification service ok, but service null");                       
                        }
                }
        }
@@ -988,7 +1008,7 @@ std::string StatusNotification::getApplicationId()
        {
                if (service_get_app_id(service, &appIdStr) != SERVICE_ERROR_NONE)
                {
-                       throw DeviceAPI::Common::UnknownException ("get a appId error");
+                       throw UnknownException ("get a appId error");
                }
 
                if (appIdStr != NULL)
@@ -1552,12 +1572,12 @@ void StatusNotification::setBackground(const std::string imagePath)
        }
 }
 
-unsigned int StatusNotification::getNumber()
+long StatusNotification::getNumber()
 {
        LogInfo("Handle = " << m_notiHandle);
        if (m_notiHandle)
        {
-               int number = 0;
+               long number = 0;
                char *strNumber = NULL;
 
                if (notification_get_text(m_notiHandle, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, &strNumber) != NOTIFICATION_ERROR_NONE)
@@ -1567,11 +1587,11 @@ unsigned int StatusNotification::getNumber()
 
                if (strNumber)
                        std::istringstream(strNumber) >> number;
+               else
+                       LogInfo("Number Is NULL");
 
                LogInfo("number = " << number);
 
-               if (number < 0 )
-                       number = 0;
                return number;
        }
        else
@@ -1581,7 +1601,33 @@ unsigned int StatusNotification::getNumber()
        }
 }
 
-void StatusNotification::setNumber(const unsigned int number)
+const char* StatusNotification::getStrNumber()
+{
+       LogInfo("Handle = " << m_notiHandle);
+       if (m_notiHandle)
+       {
+               char *strNumber = NULL;
+
+               if (notification_get_text(m_notiHandle, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, &strNumber) != NOTIFICATION_ERROR_NONE)
+               {
+                       throw UnknownException( "get notification background error");
+               }
+
+               if (!strNumber)
+               {
+                       return NULL;
+               }
+
+               return strNumber;
+       }
+       else
+       {
+               LogDebug("noti Handle is NULL");
+               return NULL;
+       }
+}
+
+void StatusNotification::setNumber(const long number)
 {
        LogInfo("Number = " << number);
        if (m_notiHandle)
@@ -1592,14 +1638,14 @@ void StatusNotification::setNumber(const unsigned int number)
                        stream << number;
                        if (stream.fail()) {
                                throw UnknownException(
-                                                "Couldn't convert e-mail account id");
+                                                "Couldn't convert notification number");
                        }
                        
                        std::string strNumber = stream.str();           
                        if (notification_set_text(m_notiHandle, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, strNumber.c_str(),
                                NULL, NOTIFICATION_VARIABLE_TYPE_NONE) != NOTIFICATION_ERROR_NONE)
                        {
-                               throw UnknownException( "set notification sound error");
+                               throw UnknownException( "set notification text error");
                        }
                        setUpdatedFlag(true);
                }
index 17c5096..8fdb131 100755 (executable)
@@ -92,7 +92,9 @@ public:
        time_t getPostedTime();
        std::string getTitle();
        void setTitle(std::string title);
+       
        std::string getContent();
+       char* getStrContent();
        void setContent(std::string content);
                
        std::string getIconPath() ;     
@@ -128,9 +130,9 @@ public:
        std::string getBackground() ;
        void setBackground(const std::string imagePath) ;
        
-       unsigned int getNumber() ;
-       void setNumber(const unsigned int number) ;
-
+       long getNumber() ;
+       const char* getStrNumber() ;
+       void setNumber(const long number) ;
        
        //void setStatusType(NotificationType type);
        DeviceAPI::Application::ApplicationControlPtr getApplicationControl();
@@ -176,67 +178,6 @@ protected:
        
        std::vector<std::string> m_thumbs;                              //thumbnail images path
        std::vector<NotificationDetailInfo*> m_detailInfos;   // detail Info
-
-#if 0
-public:
-    StatusNotification();
-    virtual ~StatusNotification();
-
-    std::string getStatusType() const;
-    void setStatusType(std::string statusType);
-
-    std::string getIconPath() const;
-    void setIconPath(std::string iconPath);
-
-    std::string getSubIconPath() const;
-    void setSubIconPath(std::string subIconPath);
-
-    long getNumber() const;
-    void setNumber(long number);
-
-    std::vector<NotificationDetailInfo*> getDetailInfo() const;
-    void setDetailInfo(std::vector<NotificationDetailInfo*> detailInfo);
-
-    std::string getBackgroundImagePath() const;
-    void setBackgroundImagePath(std::string backgroundImagePath);
-
-    std::vector<std::string> getThumbnails() const;
-    void setThumbnails(std::vector<std::string> thumbnails);
-
-    std::string getSoundPath() const;
-    void setSoundPath(std::string soundPath);
-
-    bool getVibration() const;
-    void setVibration(bool vibration);
-
-    ApplicationControl getAppControl() const;
-    void setAppControl(ApplicationControl appControl);
-
-    ApplicationId getAppId() const;
-    void setAppId(ApplicationId appId);
-
-    std::string getProgressType() const;
-    void setProgressType(std::string progressType);
-
-    unsigned long getProgressValue() const;
-    void setProgressValue(unsigned long progressValue);
-
-private:
-    std::string m_statusType;
-    std::string m_iconPath;
-    std::string m_subIconPath;
-    long m_number;
-    std::vector<NotificationDetailInfo*> m_detailInfo;
-    std::string m_backgroundImagePath;
-    std::vector<std::string> m_thumbnails;
-    std::string m_soundPath;
-    bool m_vibration;
-    ApplicationControl m_appControl;
-    ApplicationId m_appId;
-    std::string m_progressType;
-    unsigned long m_progressValue;
-
-#endif
        
 };
 
index 347e347..cd31cab 100644 (file)
@@ -125,7 +125,7 @@ JSValueRef JSPackageManager::install(JSContextRef context,
                
                string path = validator.toString(0);
 
-               JSObjectRef eventCBObj = validator.toCallbackObject(1, true, "onprogress", "oncomplete", NULL);
+               JSObjectRef eventCBObj = validator.toCallbackObject(1, false, "onprogress", "oncomplete", NULL);
                JSObjectRef errCB = validator.toFunction(2, true);
 
                CallbackUserData *onprogressCb = NULL;
@@ -182,7 +182,7 @@ JSValueRef JSPackageManager::uninstall(JSContextRef context,
                
                string id = validator.toString(0);
                //JSObjectRef eventCBObj = validator.toObject(1, true);
-               JSObjectRef eventCBObj = validator.toCallbackObject(1, true, "onprogress", "oncomplete", NULL);
+               JSObjectRef eventCBObj = validator.toCallbackObject(1, false, "onprogress", "oncomplete", NULL);
                JSObjectRef errCB = validator.toFunction(2, true);
 
                CallbackUserData *onprogressCb = NULL;
index b3acbde..556c460 100644 (file)
@@ -522,15 +522,16 @@ void install_request_cb(int id, const char *type, const char *package,
 
        switch (event_state) {
        case PACAKGE_MANAGER_EVENT_STATE_COMPLETED: {
-               LogDebug("destroy client handle");
                if (callback->getOnComplete()) {
                        Converter converter(context);
                        callback->getOnComplete()->callSuccessCallback(converter.toJSValueRef(package));
                }
 
+               LogDebug("destroy client handle");
                // this api is not supported from platform.
                //package_manager_request_destroy(callback->getHandle());
                package_manager_client_destroy(callback->getHandle());
+               callback->setHandle(NULL);
 
                //clean-up callback object
                delete callback;
@@ -553,6 +554,7 @@ void install_request_cb(int id, const char *type, const char *package,
                // this api is not supported from platform.
                //package_manager_request_destroy(callback->getHandle());
                package_manager_client_destroy(callback->getHandle());
+               callback->setHandle(NULL);
 
                //clean-up callback object
                delete callback;
@@ -577,6 +579,7 @@ void install_request_cb(int id, const char *type, const char *package,
                // this api is not supported from platform.
                //package_manager_request_destroy(callback->getHandle());
                package_manager_client_destroy(callback->getHandle());
+               callback->setHandle(NULL);
 
                //clean-up callback object
                delete callback;
index 0173fa8..b12f74f 100755 (executable)
@@ -25,6 +25,7 @@
 #include <PlatformException.h>
 #include <Logger.h>
 #include <JSUtil.h>
+#include <vconf.h>
 
 using namespace DeviceAPI::Common;
 using namespace std;
@@ -32,7 +33,6 @@ using namespace std;
 namespace DeviceAPI {
 namespace Power {
 
-
 PowerResource::PowerResource(const char *resource)
 {
     if( strcmp(resource,"SCREEN") == 0 )
@@ -129,11 +129,7 @@ void PowerManager::request(PowerResource resource, PowerState state){
                 throw UnknownException("Platform error while getting max brightness");
             }
 
-            ret = device_set_brightness(0, maxBrightness);
-            if( DEVICE_ERROR_NONE!=ret){
-                LOGE("Platform error while setting %d brightness: %d", maxBrightness, ret);
-                throw UnknownException("Platform error while setting max brightness");
-            }
+            setPlatformBrightness( maxBrightness );
 
             LOGI("Succeeded setting the brightness to a max level: %d", maxBrightness);
             ret = power_lock_state(POWER_STATE_NORMAL, 0);
@@ -168,10 +164,12 @@ void PowerManager::release(PowerResource resource){
         if( POWER_ERROR_NONE!=ret )
             LOGI("Platform return value from dim unlock: %d", ret);
 
-        ret = device_set_brightness_from_settings(0);
-        if( DEVICE_ERROR_NONE!=ret){
-            LOGE("Platform error while setting restore brightness %d", ret);
-            throw UnknownException("Platform error while setting restore brightness");
+        if( mBrightStateEnable ){
+            ret = device_set_brightness_from_settings(0);
+            if( DEVICE_ERROR_NONE!=ret){
+                LOGE("Platform error while setting restore brightness %d", ret);
+                throw UnknownException("Platform error while setting restore brightness");
+            }
         }
 
         mBrightStateEnable = false;
@@ -187,12 +185,8 @@ void PowerManager::release(PowerResource resource){
 }
 
 double PowerManager::getScreenBrightness(){
-    int ret, brightness;
-    ret = device_get_brightness(0, &brightness);
-    if( DEVICE_ERROR_NONE!=ret ){
-        LOGE("Platform error while get brightness %d", ret);
-        throw UnknownException("Platform error while get brightness");
-    }
+    int brightness;
+    brightness = getPlatformBrightness();
     LOGI("Brightness value: %d", brightness);
     return brightness/100.0;
 }
@@ -208,11 +202,8 @@ void PowerManager::setScreenBrightness(double brightness){
         throw UnknownException("Platform error while getting max brightness");
     }
     int nativeBrightness = (int)(brightness*maxBrightness);
-    ret = device_set_brightness(0, nativeBrightness);
-    if( DEVICE_ERROR_NONE!=ret ){
-        LOGE("Platform error while setting %d brightness : %d",nativeBrightness, ret);
-        throw UnknownException("Platform error while setting brightness.");
-    }
+
+    setPlatformBrightness(nativeBrightness);
     LOGI("Set the brightness value: %d", nativeBrightness);
 }
 
@@ -262,28 +253,98 @@ void PowerManager::removeScreenStateChangedCallback(Common::CallbackUserData * c
     mListener.remove(callback);
 }
 
+void PowerManager::setPlatformBrightness(int brightness){
+
+
+    if( mCurrentState.mState == PowerState::SCREENDIM ){
+        mCurrentBrightness = brightness;
+        LOGI("Current state is not normal state the value is saved in cache: %d", brightness);
+        mShouldBeReadFromCache = true;
+        return;
+    }else
+        mShouldBeReadFromCache = false;
+
+    int ret = device_set_brightness(0, brightness);
+    if( ret != 0){
+        LOGE("Platform error while setting %d brightness: %d", brightness, ret);
+        throw UnknownException("Platform error while setting brightness.");
+    }
+    mCurrentBrightness = brightness;
+}
+
+int PowerManager::getPlatformBrightness(){
+    int brightness = 0;
+    int ret = 0;
+
+    int isCustomMode = 0;
+    vconf_get_int(VCONFKEY_PM_CUSTOM_BRIGHTNESS_STATUS, &isCustomMode);
+    if( (isCustomMode && mCurrentBrightness != -1) || mShouldBeReadFromCache ){
+        LOGI("return custom brightness %d", mCurrentBrightness);
+        return mCurrentBrightness;
+    }
+
+    ret = vconf_get_int(VCONFKEY_SETAPPL_LCD_BRIGHTNESS, &brightness);
+    if( ret != 0 ){
+        LOGE("Platform error while getting brightness: %d", ret);
+        throw UnknownException("Platform error while getting brightness");
+    }
+    LOGE("VCONFKEY_SETAPPL_LCD_BRIGHTNESS %d", brightness);
+
+    return brightness;
+}
+
+
+void PowerManager::restoreSettedBrightness(){
+    int isCustomMode = 0;
+    vconf_get_int(VCONFKEY_PM_CUSTOM_BRIGHTNESS_STATUS, &isCustomMode);
+    if( isCustomMode || mShouldBeReadFromCache ){
+        if( mCurrentBrightness == -1 ){
+            // brightness was changed in other process
+            restoreScreenBrightness();
+        }else{
+            setPlatformBrightness(mCurrentBrightness);
+        }
+    }
+    mShouldBeReadFromCache = false;
+}
+
 void PowerManager::broadcastScreenState(PowerState current){
     if( mCurrentState == current)
         return;
 
+    PowerState PreviousState = mCurrentState;
+    mCurrentState = current;
+
+    if( mCurrentState.mState == PowerState::SCREENNORMAL && PreviousState.mState == PowerState::SCREENDIM ){
+        //restore ScreenBrightness
+        try{
+            restoreSettedBrightness();
+        }
+        catch( const BasePlatformException& err){
+            LOGE("Error restore custom brightness %s", err.getMessage().c_str());
+        }
+    }
+    if( mCurrentState.mState == PowerState::SCREENNORMAL && PreviousState.mState == PowerState::SCREENOFF){
+        mShouldBeReadFromCache = false;
+    }
+
     list<CallbackUserData*> tmplist(mListener);
     list<CallbackUserData*>::iterator itr = tmplist.begin();
 
     while( itr != tmplist.end() ){
         CallbackUserData *callback = *itr;
         if( callback != NULL ){
-            JSValueRef previousState = JSUtil::toJSValueRef(callback->getContext(), mCurrentState.toString());
-            JSValueRef currentState = JSUtil::toJSValueRef(callback->getContext(), current.toString());
+            JSValueRef previousState = JSUtil::toJSValueRef(callback->getContext(), PreviousState.toString());
+            JSValueRef currentState = JSUtil::toJSValueRef(callback->getContext(), mCurrentState.toString());
             JSValueRef args[2] = { previousState, currentState };
             callback->callSuccessCallback(2, args);
         }
         ++itr;
     }
-    mCurrentState = current;
 }
 
 
-PowerManager::PowerManager():mCurrentState(PowerState::SCREENNORMAL),mBrightStateEnable(false){
+PowerManager::PowerManager():mCurrentState(PowerState::SCREENNORMAL),mBrightStateEnable(false),mCurrentBrightness(-1),mShouldBeReadFromCache(false){
     power_state_e platform_state = power_get_state();
     switch( platform_state ){
         case POWER_STATE_NORMAL :
index 82709c3..e5f6153 100755 (executable)
@@ -64,6 +64,9 @@ public:
 
     static PowerManager* getInstance();
 private:
+    int getPlatformBrightness();
+    void setPlatformBrightness(int i);
+    void restoreSettedBrightness();
     static void onPlatformStateChangedCB(power_state_e state, void *user_data);
     PowerManager();
     virtual ~PowerManager();
@@ -71,6 +74,8 @@ private:
     std::list<Common::CallbackUserData*> mListener;
     PowerState mCurrentState;
     bool mBrightStateEnable;
+    int mCurrentBrightness;
+    bool mShouldBeReadFromCache;
 
 };
 
index b68bf9a..ba02ef4 100755 (executable)
@@ -62,8 +62,8 @@ JSClassDefinition JSTZDate::m_classInfo =
     NULL, //DeleteProperty,
     NULL, //GetPropertyNames,
     NULL, //CallAsFunction,
-    constructor, //CallAsConstructor,
-    hasInstance, //HasInstance,
+    NULL, //CallAsConstructor,
+    NULL, //HasInstance,
     NULL  //ConvertToType
 };
 
@@ -206,15 +206,6 @@ JSObjectRef JSTZDate::createJSObject(JSContextRef context, const long year, cons
 void JSTZDate::initialize(JSContextRef context, JSObjectRef object)
 {
        LogDebug("entered Nothing to do.");
-
-       if (!JSObjectGetPrivate(object)) {
-               LogDebug("Private object not set... setting it.");
-               TZDatePtr tzDate(new TZDate(FALSE));
-               TZDatePrivObject *priv = new TZDatePrivObject(context, tzDate);
-               if (!JSObjectSetPrivate(object, priv)) {
-                       delete priv;
-               }
-       }
 }
 
 void JSTZDate::finalize(JSObjectRef object)
@@ -232,40 +223,43 @@ JSObjectRef JSTZDate::constructor(JSContextRef ctx, JSObjectRef constructor, siz
        TimeUtilConverter converter(ctx);
 
        Try {
+               JSObjectRef tzDate = NULL;
+
                if (argumentCount == 0) {
-                       return createJSObject(ctx);
+                       tzDate = createJSObject(ctx);
                } else if (argumentCount <= 2) {
                        std::string timezone = "";
                        if ((argumentCount == 2) && !JSValueIsNull(ctx, arguments[1]) && !JSValueIsUndefined(ctx, arguments[1])) {
                                timezone = converter.toString(arguments[1]);
                        }
 
-                       if (JSValueIsNull(ctx, arguments[0]) || JSValueIsUndefined(ctx, arguments[0]))
-                               return createJSObject(ctx, timezone);
-
-                       struct tm date = converter.toDateTm(arguments[0]);
-                       LogDebug("date = " << date.tm_year << "." << date.tm_mon << "." << date.tm_mday);
-                       LogDebug(date.tm_hour << ":" << date.tm_min << ":" << date.tm_sec);
-                       LogDebug("isdst?" << date.tm_isdst);
-
-                       prop.timezone = timezone;
-                       prop.year = date.tm_year + 1900;
-                       prop.month = date.tm_mon;
-                       prop.day = date.tm_mday;
-                       prop.hours = date.tm_hour;
-                       prop.minutes = date.tm_min;
-                       prop.seconds = date.tm_sec;
-
-                      JSStringRef getMillisecondsName = JSStringCreateWithUTF8CString("getMilliseconds");
-                       JSValueRef getMiliSecFuction = JSObjectGetProperty(ctx, converter.toJSObjectRef(arguments[0]), getMillisecondsName, exception);
-                       JSStringRelease(getMillisecondsName);
-                       if (getMiliSecFuction) {
-                               JSObjectRef function = JSValueToObject(ctx, getMiliSecFuction, exception);
-                               JSValueRef result = JSObjectCallAsFunction(ctx, function, converter.toJSObjectRef(arguments[0]), 0, NULL, exception);
-                               prop.milliseconds = converter.toLong(result);
-                               LogDebug("getMilliseconds = " << prop.milliseconds);
+                       if (JSValueIsNull(ctx, arguments[0]) || JSValueIsUndefined(ctx, arguments[0])) {
+                               tzDate = createJSObject(ctx, timezone);
+                       } else {
+                               struct tm date = converter.toDateTm(arguments[0]);
+                               LogDebug("date = " << date.tm_year << "." << date.tm_mon << "." << date.tm_mday);
+                               LogDebug(date.tm_hour << ":" << date.tm_min << ":" << date.tm_sec);
+                               LogDebug("isdst?" << date.tm_isdst);
+
+                               prop.timezone = timezone;
+                               prop.year = date.tm_year + 1900;
+                               prop.month = date.tm_mon;
+                               prop.day = date.tm_mday;
+                               prop.hours = date.tm_hour;
+                               prop.minutes = date.tm_min;
+                               prop.seconds = date.tm_sec;
+
+                           JSStringRef getMillisecondsName = JSStringCreateWithUTF8CString("getMilliseconds");
+                               JSValueRef getMiliSecFuction = JSObjectGetProperty(ctx, converter.toJSObjectRef(arguments[0]), getMillisecondsName, exception);
+                               JSStringRelease(getMillisecondsName);
+                               if (getMiliSecFuction) {
+                                       JSObjectRef function = JSValueToObject(ctx, getMiliSecFuction, exception);
+                                       JSValueRef result = JSObjectCallAsFunction(ctx, function, converter.toJSObjectRef(arguments[0]), 0, NULL, exception);
+                                       prop.milliseconds = converter.toLong(result);
+                                       LogDebug("getMilliseconds = " << prop.milliseconds);
+                               }
+                               tzDate = createJSObject(ctx, prop);
                        }
-                       return createJSObject(ctx, prop);
                } else {
                        prop.year = converter.toLong(arguments[0]);
                        if ((prop.year >= 0) && (prop.year <= 99))
@@ -292,23 +286,34 @@ JSObjectRef JSTZDate::constructor(JSContextRef ctx, JSObjectRef constructor, siz
                                        }
                                }
                        }
-                       return createJSObject(ctx, prop);
+                       tzDate = createJSObject(ctx, prop);
+               }
+
+               if (tzDate) {
+                       JSStringRef ctorName = JSStringCreateWithUTF8CString("constructor");
+                   JSObjectSetProperty(ctx, tzDate, ctorName, constructor,
+                       kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete | kJSPropertyAttributeDontEnum, NULL);
+               JSStringRelease(ctorName);
+                       return tzDate;
                }
        } Catch(ConversionException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
-               *exception = JSTizenExceptionFactory::makeErrorObject(ctx, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
-               return NULL;
+               JSObjectRef error = JSTizenExceptionFactory::makeErrorObject(ctx, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
+               *exception = error;
+               return error;
        } Catch (InvalidArgumentException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
-               *exception = JSTizenExceptionFactory::makeErrorObject(ctx, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
-               return NULL;
+               JSObjectRef error = JSTizenExceptionFactory::makeErrorObject(ctx, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
+               *exception = error;
+               return error;
        } Catch (PlatformException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
        } Catch (WrtDeviceApis::Commons::Exception) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
        }
-       *exception = JSTizenExceptionFactory::makeErrorObject(ctx, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
-       return NULL;
+       JSObjectRef error = JSTizenExceptionFactory::makeErrorObject(ctx, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
+       *exception = error;
+       return error;
 }
 const JSClassRef JSTZDate::getClassRef()
 {
@@ -323,14 +328,6 @@ const JSClassDefinition* JSTZDate::getClassInfo()
     return &m_classInfo;
 }
 
-bool JSTZDate::hasInstance(JSContextRef context,
-        JSObjectRef constructor,
-        JSValueRef possibleInstance,
-        JSValueRef* exception)
-{
-    return JSValueIsObjectOfClass(context, possibleInstance, getClassRef());
-}
-
 JSValueRef JSTZDate::getTimezone(JSContextRef context, JSObjectRef function,
        JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
        LogDebug("entered");
index 8794559..dbdcc97 100755 (executable)
@@ -42,6 +42,10 @@ public:
     static JSObjectRef createJSObject(JSContextRef context, const double milliseconds, const std::string &timezone);
     static JSObjectRef createJSObject(JSContextRef context, const TZDateProperties &properties);
     static JSObjectRef createJSObject(JSContextRef context, const long year, const long month,  const long day, const long hours, const long minutes, const long seconds, const long milliseconds, const std::string &timezone);       
+
+
+    static JSObjectRef constructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
+
 private:
        enum CompareType {
                DIFFERENCE,
@@ -78,16 +82,6 @@ private:
      */
     static void finalize(JSObjectRef object);
 
-    static JSObjectRef constructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
-
-    /**
-     * The callback invoked when an object is used as the target of an 'instanceof' expression.
-     */
-    static bool hasInstance(JSContextRef context,
-            JSObjectRef constructor,
-            JSValueRef possibleInstance,
-            JSValueRef* exception);
-
     static JSValueRef getTimezone(JSContextRef context, JSObjectRef function, 
             JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
     static JSValueRef toTimezone(JSContextRef context, JSObjectRef function, 
index 310b15a..ac3db79 100755 (executable)
@@ -55,8 +55,8 @@ JSClassDefinition JSTimeDuration::m_classInfo = {
     NULL, //DeleteProperty,
     NULL, //GetPropertyNames,
     NULL, //CallAsFunction,
-    constructor, //CallAsConstructor,
-    hasInstance,
+    NULL, //CallAsConstructor,
+    NULL,
     NULL, //ConvertToType
 };
 
@@ -94,17 +94,6 @@ JSClassRef JSTimeDuration::m_jsClassRef = JSClassCreate(JSTimeDuration::getClass
 void JSTimeDuration::initialize(JSContextRef context, JSObjectRef object)
 {
        LogDebug("entered Nothing to do.");
-
-       if (!JSObjectGetPrivate(object)) {
-               LogDebug("Private object not set... setting it.");
-               DurationProperties durations;
-               DurationPropertiesPtr durationProps(new DurationProperties(durations));
-               TimeDurationPrivObject *priv = new TimeDurationPrivObject(context, durationProps);
-
-               if (!JSObjectSetPrivate(object, priv)) {
-                       delete priv;
-               }
-       }
 }
 
 void JSTimeDuration::finalize(JSObjectRef object)
@@ -214,36 +203,41 @@ JSObjectRef JSTimeDuration::constructor(JSContextRef ctx, JSObjectRef constructo
                                        ThrowMsg(ConversionException, "Argument(unit) is invalid(wrong type unit)");
                        }
                }
-               return createJSObject(ctx, duration);
+               JSObjectRef timeDuration = createJSObject(ctx, duration);
+               if (timeDuration) {
+                       JSStringRef ctorName = JSStringCreateWithUTF8CString("constructor");
+                   JSObjectSetProperty(ctx, timeDuration, ctorName, constructor,
+                       kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete | kJSPropertyAttributeDontEnum, NULL);
+               JSStringRelease(ctorName);
+                       return timeDuration;
+               }
        } Catch(NullPointerException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
-               *exception = JSTizenExceptionFactory::makeErrorObject(ctx, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
-               return NULL;
+               JSObjectRef error = JSTizenExceptionFactory::makeErrorObject(ctx, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
+               *exception = error;
+               return error;
        } Catch(UnknownException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
-               *exception = JSTizenExceptionFactory::makeErrorObject(ctx, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
-               return NULL;
+               JSObjectRef error = JSTizenExceptionFactory::makeErrorObject(ctx, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
+               *exception = error;
+               return error;
        } Catch(ConversionException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
-               *exception = JSTizenExceptionFactory::makeErrorObject(ctx, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
-               return NULL;
+               JSObjectRef error = JSTizenExceptionFactory::makeErrorObject(ctx, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
+               *exception = error;
+               return error;
        } Catch (InvalidArgumentException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
-               *exception = JSTizenExceptionFactory::makeErrorObject(ctx, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
-               return NULL;
+               JSObjectRef error = JSTizenExceptionFactory::makeErrorObject(ctx, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
+               *exception = error;
+               return error;
        } Catch (WrtDeviceApis::Commons::Exception) {
            LogWarning("Trying to get incorrect value");
        }
-       *exception = JSTizenExceptionFactory::makeErrorObject(ctx, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
-       return NULL;
-}
+       JSObjectRef error = JSTizenExceptionFactory::makeErrorObject(ctx, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
+       *exception = error;
+       return error;
 
-bool JSTimeDuration::hasInstance(JSContextRef context,
-        JSObjectRef constructor,
-        JSValueRef possibleInstance,
-        JSValueRef* exception)
-{
-    return JSValueIsObjectOfClass(context, possibleInstance, getClassRef());
 }
 
 JSValueRef JSTimeDuration::diffTimeDuration(JSContextRef context, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception, CompareType type) {
index 0fce198..fbddf33 100755 (executable)
@@ -52,6 +52,8 @@ class JSTimeDuration
      */
     static const JSClassRef getClassRef();
     static JSObjectRef createJSObject(JSContextRef context, const DurationProperties &durations);
+
+    static JSObjectRef constructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
   private:
        enum CompareType {
                DIFFERENCE,
@@ -79,16 +81,6 @@ class JSTimeDuration
     static bool setProperty(JSContextRef context, JSObjectRef object,
             JSStringRef propertyName,  JSValueRef value,  JSValueRef* exception);
 
-    static JSObjectRef constructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
-
-    /**
-     * The callback invoked when an object is used as the target of an 'instanceof' expression.
-     */
-    static bool hasInstance(JSContextRef context,
-            JSObjectRef constructor,
-            JSValueRef possibleInstance,
-            JSValueRef* exception);
-
     static JSValueRef diffTimeDuration(JSContextRef context, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception, CompareType type);
     static JSValueRef difference(JSContextRef context, JSObjectRef function, 
        JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
index 459c2ec..7b8f3aa 100755 (executable)
@@ -29,6 +29,17 @@ namespace Time {
 using namespace WrtDeviceApis;
 using namespace WrtDeviceApis::Commons;
 
+class_definition_options_t ConstructorClassOptions =
+{
+    JS_INTERFACE,
+    CREATE_INSTANCE,
+    NONE_NOTICE,
+    USE_OVERLAYED, //ignored
+    NULL,
+    NULL,
+    NULL
+};
+
 void on_widget_start_callback(int widgetId) {
        LogDebug("[TIZEN\\TimeUtil] on_widget_start_callback ("<<widgetId<<")");
     Try
@@ -57,21 +68,20 @@ PLUGIN_ON_WIDGET_START(on_widget_start_callback)
 PLUGIN_ON_WIDGET_STOP(on_widget_stop_callback)
 
 PLUGIN_CLASS_MAP_BEGIN
-       PLUGIN_CLASS_MAP_ADD_CLASS(
-               WRT_JS_EXTENSION_OBJECT_TIZEN,
-               "time",
-               (js_class_template_getter)DeviceAPI::Time::JSTimeUtil::getClassRef,
-               NULL)
-       PLUGIN_CLASS_MAP_ADD_CLASS(
-               WRT_JS_EXTENSION_OBJECT_TIZEN,
-               "TZDate",
-               (js_class_template_getter)DeviceAPI::Time::JSTZDate::getClassRef,
-               NULL)
-       PLUGIN_CLASS_MAP_ADD_CLASS(
-               WRT_JS_EXTENSION_OBJECT_TIZEN,
-               "TimeDuration",
-               (js_class_template_getter)DeviceAPI::Time::JSTimeDuration::getClassRef,
-               NULL)
+PLUGIN_CLASS_MAP_ADD_CLASS(WRT_JS_EXTENSION_OBJECT_TIZEN,
+        "time",
+        (js_class_template_getter)JSTimeUtil::getClassRef,
+        NULL)
+PLUGIN_CLASS_MAP_ADD_INTERFACE(WRT_JS_EXTENSION_OBJECT_TIZEN,
+        "TZDate",
+        (js_class_template_getter)JSTZDate::getClassRef,
+        reinterpret_cast<js_class_constructor_cb_t>(JSTZDate::constructor),
+        &ConstructorClassOptions)
+PLUGIN_CLASS_MAP_ADD_INTERFACE(WRT_JS_EXTENSION_OBJECT_TIZEN,
+        "TimeDuration",
+        (js_class_template_getter)JSTimeDuration::getClassRef,
+        reinterpret_cast<js_class_constructor_cb_t>(JSTimeDuration::constructor),
+        &ConstructorClassOptions)
 PLUGIN_CLASS_MAP_END
 
 } // Time