Update change log and spec for wrt-plugins-tizen_0.4.34
authorDongjin Choi <milkelf.choi@samsung.com>
Thu, 23 May 2013 09:40:20 +0000 (18:40 +0900)
committerDongjin Choi <milkelf.choi@samsung.com>
Thu, 23 May 2013 09:40:20 +0000 (18:40 +0900)
[model] REDWOOD
[binary_type] PDA
[customer] OPEN

[Issue] N/A
[Problem] memory leak in callback code.
[Cause] there is not free code in return block.
[Solution] free memory.

[Issue] Prevent 53938
[Problem] Resource leak
[Cause] mms_struct is not released
[Solution] release mms_struct

[Issue#] N/A
[Problem] N/A
[Cause] N/A
[Solution] Add profiling code for performance checking

[Issue#] N/A
[Problem] DPL need 2~3 msec additionllay for every sync-to-sync call
[Cause] N/A
[Solution] call platform code directly without dpl

[Issue#] N/A
[Problem] N/A
[Cause] N/A
[Solution] Add additional profiling code for package

[Issue#] N/A
[Problem] Plugin preload didn't work.
[Cause] Calendar thread not generated as expected.
[Solution] Don't use a calendar thread for all function calls.

[team] WebAPI
[request] N/A
[horizontal_expansion] N/A

23 files changed:
packaging/wrt-plugins-tizen.spec
src/Alarm/JSAlarmAbsolute.cpp
src/Alarm/JSAlarmManager.cpp
src/Alarm/JSAlarmRelative.cpp
src/Application/AppManagerWrapper.cpp
src/Application/ApplicationController.cpp
src/Application/ApplicationConverter.h
src/Application/ApplicationManager.cpp
src/Application/ApplicationManager.h
src/Application/IApplicationManager.cpp
src/Application/IApplicationManager.h
src/Application/JSApplicationManager.cpp
src/Application/JSRequestedApplicationControl.cpp
src/Application/RequestedApplicationControl.cpp
src/Calendar/Calendar.h
src/Calendar/CalendarManager.h
src/Calendar/ICalendar.cpp
src/Calendar/ICalendarManager.cpp
src/DataControl/MappedDataControlConsumer.cpp
src/DataControl/SqlDataControlConsumer.cpp
src/Messaging/Mms.cpp
src/Package/JSPackageManager.cpp
src/Package/PackageManager.cpp

index 72f2d45..91dbdc4 100755 (executable)
@@ -1,6 +1,6 @@
 Name:       wrt-plugins-tizen
 Summary:    JavaScript plugins for WebRuntime
-Version:    0.4.33
+Version:    0.4.34
 Release:    0
 Group:      Development/Libraries
 License:    Apache License, Version 2.0
index feaea94..1c78c4f 100644 (file)
@@ -32,6 +32,7 @@
 #include <time.h>
 #include <JSUtil.h>
 
+#include <TimeTracer.h>
 #include "plugin_config.h"
 #include "JSAlarmAbsolute.h"
 #include "JSAlarmManager.h"
@@ -48,49 +49,49 @@ using namespace DeviceAPI::Common;
 JSClassRef JSAlarmAbsolute::m_jsClassRef = NULL;
 
 JSClassDefinition JSAlarmAbsolute::m_jsClassInfo = {
-               0,
-               kJSClassAttributeNone,
-               TIZEN_ALARM_ABSOLUTE_INTERFACE,
-               NULL,
-               m_property,
-               m_function,
-               initialize,
-               finalize,
-               NULL, //hasProperty,
-               NULL, //getProperty,
-               NULL, //setProperty,
-               NULL, //deleteProperty,Geolocation
-               NULL, //getPropertyNames,
-               NULL,
-               NULL, // constructor
-               NULL,
-               NULL
+        0,
+        kJSClassAttributeNone,
+        TIZEN_ALARM_ABSOLUTE_INTERFACE,
+        NULL,
+        m_property,
+        m_function,
+        initialize,
+        finalize,
+        NULL, //hasProperty,
+        NULL, //getProperty,
+        NULL, //setProperty,
+        NULL, //deleteProperty,Geolocation
+        NULL, //getPropertyNames,
+        NULL,
+        NULL, // constructor
+        NULL,
+        NULL
 };
 
 JSStaticFunction JSAlarmAbsolute::m_function[] = { 
-       { ALARM_FUNCTION_API_GET_NEXT_SCHEDULED_DATE, JSAlarmAbsolute::getNextScheduledDate, kJSPropertyAttributeNone },
-       { 0, 0, 0 }
+    { ALARM_FUNCTION_API_GET_NEXT_SCHEDULED_DATE, JSAlarmAbsolute::getNextScheduledDate, kJSPropertyAttributeNone },
+    { 0, 0, 0 }
 };
 
 JSStaticValue JSAlarmAbsolute::m_property[] = {
-       { TIZEN_ALARM_ABSOLUTE_ATTRIBUTE_ID, getId, NULL, kJSPropertyAttributeReadOnly },
-       { TIZEN_ALARM_ABSOLUTE_ATTRIBUTE_DATE, getDate, NULL, kJSPropertyAttributeReadOnly },
-       { TIZEN_ALARM_ABSOLUTE_ATTRIBUTE_PERIOD, getInterval, NULL, kJSPropertyAttributeReadOnly },
-       { TIZEN_ALARM_ABSOLUTE_ATTRIBUTE_DAYSOFTHEWEEK, getDaysOfTheWeek, NULL, kJSPropertyAttributeReadOnly },
-       { 0, 0, 0, 0 }                                                                                            
+    { TIZEN_ALARM_ABSOLUTE_ATTRIBUTE_ID, getId, NULL, kJSPropertyAttributeReadOnly },
+    { TIZEN_ALARM_ABSOLUTE_ATTRIBUTE_DATE, getDate, NULL, kJSPropertyAttributeReadOnly },
+    { TIZEN_ALARM_ABSOLUTE_ATTRIBUTE_PERIOD, getInterval, NULL, kJSPropertyAttributeReadOnly },
+    { TIZEN_ALARM_ABSOLUTE_ATTRIBUTE_DAYSOFTHEWEEK, getDaysOfTheWeek, NULL, kJSPropertyAttributeReadOnly },
+    { 0, 0, 0, 0 }                                                                                            
 };
 
 const JSClassRef DLL_EXPORT JSAlarmAbsolute::getClassRef()
 {
-       if (!m_jsClassRef) {
-               m_jsClassRef = JSClassCreate(&m_jsClassInfo);
-       }
-       return m_jsClassRef;
+    if (!m_jsClassRef) {
+        m_jsClassRef = JSClassCreate(&m_jsClassInfo);
+    }
+    return m_jsClassRef;
 }
 
 const JSClassDefinition* JSAlarmAbsolute::getClassInfo() 
 {
-       return &m_jsClassInfo;
+    return &m_jsClassInfo;
 }
 
 void JSAlarmAbsolute::initialize(JSContextRef context, JSObjectRef object) 
@@ -115,20 +116,20 @@ JSObjectRef DLL_EXPORT JSAlarmAbsolute::constructor(JSContextRef ctx, JSObjectRe
 {
     try {
         AlarmAbsolutePtr priv = AlarmAbsolutePtr(new AlarmAbsolute());
-               if (!priv) {
-                       throw TypeMismatchException("Private object is null");
-               }
+        if (!priv) {
+            throw TypeMismatchException("Private object is null");
+        }
 
-               ArgumentValidator validator(ctx, argumentCount, arguments);     
-               time_t date = validator.toTimeT(0);
-               struct tm *startDate = localtime(&date);
-               mktime(startDate);
-               
-               priv->setDate(*startDate);
+        ArgumentValidator validator(ctx, argumentCount, arguments); 
+        time_t date = validator.toTimeT(0);
+        struct tm *startDate = localtime(&date);
+        mktime(startDate);
+        
+        priv->setDate(*startDate);
 
-               if (argumentCount >= 2) {
-                       if (JSIsArrayValue(ctx, arguments[1])) {
-                               std::vector<std::string> daysOfTheWeek =  validator.toStringVector(1);
+        if (argumentCount >= 2) {
+            if (JSIsArrayValue(ctx, arguments[1])) {
+                std::vector<std::string> daysOfTheWeek =  validator.toStringVector(1);
 
                 for (int i = 0; i < daysOfTheWeek.size(); i++ ) {
                     if ( (daysOfTheWeek[i]!="SU") && (daysOfTheWeek[i]!="MO") &&
@@ -142,20 +143,20 @@ JSObjectRef DLL_EXPORT JSAlarmAbsolute::constructor(JSContextRef ctx, JSObjectRe
                 if(daysOfTheWeek.size() > 0) {
                     priv->setByDayRecurrence(daysOfTheWeek);    
                 }
-                       } else {
-                               long interval = validator.toLong(1);
-                               if (interval < 0) {
-                                       throw InvalidValuesException("period can not be negative value");
-                               }
+            } else {
+                long interval = validator.toLong(1);
+                if (interval < 0) {
+                    throw InvalidValuesException("period can not be negative value");
+                }
 
-                               priv->setInterval(interval);
-                       }
-               }
+                priv->setInterval(interval);
+            }
+        }
 
-               return JSValueToObject(ctx, createJSObject(ctx, priv), exception);
+        return JSValueToObject(ctx, createJSObject(ctx, priv), exception);
 
     } catch (const BasePlatformException& err) {
-               return JSWebAPIErrorFactory::postException(ctx, exception, err);
+        return JSWebAPIErrorFactory::postException(ctx, exception, err);
     }
 }
 
@@ -163,11 +164,11 @@ AlarmAbsolutePtr JSAlarmAbsolute::getPrivData(JSObjectRef object)
 {
     JSAlarmAbsolutePriv *priv = static_cast<JSAlarmAbsolutePriv*>(JSObjectGetPrivate(object));
     if (!priv) {
-               throw TypeMismatchException("Private object is null");
+        throw TypeMismatchException("Private object is null");
     }
     AlarmAbsolutePtr result = priv->getObject();
     if (!result) {
-               throw TypeMismatchException("Private object is null");
+        throw TypeMismatchException("Private object is null");
     }
     return result;
 }
@@ -179,7 +180,7 @@ JSValueRef JSAlarmAbsolute::createJSObject(JSContextRef context, const int id)
     
     JSAlarmAbsolutePriv *priv = new JSAlarmAbsolutePriv(context, privateData);
     if (!priv) {
-               throw TypeMismatchException("Private object is null");
+        throw TypeMismatchException("Private object is null");
     }
     return  JSObjectMake(context, getClassRef(), static_cast<void*>(priv));
 }
@@ -188,7 +189,7 @@ JSValueRef JSAlarmAbsolute::createJSObject(JSContextRef context, AlarmAbsolutePt
 {
     JSAlarmAbsolutePriv *priv = new JSAlarmAbsolutePriv(context, privateData);
     if (!priv) {
-               throw TypeMismatchException("Private object is null");
+        throw TypeMismatchException("Private object is null");
     }
     return JSObjectMake(context, getClassRef(), static_cast<void*>(priv));
 }
@@ -200,7 +201,7 @@ JSValueRef JSAlarmAbsolute::createJSObject(JSContextRef context, struct tm date,
 
     JSAlarmAbsolutePriv *priv = new JSAlarmAbsolutePriv(context, privateData);
     if (!priv) {
-               throw TypeMismatchException("Private object is null");
+        throw TypeMismatchException("Private object is null");
     }
     return JSObjectMake(context, getClassRef(), static_cast<void*>(priv));
 }
@@ -212,35 +213,40 @@ JSValueRef JSAlarmAbsolute::createJSObject(JSContextRef context, struct tm date)
 
     JSAlarmAbsolutePriv *priv = new JSAlarmAbsolutePriv(context, privateData);
     if (!priv) {
-               throw TypeMismatchException("Private object is null");
+        throw TypeMismatchException("Private object is null");
     }
     return JSObjectMake(context, getClassRef(), static_cast<void*>(priv));
 }
 
 JSValueRef JSAlarmAbsolute::getNextScheduledDate( JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception)
 {   
-       try {
-           struct tm date;
-           Converter converter(ctx);
-               
+    TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0);
+    try {
+        struct tm date;
+        Converter converter(ctx);
+        
         AlarmAbsolutePtr privateData = getPrivData(thisObject);
-               if (!privateData) {
-                       throw TypeMismatchException("Private object is null");
-           }
-               
+        if (!privateData) {
+            throw TypeMismatchException("Private object is null");
+        }
+        
         if(!privateData->is_registered) {
             return JSValueMakeNull(ctx);
         }
 
         int id = privateData->getId();
+        TIME_TRACER_ITEM_BEGIN("(getNextScheduledDate)alarm_get_scheduled_date", 0);
         int err = alarm_get_scheduled_date(id, &date);
+        TIME_TRACER_ITEM_END("(getNextScheduledDate)alarm_get_scheduled_date", 0);
         if(err != ALARM_ERROR_NONE) {
             return JSValueMakeNull(ctx);
         }
 
         // check wheter the alarm is expired or not
         struct tm curr_date;
+        TIME_TRACER_ITEM_BEGIN("(getNextScheduledDate)alarm_get_current_time", 0);
         err = alarm_get_current_time(&curr_date);
+        TIME_TRACER_ITEM_END("(getNextScheduledDate)alarm_get_current_time", 0);
         if(err != ALARM_ERROR_NONE) {
             return JSValueMakeNull(ctx);
         }
@@ -248,10 +254,11 @@ JSValueRef JSAlarmAbsolute::getNextScheduledDate( JSContextRef ctx, JSObjectRef
         if (mktime(&date) < mktime(&curr_date)) {
             return JSValueMakeNull(ctx);
         }
+        TIME_TRACER_ITEM_END(__FUNCTION__, 0);
 
         return converter.toJSValueRef(date);
-               
-       } catch (const BasePlatformException &err) {
+        
+    } catch (const BasePlatformException &err) {
         return JSWebAPIErrorFactory::postException(ctx, exception, err);
     } catch (...) {
         DeviceAPI::Common::UnknownException err("Unknown Error in ApplicationManager.getAppSharedURI().");
@@ -260,19 +267,19 @@ JSValueRef JSAlarmAbsolute::getNextScheduledDate( JSContextRef ctx, JSObjectRef
 }
 
 JSValueRef JSAlarmAbsolute::getDate(JSContextRef ctx,
-               JSObjectRef object,
-               JSStringRef propertyName,
-               JSValueRef* exception)
+        JSObjectRef object,
+        JSStringRef propertyName,
+        JSValueRef* exception)
 {
     Converter converter(ctx);
     struct tm date;
 
-       try {
+    try {
         AlarmAbsolutePtr privateData = getPrivData(object);
-               if (!privateData) {
-                       throw TypeMismatchException("Private object is null");
-           }
-               
+        if (!privateData) {
+            throw TypeMismatchException("Private object is null");
+        }
+        
         date = privateData->getDate();
         LoggerI("JSAlarmAbsolute Date  = " << "  Sec : " << date.tm_sec << "  Min : "<< date.tm_min
         << "  Hour" << date.tm_hour << "Day : " << date.tm_mday << "  MON : " << date.tm_mon 
@@ -289,98 +296,98 @@ JSValueRef JSAlarmAbsolute::getDate(JSContextRef ctx,
         JSObjectRef result = JSObjectMakeDate(ctx, 6, args, exception);
         return result;
     } catch (...) {
-       LoggerE("Exception: occured");
+        LoggerE("Exception: occured");
     }
 
-       return JSValueMakeUndefined(ctx);
+    return JSValueMakeUndefined(ctx);
 }
 
 JSValueRef JSAlarmAbsolute::getId(JSContextRef ctx,
-               JSObjectRef object,
-               JSStringRef propertyName,
-               JSValueRef* exception)
+        JSObjectRef object,
+        JSStringRef propertyName,
+        JSValueRef* exception)
 {
-       try {
+    try {
         AlarmAbsolutePtr privateData = getPrivData(object);
-               if (!privateData) {
-                       throw TypeMismatchException("Private object is null");
-           }
-               
+        if (!privateData) {
+            throw TypeMismatchException("Private object is null");
+        }
+        
         Converter converter(ctx);
-               if (privateData->is_registered) {
+        if (privateData->is_registered) {
             std::string strId = converter.toString(privateData->getId());
             return converter.toJSValueRef(strId);
         } else {
             return JSValueMakeNull(ctx);
         }
-       } catch (...) {
-       LoggerE("Exception: occured");
+    } catch (...) {
+        LoggerE("Exception: occured");
     }
 
-       return JSValueMakeUndefined(ctx);
+    return JSValueMakeUndefined(ctx);
 }
 
 JSValueRef JSAlarmAbsolute::getInterval(JSContextRef ctx,
-               JSObjectRef object,
-               JSStringRef propertyName,
-               JSValueRef* exception)
+        JSObjectRef object,
+        JSStringRef propertyName,
+        JSValueRef* exception)
 {
-       try {
+    try {
         AlarmAbsolutePtr privateData = getPrivData(object);
         AbsoluteRecurrence::Type alarmType = privateData->getRecurrenceType();
        
         if(alarmType == AbsoluteRecurrence::Interval) {
             long interval = privateData->getInterval();
-                       if (interval == -1 ) {
-                               return JSValueMakeNull(ctx);
-                       } else {
-                   return DeviceAPI::Common::JSUtil::toJSValueRef(ctx, interval);
-                       }
+            if (interval == -1 ) {
+                return JSValueMakeNull(ctx);
+            } else {
+                return DeviceAPI::Common::JSUtil::toJSValueRef(ctx, interval);
+            }
         } else {
             return JSValueMakeNull(ctx);    
         }
     } catch (...) {
-       LoggerI("Exception: occured");
+        LoggerI("Exception: occured");
     }
 
-       return JSValueMakeUndefined(ctx);
+    return JSValueMakeUndefined(ctx);
 }
 
 JSValueRef JSAlarmAbsolute::getDaysOfTheWeek(JSContextRef ctx,
-               JSObjectRef object,
-               JSStringRef propertyName,
-               JSValueRef* exception)
+        JSObjectRef object,
+        JSStringRef propertyName,
+        JSValueRef* exception)
 {
     Converter converter(ctx);
     
     try {
         AlarmAbsolutePtr privateData = getPrivData(object);
-               if (!privateData) {
-                       throw TypeMismatchException("Private object is null");
-           }
+        if (!privateData) {
+            throw TypeMismatchException("Private object is null");
+        }
 
         JSObjectRef jsResult = JSCreateArrayObject(ctx, 0, NULL);
-               if (jsResult == NULL) {
-                       throw UnknownException("Could not create js array object");
+        if (jsResult == NULL) {
+            throw UnknownException("Could not create js array object");
         }
-               
+        
         std::vector<std::string> daysOfTheWeek = privateData->getByDayRecurrence();
 
         if(daysOfTheWeek.size() > 0) {
             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");
+                    throw UnknownException("Could not insert value into js array");
                 }
             }
         }
 
         return jsResult;
-       } catch (...) {
-       LoggerI("Exception: occured");
+    } catch (...) {
+        LoggerI("Exception: occured");
     }
 
-       return JSValueMakeUndefined(ctx);
+    return JSValueMakeUndefined(ctx);
 }
 
 } // Alarm
index 6f1fae1..d59abb0 100644 (file)
@@ -98,11 +98,11 @@ JSStaticFunction JSAlarmManager::m_function[] = {
 };
 
 JSStaticValue JSAlarmManager::m_property[] = {
-               { TIZEN_ALARM_CONSTANT_PERIOD_MINUTE, getProperty, NULL, kJSPropertyAttributeReadOnly },
-               { TIZEN_ALARM_CONSTANT_PERIOD_HOUR, getProperty, NULL, kJSPropertyAttributeReadOnly },
-               { TIZEN_ALARM_CONSTANT_PERIOD_DAY, getProperty, NULL, kJSPropertyAttributeReadOnly },
-               { TIZEN_ALARM_CONSTANT_PERIOD_WEEK, getProperty, NULL, kJSPropertyAttributeReadOnly },
-               { 0, 0, 0, 0 }
+        { TIZEN_ALARM_CONSTANT_PERIOD_MINUTE, getProperty, NULL, kJSPropertyAttributeReadOnly },
+        { TIZEN_ALARM_CONSTANT_PERIOD_HOUR, getProperty, NULL, kJSPropertyAttributeReadOnly },
+        { TIZEN_ALARM_CONSTANT_PERIOD_DAY, getProperty, NULL, kJSPropertyAttributeReadOnly },
+        { TIZEN_ALARM_CONSTANT_PERIOD_WEEK, getProperty, NULL, kJSPropertyAttributeReadOnly },
+        { 0, 0, 0, 0 }
 };
 
 const JSClassRef DLL_EXPORT JSAlarmManager::getClassRef()
@@ -135,125 +135,134 @@ bool JSAlarmManager::hasInstance(JSContextRef context, JSObjectRef constructor,
 
 JSValueRef JSAlarmManager::add(JSContextRef ctx, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
 {
-       TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0);
-       service_h service;
-       struct tm startDate;
-       int delay = 0;
-       int alarm_id;
-       std::string applicationId;
-       std::string page;
-
-       TIME_TRACER_ITEM_BEGIN("(add)ace_check", 0);
-       AceSecurityStatus status = ALARM_CHECK_ACCESS(ALARM_FUNCTION_API_ADD);
-       TIZEN_SYNC_ACCESS_HANDLER(status, ctx, exception);
-       TIME_TRACER_ITEM_END("(add)ace_check", 0);
-
-       try {
-               ArgumentValidator validator(ctx, argumentCount, arguments);
-               AlarmConverter converter(ctx);
-               
-               // applicationId
-               std::string appId = validator.toString(1);
-
-               // alarm
+    TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0);
+    service_h service;
+    struct tm startDate;
+    int delay = 0;
+    int alarm_id;
+    std::string applicationId;
+    std::string page;
+
+    TIME_TRACER_ITEM_BEGIN("(add)ace_check", 0);
+    AceSecurityStatus status = ALARM_CHECK_ACCESS(ALARM_FUNCTION_API_ADD);
+    TIZEN_SYNC_ACCESS_HANDLER(status, ctx, exception);
+    TIME_TRACER_ITEM_END("(add)ace_check", 0);
+
+    try {
+        ArgumentValidator validator(ctx, argumentCount, arguments);
+        AlarmConverter converter(ctx);
+        
+        // applicationId
+        std::string appId = validator.toString(1);
+
+        // alarm
         JSObjectRef alarmObj = validator.toObject(0);
-               if (JSValueIsObjectOfClass(ctx, alarmObj, JSAlarmAbsolute::getClassRef())) {
-
-                       JSAlarmAbsolutePriv *priv = static_cast<JSAlarmAbsolutePriv*>(JSObjectGetPrivate(alarmObj));
-                       if (!priv) {
-                               throw TypeMismatchException("Object is null.");
-                       }
-                       AlarmAbsolutePtr alarmPtr = priv->getObject();
-                       if (!alarmPtr) {
-                               throw TypeMismatchException("Private object is null.");
-                       }
-       
-                       startDate = alarmPtr->getDate();
-                       service = alarmPtr->getService();
-                       service_set_app_id(service, appId.c_str());
-                       
-                       // appControl
-                       JSObjectRef appControlObj = validator.toObject(2, true);
-                       if (appControlObj) {
-                               if(!JSValueIsObjectOfClass(ctx, appControlObj, DeviceAPI::Application::JSApplicationControl::getClassRef())) {
-                                       throw TypeMismatchException("Third parameter is not a ApplicationControl object");
-                               }
-                               DeviceAPI::Application::ApplicationConverter applicationConverter(ctx);
-                               DeviceAPI::Application::ApplicationControlPtr appService = applicationConverter.toApplicationControl(appControlObj);
-                               if(converter.toAlarmService(service, appService) == false) {
-                                       throw TypeMismatchException("Third parameter is not a ApplicationControl object");
-                               }
-                       } else {
-                               service_set_operation(service, SERVICE_OPERATION_DEFAULT);
-                       }
-
-                       AbsoluteRecurrence::Type alarmType = alarmPtr->getRecurrenceType();
-
-                       int err = ALARM_ERROR_NONE;
-                       if(alarmType == AbsoluteRecurrence::ByDayValue) {
-                               int bydayValue = converter.toNativeAlarmValue(alarmPtr->getByDayRecurrence());
-                               LoggerI("Native bydayValue = " << bydayValue);
-                               err = alarm_schedule_with_recurrence_week_flag(service, &startDate, bydayValue, &alarm_id);
-                       } else if(alarmType == AbsoluteRecurrence::Interval) {
-                               int interval = alarmPtr->getInterval();
-                               err = alarm_schedule_at_date(service, &startDate, interval, &alarm_id);
-                       } else {
-                               err = alarm_schedule_at_date(service, &startDate, 0, &alarm_id);
-                       }
-
-                       if(err == ALARM_ERROR_NONE) {
-                               alarmPtr->setId(alarm_id);
-                       } else {
-                               throw UnknownException("Alarm scheduling failed.");
-                       }
-                       
-               } else if (JSValueIsObjectOfClass(ctx, alarmObj, JSAlarmRelative::getClassRef())) {
-
-                       JSAlarmRelativePriv *priv = static_cast<JSAlarmRelativePriv*>(JSObjectGetPrivate(alarmObj));
-                       if (!priv) {
-                               throw TypeMismatchException("Object is null.");
-                       }
-                       AlarmRelativePtr alarmPtr = priv->getObject();
-                       if (!alarmPtr) {
-                               throw TypeMismatchException("Private object is null.");
-                       }
-
-                       delay = alarmPtr->getDelay();
-                       long interval = alarmPtr->getPeriod();
-                       service = alarmPtr->getService();
-                       service_set_app_id(service, appId.c_str());
-
-                       // appControl
-                       JSObjectRef appControlObj = validator.toObject(2, true);
-                       if (appControlObj) {
-                               if(!JSValueIsObjectOfClass(ctx, appControlObj, DeviceAPI::Application::JSApplicationControl::getClassRef())) {
-                                       throw TypeMismatchException("Third parameter is not a ApplicationControl object");
-                               }
-                               DeviceAPI::Application::ApplicationConverter applicationConverter(ctx);
-                               DeviceAPI::Application::ApplicationControlPtr appService = applicationConverter.toApplicationControl(appControlObj);
-                               if(converter.toAlarmService(service, appService) == false) {
-                                       throw TypeMismatchException("Third parameter is not a ApplicationControl object");
-                               }
-                       } else {
-                               service_set_operation(service, SERVICE_OPERATION_DEFAULT);
-                       }
-
-                       int err = alarm_schedule_after_delay(service, delay, interval, &alarm_id);
-
-                       if(err == ALARM_ERROR_NONE) {
-                               alarmPtr->setId(alarm_id);
-                       } else {
-                               throw UnknownException("Alarm scheduling failed.");
-                       }
-
-               } else {
-                       LoggerE("First parameter is not a Alarm object");
-                       throw TypeMismatchException("First parameter is not a Alarm object");
-               }
-               TIME_TRACER_ITEM_END(__FUNCTION__, 0);
-               return JSValueMakeUndefined(ctx);
-
-       }  catch (const BasePlatformException &err) {
+        if (JSValueIsObjectOfClass(ctx, alarmObj, JSAlarmAbsolute::getClassRef())) {
+
+            JSAlarmAbsolutePriv *priv = static_cast<JSAlarmAbsolutePriv*>(JSObjectGetPrivate(alarmObj));
+            if (!priv) {
+                throw TypeMismatchException("Object is null.");
+            }
+            AlarmAbsolutePtr alarmPtr = priv->getObject();
+            if (!alarmPtr) {
+                throw TypeMismatchException("Private object is null.");
+            }
+    
+            startDate = alarmPtr->getDate();
+            service = alarmPtr->getService();
+            service_set_app_id(service, appId.c_str());
+            
+            // appControl
+            JSObjectRef appControlObj = validator.toObject(2, true);
+            if (appControlObj) {
+                if(!JSValueIsObjectOfClass(ctx, appControlObj, DeviceAPI::Application::JSApplicationControl::getClassRef())) {
+                    throw TypeMismatchException("Third parameter is not a ApplicationControl object");
+                }
+                DeviceAPI::Application::ApplicationConverter applicationConverter(ctx);
+                DeviceAPI::Application::ApplicationControlPtr appService = applicationConverter.toApplicationControl(appControlObj);
+                if(converter.toAlarmService(service, appService) == false) {
+                    throw TypeMismatchException("Third parameter is not a ApplicationControl object");
+                }
+            } else {
+                service_set_operation(service, SERVICE_OPERATION_DEFAULT);
+            }
+
+            AbsoluteRecurrence::Type alarmType = alarmPtr->getRecurrenceType();
+
+            int err = ALARM_ERROR_NONE;
+            if(alarmType == AbsoluteRecurrence::ByDayValue) {
+                int bydayValue = converter.toNativeAlarmValue(alarmPtr->getByDayRecurrence());
+                LoggerI("Native bydayValue = " << bydayValue);
+                TIME_TRACER_ITEM_BEGIN("(add)alarm_schedule_with_recurrence_week_flag", 0);
+                err = alarm_schedule_with_recurrence_week_flag(service, &startDate, bydayValue, &alarm_id);
+                TIME_TRACER_ITEM_END("(add)alarm_schedule_with_recurrence_week_flag", 0);
+
+            } else if(alarmType == AbsoluteRecurrence::Interval) {
+                int interval = alarmPtr->getInterval();
+                TIME_TRACER_ITEM_BEGIN("(add)alarm_schedule_at_date", 0);
+                err = alarm_schedule_at_date(service, &startDate, interval, &alarm_id);
+                TIME_TRACER_ITEM_END("(add)alarm_schedule_at_date", 0);
+            } else {
+                TIME_TRACER_ITEM_BEGIN("(add)alarm_schedule_at_date", 0);
+                err = alarm_schedule_at_date(service, &startDate, 0, &alarm_id);
+                TIME_TRACER_ITEM_END("(add)alarm_schedule_at_date", 0);
+            }
+
+            if(err == ALARM_ERROR_NONE) {
+                alarmPtr->setId(alarm_id);
+            } else {
+                throw UnknownException("Alarm scheduling failed.");
+            }
+            
+        } else if (JSValueIsObjectOfClass(ctx, alarmObj, JSAlarmRelative::getClassRef())) {
+
+            JSAlarmRelativePriv *priv = static_cast<JSAlarmRelativePriv*>(JSObjectGetPrivate(alarmObj));
+            if (!priv) {
+                throw TypeMismatchException("Object is null.");
+            }
+            AlarmRelativePtr alarmPtr = priv->getObject();
+            if (!alarmPtr) {
+                throw TypeMismatchException("Private object is null.");
+            }
+
+            delay = alarmPtr->getDelay();
+            long interval = alarmPtr->getPeriod();
+            service = alarmPtr->getService();
+            service_set_app_id(service, appId.c_str());
+
+            // appControl
+            JSObjectRef appControlObj = validator.toObject(2, true);
+            if (appControlObj) {
+                if(!JSValueIsObjectOfClass(ctx, appControlObj, DeviceAPI::Application::JSApplicationControl::getClassRef())) {
+                    throw TypeMismatchException("Third parameter is not a ApplicationControl object");
+                }
+                DeviceAPI::Application::ApplicationConverter applicationConverter(ctx);
+                DeviceAPI::Application::ApplicationControlPtr appService = applicationConverter.toApplicationControl(appControlObj);
+                if(converter.toAlarmService(service, appService) == false) {
+                    throw TypeMismatchException("Third parameter is not a ApplicationControl object");
+                }
+            } else {
+                service_set_operation(service, SERVICE_OPERATION_DEFAULT);
+            }
+
+            TIME_TRACER_ITEM_BEGIN("(add)alarm_schedule_after_delay", 0);
+            int err = alarm_schedule_after_delay(service, delay, interval, &alarm_id);
+            TIME_TRACER_ITEM_END("(add)alarm_schedule_after_delay", 0);
+
+            if(err == ALARM_ERROR_NONE) {
+                alarmPtr->setId(alarm_id);
+            } else {
+                throw UnknownException("Alarm scheduling failed.");
+            }
+
+        } else {
+            LoggerE("First parameter is not a Alarm object");
+            throw TypeMismatchException("First parameter is not a Alarm object");
+        }
+        TIME_TRACER_ITEM_END(__FUNCTION__, 0);
+        return JSValueMakeUndefined(ctx);
+
+    }  catch (const BasePlatformException &err) {
         return JSWebAPIErrorFactory::postException(ctx, exception, err);
     } catch (...) {
         DeviceAPI::Common::UnknownException err("Unknown Error in ApplicationManager.getAppSharedURI().");
@@ -263,34 +272,36 @@ JSValueRef JSAlarmManager::add(JSContextRef ctx, JSObjectRef object, JSObjectRef
 
 JSValueRef JSAlarmManager::remove(JSContextRef ctx, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
 {
-       TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0);
+    TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0);
+    TIME_TRACER_ITEM_BEGIN("(add)ace_check", 0);
     AceSecurityStatus status = ALARM_CHECK_ACCESS(ALARM_FUNCTION_API_REMOVE);
     TIZEN_SYNC_ACCESS_HANDLER(status, ctx, exception);
+    TIME_TRACER_ITEM_END("(add)ace_check", 0);
     
-       try {
-               ArgumentValidator validator(ctx, argumentCount, arguments);
+    try {
+        ArgumentValidator validator(ctx, argumentCount, arguments);
 
-               // id
+        // id
         std::string id = validator.toString(0);
-               
-               int alarmId = 0;
-               std::stringstream(id) >> alarmId;
-
-               if (alarmId <= 0) {
-                       throw InvalidValuesException("Invalid ID");
-               }
-
-               TIME_TRACER_ITEM_BEGIN("(remove)alarm_cancel", 0);
-               int ret = alarm_cancel(alarmId);
-               TIME_TRACER_ITEM_END("(remove)alarm_cancel", 0);
-
-               if (ret != ALARM_ERROR_NONE) {
-                       throw NotFoundException("Alarm not found");
-               }
-               
-               TIME_TRACER_ITEM_END(__FUNCTION__, 0);
-               return JSValueMakeUndefined(ctx);
-       } catch (const BasePlatformException &err) {
+        
+        int alarmId = 0;
+        std::stringstream(id) >> alarmId;
+
+        if (alarmId <= 0) {
+            throw InvalidValuesException("Invalid ID");
+        }
+
+        TIME_TRACER_ITEM_BEGIN("(remove)alarm_cancel", 0);
+        int ret = alarm_cancel(alarmId);
+        TIME_TRACER_ITEM_END("(remove)alarm_cancel", 0);
+
+        if (ret != ALARM_ERROR_NONE) {
+            throw NotFoundException("Alarm not found");
+        }
+        
+        TIME_TRACER_ITEM_END(__FUNCTION__, 0);
+        return JSValueMakeUndefined(ctx);
+    } catch (const BasePlatformException &err) {
         return JSWebAPIErrorFactory::postException(ctx, exception, err);
     } catch (...) {
         DeviceAPI::Common::UnknownException err("Unknown Error in ApplicationManager.getAppSharedURI().");
@@ -300,85 +311,87 @@ JSValueRef JSAlarmManager::remove(JSContextRef ctx, JSObjectRef object, JSObject
 
 JSValueRef JSAlarmManager::removeAll(JSContextRef ctx, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
 {
-       TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0);
+    TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0);
+    TIME_TRACER_ITEM_BEGIN("(add)ace_check", 0);
     AceSecurityStatus status = ALARM_CHECK_ACCESS(ALARM_FUNCTION_API_REMOVE_ALL);
     TIZEN_SYNC_ACCESS_HANDLER(status, ctx, exception);
+    TIME_TRACER_ITEM_END("(add)ace_check", 0);
 
-       TIME_TRACER_ITEM_BEGIN("(removeAll)alarm_cancel_all", 0);
-       int returnVal = alarm_cancel_all();
-       TIME_TRACER_ITEM_END("(removeAll)alarm_cancel_all", 0);
+    TIME_TRACER_ITEM_BEGIN("(removeAll)alarm_cancel_all", 0);
+    int returnVal = alarm_cancel_all();
+    TIME_TRACER_ITEM_END("(removeAll)alarm_cancel_all", 0);
 
-       if (ALARM_ERROR_NONE != returnVal) {
-               LoggerE("Error while removing all alarms: "<< returnVal);
-       }
+    if (ALARM_ERROR_NONE != returnVal) {
+        LoggerE("Error while removing all alarms: "<< returnVal);
+    }
 
-       TIME_TRACER_ITEM_END(__FUNCTION__, 0);
+    TIME_TRACER_ITEM_END(__FUNCTION__, 0);
     return JSValueMakeUndefined(ctx);
 }
 
 JSValueRef JSAlarmManager::get(JSContextRef ctx, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
 {
-       TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0);
+    TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0);
     try {
-               service_h service = NULL;
-               char* alarmType = NULL;
-               JSValueRef result = NULL;
-               
+        service_h service = NULL;
+        char* alarmType = NULL;
+        JSValueRef result = NULL;
+        
         ArgumentValidator validator(ctx, argumentCount, arguments);
-           AlarmConverter converter(ctx);
+        AlarmConverter converter(ctx);
 
         // id
         std::string id = validator.toString(0);
-               int alarmId = 0;
-               std::stringstream(id) >> alarmId;       
-
-               if (alarmId <= 0) {
-                       LoggerE("Wrong Alarm ID");
-                       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);
-
-               if (ret != ALARM_ERROR_NONE) {
-                       throw NotFoundException("Alarm not found");
-               }
-               
-               ret = service_get_extra_data(service, ALARM_TYPE_KEY, &alarmType);
-               if (ret != SERVICE_ERROR_NONE) {
-                       LoggerE("Getting data failed: " << ret);
-                       service_destroy(service);
-                       throw UnknownException("Unknown error occurred.");
-               }
-               
-               if (strcmp(alarmType, ALARM_TYPE_ABSOLUTE_VALUE) == 0) {
-                       AlarmAbsolutePtr privateData = AlarmAbsolutePtr(new AlarmAbsolute(service));
-                       
-                       if(!converter.toAlarmAbsolutePtr(alarmId, service, privateData)) {
-                               service_destroy(service);
+        int alarmId = 0;
+        std::stringstream(id) >> alarmId;   
+
+        if (alarmId <= 0) {
+            LoggerE("Wrong Alarm ID");
+            throw InvalidValuesException("Invalid ID");
+        }
+
+        TIME_TRACER_ITEM_BEGIN("(get)alarm_get_service", 0);
+        int ret = alarm_get_service(alarmId, &service);
+
+        if (ret != ALARM_ERROR_NONE) {
+            throw NotFoundException("Alarm not found");
+        }
+        
+        ret = service_get_extra_data(service, ALARM_TYPE_KEY, &alarmType);
+        if (ret != SERVICE_ERROR_NONE) {
+            LoggerE("Getting data failed: " << ret);
+            service_destroy(service);
+            throw UnknownException("Unknown error occurred.");
+        }
+        TIME_TRACER_ITEM_END("(get)alarm_get_service", 0);
+        
+        if (strcmp(alarmType, ALARM_TYPE_ABSOLUTE_VALUE) == 0) {
+            AlarmAbsolutePtr privateData = AlarmAbsolutePtr(new AlarmAbsolute(service));
+            
+            if(!converter.toAlarmAbsolutePtr(alarmId, service, privateData)) {
+                service_destroy(service);
                 throw TypeMismatchException("Alarm not found");
             }
 
-            result = JSAlarmAbsolute::createJSObject(ctx, privateData);                
+            result = JSAlarmAbsolute::createJSObject(ctx, privateData);     
 
-               } else if(strcmp(alarmType, ALARM_TYPE_RELATIVE_VALUE) == 0) {
+        } else if(strcmp(alarmType, ALARM_TYPE_RELATIVE_VALUE) == 0) {
             AlarmRelativePtr privateData = AlarmRelativePtr(new AlarmRelative(service));
-                       
+            
             if(!converter.toAlarmRelativePtr(alarmId, service, privateData)) {
-                               service_destroy(service);
+                service_destroy(service);
                  throw TypeMismatchException("Alarm not found");
             }
-                       
+            
             result = JSAlarmRelative::createJSObject(ctx, privateData);  
-               } else {
-                       service_destroy(service);
-                       throw UnknownException("Unknown error occurred.");
-               }
-
-               service_destroy(service);
-               TIME_TRACER_ITEM_END(__FUNCTION__, 0);
-               return result;
+        } else {
+            service_destroy(service);
+            throw UnknownException("Unknown error occurred.");
+        }
+
+        service_destroy(service);
+        TIME_TRACER_ITEM_END(__FUNCTION__, 0);
+        return result;
     } catch (const BasePlatformException &err) {
         return JSWebAPIErrorFactory::postException(ctx, exception, err);
     } catch (...) {
@@ -390,12 +403,14 @@ JSValueRef JSAlarmManager::get(JSContextRef ctx, JSObjectRef object, JSObjectRef
 
 JSValueRef JSAlarmManager::getAll(JSContextRef ctx, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
 {
-       TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0);
+    TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0);
     try {
-               AlarmConverter converter(ctx);
-               std::vector<int> alarmIds; 
-               
+        AlarmConverter converter(ctx);
+        std::vector<int> alarmIds; 
+
+        TIME_TRACER_ITEM_BEGIN("(getAll)alarm_foreach_registered_alarm", 0);
         int error = alarm_foreach_registered_alarm(alarm_iterate_callback, &alarmIds);
+        TIME_TRACER_ITEM_END("(getAll)alarm_foreach_registered_alarm", 0);
         if (error == ALARM_ERROR_CONNECTION_FAIL) {
             LoggerE("Alarm system may not be ready yet.");
             alarmIds.clear();
@@ -405,63 +420,67 @@ JSValueRef JSAlarmManager::getAll(JSContextRef ctx, JSObjectRef object, JSObject
         }
 
         JSObjectRef jsResult = JSCreateArrayObject(ctx, 0, NULL);
-           if (jsResult == NULL) {
-                       throw TypeMismatchException("Could not create js array object.");
-           }
+        if (jsResult == NULL) {
+            throw TypeMismatchException("Could not create js array object.");
+        }
 
-               for (size_t i = 0 ; i < alarmIds.size(); i++) {
+        for (size_t i = 0 ; i < alarmIds.size(); i++) {
 
             service_h handle = NULL;
             char* alarmType = NULL;
-                       
+
+            TIME_TRACER_ITEM_BEGIN("(getAll)alarm_get_service", 0);
             error = alarm_get_service(alarmIds.at(i), &handle);
+            TIME_TRACER_ITEM_END("(getAll)alarm_get_service", 0);
             if(error != ALARM_ERROR_NONE) {
                 LoggerE("Getting service failed: " << error);
                 throw NotFoundException("Alarm not found");
             }
 
+            TIME_TRACER_ITEM_BEGIN("(getAll)service_get_extra_data", 0);
             error = service_get_extra_data(handle, ALARM_TYPE_KEY, &alarmType);
+            TIME_TRACER_ITEM_END("(getAll)service_get_extra_data", 0);
             if(error != SERVICE_ERROR_NONE) {
                 LoggerI("Getting data failed: " << error);
                 service_destroy(handle);
                 throw UnknownException("Unknown error occurred.");
             }
 
-                       JSValueRef obj = NULL;
-                       if (strcmp(alarmType, ALARM_TYPE_ABSOLUTE_VALUE) == 0) {
-                               AlarmAbsolutePtr privateData = AlarmAbsolutePtr(new AlarmAbsolute(handle));
+            JSValueRef obj = NULL;
+            if (strcmp(alarmType, ALARM_TYPE_ABSOLUTE_VALUE) == 0) {
+                AlarmAbsolutePtr privateData = AlarmAbsolutePtr(new AlarmAbsolute(handle));
 
-                               if(!converter.toAlarmAbsolutePtr(alarmIds.at(i), handle, privateData)) {
-                                       service_destroy(handle);
-                                       throw TypeMismatchException("Absolute alarm conversion failed.");
-                               }
+                if(!converter.toAlarmAbsolutePtr(alarmIds.at(i), handle, privateData)) {
+                    service_destroy(handle);
+                    throw TypeMismatchException("Absolute alarm conversion failed.");
+                }
 
-                               obj = JSAlarmAbsolute::createJSObject(ctx, privateData);
-                               
+                obj = JSAlarmAbsolute::createJSObject(ctx, privateData);
+                
             } else if( !strcmp(alarmType, ALARM_TYPE_RELATIVE_VALUE)) {
                 AlarmRelativePtr privateData = AlarmRelativePtr(new AlarmRelative(handle));
-                               
+                
                 if(!converter.toAlarmRelativePtr(alarmIds.at(i), handle, privateData)) {
-                                       service_destroy(handle);
-                                       throw TypeMismatchException("Relative alarm conversion failed.");
+                    service_destroy(handle);
+                    throw TypeMismatchException("Relative alarm conversion failed.");
                 }
                 obj = JSAlarmRelative::createJSObject(ctx, privateData);
 
             }  else {
-                   service_destroy(handle);
-                               throw UnknownException("Unknown error occurred.");
-                       }
+                service_destroy(handle);
+                throw UnknownException("Unknown error occurred.");
+            }
 
             service_destroy(handle);
-                       
-                       if(!JSSetArrayElement(ctx, jsResult, i, obj)) {
-                               service_destroy(handle);
-                               throw UnknownException("JS array creation failed.");
-                       }
-               }
-
-               TIME_TRACER_ITEM_END(__FUNCTION__, 0);
-               return jsResult;
+            
+            if(!JSSetArrayElement(ctx, jsResult, i, obj)) {
+                service_destroy(handle);
+                throw UnknownException("JS array creation failed.");
+            }
+        }
+
+        TIME_TRACER_ITEM_END(__FUNCTION__, 0);
+        return jsResult;
     } catch (const BasePlatformException &err) {
         return JSWebAPIErrorFactory::postException(ctx, exception, err);
     } catch (...) {
index bfc5d38..f38bc8d 100644 (file)
@@ -35,6 +35,7 @@
 
 #include <JSUtil.h>
 
+#include <TimeTracer.h>
 #include <app.h>
 #include <time.h>
 #include <Export.h>
@@ -50,23 +51,23 @@ using namespace DeviceAPI::Common;
 JSClassRef JSAlarmRelative::m_jsClassRef = NULL;
 
 JSClassDefinition JSAlarmRelative::m_jsClassInfo = {
-       0,
-       kJSClassAttributeNone,
-       TIZEN_ALARM_RELATIVE_INTERFACE,
-       NULL,
-       m_property,
-       m_function,
-       initialize,
-       finalize,
-       NULL, //hasProperty,
-       NULL, //getProperty,
-       NULL, //setProperty,
-       NULL, //deleteProperty,Geolocation
-       NULL, //getPropertyNames,
-       NULL,
-       NULL, // constructor
-       NULL,
-       NULL
+    0,
+    kJSClassAttributeNone,
+    TIZEN_ALARM_RELATIVE_INTERFACE,
+    NULL,
+    m_property,
+    m_function,
+    initialize,
+    finalize,
+    NULL, //hasProperty,
+    NULL, //getProperty,
+    NULL, //setProperty,
+    NULL, //deleteProperty,Geolocation
+    NULL, //getPropertyNames,
+    NULL,
+    NULL, // constructor
+    NULL,
+    NULL
 };
 
 JSStaticFunction JSAlarmRelative::m_function[] = { 
@@ -75,23 +76,23 @@ JSStaticFunction JSAlarmRelative::m_function[] = {
 };
 
 JSStaticValue JSAlarmRelative::m_property[] = {
-       { TIZEN_ALARM_RELATIVE_ATTRIBUTE_ID, getId, NULL, kJSPropertyAttributeReadOnly },
-       { TIZEN_ALARM_RELATIVE_ATTRIBUTE_DELAY, getDelay, NULL, kJSPropertyAttributeReadOnly },
-       { TIZEN_ALARM_RELATIVE_ATTRIBUTE_PERIOD, getPeriod, NULL, kJSPropertyAttributeReadOnly },
-       { 0, 0, 0, 0 }                                                                                            
+    { TIZEN_ALARM_RELATIVE_ATTRIBUTE_ID, getId, NULL, kJSPropertyAttributeReadOnly },
+    { TIZEN_ALARM_RELATIVE_ATTRIBUTE_DELAY, getDelay, NULL, kJSPropertyAttributeReadOnly },
+    { TIZEN_ALARM_RELATIVE_ATTRIBUTE_PERIOD, getPeriod, NULL, kJSPropertyAttributeReadOnly },
+    { 0, 0, 0, 0 }                                                                                            
 };
 
 const JSClassRef DLL_EXPORT JSAlarmRelative::getClassRef()
 {
-       if (!m_jsClassRef) {
-               m_jsClassRef = JSClassCreate(&m_jsClassInfo);
-       }
-       return m_jsClassRef;
+    if (!m_jsClassRef) {
+        m_jsClassRef = JSClassCreate(&m_jsClassInfo);
+    }
+    return m_jsClassRef;
 }
 
 const JSClassDefinition* JSAlarmRelative::getClassInfo() 
 {
-       return &m_jsClassInfo;
+    return &m_jsClassInfo;
 }
 
 void JSAlarmRelative::initialize(JSContextRef context, JSObjectRef object) 
@@ -113,25 +114,25 @@ bool JSAlarmRelative::hasInstance(JSContextRef context, JSObjectRef constructor,
 
 JSObjectRef DLL_EXPORT JSAlarmRelative::constructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
 {
-       try {
-           ArgumentValidator validator(ctx, argumentCount, arguments);
-
-               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);
-               } else {
-                       return JSValueToObject(ctx, createJSObject(ctx, delay, -1), exception);
-               }
-       } catch (const BasePlatformException& err) {
-               return JSWebAPIErrorFactory::postException(ctx, exception, err);
+    try {
+        ArgumentValidator validator(ctx, argumentCount, arguments);
+
+        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);
+        } else {
+            return JSValueToObject(ctx, createJSObject(ctx, delay, -1), exception);
+        }
+    } catch (const BasePlatformException& err) {
+        return JSWebAPIErrorFactory::postException(ctx, exception, err);
     }
 
 }
@@ -140,11 +141,11 @@ AlarmRelativePtr JSAlarmRelative::getPrivData(JSObjectRef object)
 {
     JSAlarmRelativePriv *priv = static_cast<JSAlarmRelativePriv*>(JSObjectGetPrivate(object));
     if (!priv) {
-               throw TypeMismatchException("Private object is null");
+        throw TypeMismatchException("Private object is null");
     }
     AlarmRelativePtr result = priv->getObject();
     if (!result) {
-               throw TypeMismatchException("Private object is null");
+        throw TypeMismatchException("Private object is null");
     }
     return result;
 }
@@ -153,7 +154,7 @@ JSValueRef JSAlarmRelative::createJSObject(JSContextRef context, AlarmRelativePt
 {
     JSAlarmRelativePriv *priv = new JSAlarmRelativePriv(context, privateData);
     if (!priv) {
-               throw TypeMismatchException("Private object is null");
+        throw TypeMismatchException("Private object is null");
     }
     return JSObjectMake(context, getClassRef(), static_cast<void*>(priv));
 }
@@ -167,7 +168,7 @@ JSValueRef JSAlarmRelative::createJSObject(JSContextRef context, int delay, int
     
     JSAlarmRelativePriv *priv = new JSAlarmRelativePriv(context, privateData);
     if (!priv) {
-               throw TypeMismatchException("Private object is null");
+        throw TypeMismatchException("Private object is null");
     }
     return JSObjectMake(context, getClassRef(), static_cast<void*>(priv));
 }
@@ -180,6 +181,8 @@ JSValueRef JSAlarmRelative::getRemainingSeconds(JSContextRef ctx, JSObjectRef fu
     time_t nextTime;
     int id;
 
+    TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0);
+
     try {
         AlarmRelativePtr privateData = getPrivData(thisObject);
 
@@ -189,7 +192,9 @@ JSValueRef JSAlarmRelative::getRemainingSeconds(JSContextRef ctx, JSObjectRef fu
 
         id = privateData->getId();
 
+        TIME_TRACER_ITEM_BEGIN("(getRemainingSeconds)alarm_get_scheduled_date", 0);
         int err = alarm_get_scheduled_date(id, &date);
+        TIME_TRACER_ITEM_END("(getRemainingSeconds)alarm_get_scheduled_date", 0);
         if(err != ALARM_ERROR_NONE)
         {
             if(err == ALARM_ERROR_INVALID_PARAMETER) {
@@ -199,10 +204,12 @@ JSValueRef JSAlarmRelative::getRemainingSeconds(JSContextRef ctx, JSObjectRef fu
             }
         }
 
+        TIME_TRACER_ITEM_BEGIN("(getRemainingSeconds)alarm_get_current_time", 0);
         alarm_get_current_time(&current);
 
         nextTime = mktime(&date);
         currentTime = mktime(&current);
+        TIME_TRACER_ITEM_END("(getRemainingSeconds)alarm_get_current_time", 0);
 
         long result = nextTime - currentTime;
 
@@ -212,9 +219,10 @@ JSValueRef JSAlarmRelative::getRemainingSeconds(JSContextRef ctx, JSObjectRef fu
             // It is impossible
             throw UnknownException("Unknown exception occurred.");
         }
+        TIME_TRACER_ITEM_END(__FUNCTION__, 0);
 
-               return DeviceAPI::Common::JSUtil::toJSValueRef(ctx, result);
-       } catch (const BasePlatformException &err) {
+        return DeviceAPI::Common::JSUtil::toJSValueRef(ctx, result);
+    } catch (const BasePlatformException &err) {
         return JSWebAPIErrorFactory::postException(ctx, exception, err);
     } catch (...) {
         DeviceAPI::Common::UnknownException err("Unknown Error in ApplicationManager.getAppSharedURI().");
@@ -223,19 +231,19 @@ JSValueRef JSAlarmRelative::getRemainingSeconds(JSContextRef ctx, JSObjectRef fu
 }
 
 JSValueRef JSAlarmRelative::getId(JSContextRef ctx,
-               JSObjectRef object,
-               JSStringRef propertyName,
-               JSValueRef* exception)
+        JSObjectRef object,
+        JSStringRef propertyName,
+        JSValueRef* exception)
 {
     Converter converter(ctx);
 
     try {
         AlarmRelativePtr privateData = getPrivData(object);
-               if (!privateData) {
-                       throw TypeMismatchException("Private object is null");
-           }
-               
-               if(privateData->is_registered) {
+        if (!privateData) {
+            throw TypeMismatchException("Private object is null");
+        }
+        
+        if(privateData->is_registered) {
             std::string strId = converter.toString(privateData->getId());
             return converter.toJSValueRef(strId);
         } else {
@@ -250,18 +258,18 @@ JSValueRef JSAlarmRelative::getId(JSContextRef ctx,
 }
 
 JSValueRef JSAlarmRelative::getDelay(JSContextRef ctx,
-               JSObjectRef object,
-               JSStringRef propertyName,
-               JSValueRef* exception)
+        JSObjectRef object,
+        JSStringRef propertyName,
+        JSValueRef* exception)
 {
     long delay;
 
-       try {
+    try {
         AlarmRelativePtr privateData = getPrivData(object);
-               if (!privateData) {
-                       throw TypeMismatchException("Private object is null");
-           }
-               
+        if (!privateData) {
+            throw TypeMismatchException("Private object is null");
+        }
+        
         delay = privateData->getDelay();
         LoggerI("JSAlarmRelative delay = " << delay);
         return DeviceAPI::Common::JSUtil::toJSValueRef(ctx, delay);
@@ -274,31 +282,31 @@ JSValueRef JSAlarmRelative::getDelay(JSContextRef ctx,
 }
 
 JSValueRef JSAlarmRelative::getPeriod(JSContextRef ctx,
-               JSObjectRef object,
-               JSStringRef propertyName,
-               JSValueRef* exception)
+        JSObjectRef object,
+        JSStringRef propertyName,
+        JSValueRef* exception)
 {
     long period =0;
 
-       try {
+    try {
         AlarmRelativePtr privateData = getPrivData(object);
-               if (!privateData) {
-                       throw TypeMismatchException("Private object is null");
-           }
-               
+        if (!privateData) {
+            throw TypeMismatchException("Private object is null");
+        }
+        
         period = privateData->getPeriod();
         LoggerI("JSAlarmRelative interval = " << period);
          if(period == -1) {
             return JSValueMakeNull(ctx);
         } else {
-               return DeviceAPI::Common::JSUtil::toJSValueRef(ctx, period);
+            return DeviceAPI::Common::JSUtil::toJSValueRef(ctx, period);
         }
-       } catch (const BasePlatformException &err) {
-               return JSWebAPIErrorFactory::postException(ctx, exception, err);
-       } catch (...) {
-               DeviceAPI::Common::TypeMismatchException err("TypeMismatchException occured");
-               return JSWebAPIErrorFactory::postException(ctx, exception, err);
-       }
+    } catch (const BasePlatformException &err) {
+        return JSWebAPIErrorFactory::postException(ctx, exception, err);
+    } catch (...) {
+        DeviceAPI::Common::TypeMismatchException err("TypeMismatchException occured");
+        return JSWebAPIErrorFactory::postException(ctx, exception, err);
+    }
 }
 
 } // Alarm
index b42af96..5401dc0 100644 (file)
@@ -21,6 +21,7 @@
 
 // To get package id from appId
 #include <package_manager.h>
+#include <TimeTracer.h>
 
 #include <Logger.h>
 
@@ -258,12 +259,16 @@ void AppManagerWrapper::registerAppListChangedCallbacks()
                return;
        }
 
+       TIME_TRACER_ITEM_BEGIN("(addAppInfoEventListener)pkgmgr_client_new", 0);
        m_manager_handle = pkgmgr_client_new(PC_LISTENING);
+       TIME_TRACER_ITEM_END("(addAppInfoEventListener)pkgmgr_client_new", 0);
        if (m_manager_handle == NULL) {
                ThrowMsg(InvalidArgumentException, "Error while registering listener to app_manager");
        }
 
+       TIME_TRACER_ITEM_BEGIN("(addAppInfoEventListener)pkgmgr_client_listen_status", 0);
        pkgmgr_client_listen_status(m_manager_handle, app_list_changed_cb_broker, this);
+       TIME_TRACER_ITEM_END("(addAppInfoEventListener)pkgmgr_client_listen_status", 0);
 }
 
 void AppManagerWrapper::unregisterAppListChangedCallbacks()
@@ -273,7 +278,9 @@ void AppManagerWrapper::unregisterAppListChangedCallbacks()
                return;
        }
 
+       TIME_TRACER_ITEM_BEGIN("(removeAppInfoEventListener)pkgmgr_client_free", 0);
        pkgmgr_client_free(m_manager_handle);
+       TIME_TRACER_ITEM_END("(removeAppInfoEventListener)pkgmgr_client_free", 0);
        m_manager_handle = NULL;
 }
 
index 7269852..be98d0d 100644 (file)
@@ -61,7 +61,7 @@ void ApplicationController::OnAnswerReceived(const EventApplicationLaunchPtr &ev
 void ApplicationController::OnAnswerReceived(const EventApplicationKillPtr &event)
 {
        ApplicationAsyncAnswerHandler::kill(event);
-       TIME_TRACER_ITEM_END("kill(async)", 0);
+       //TIME_TRACER_ITEM_END("kill(async)", 0);
 }
 
 void ApplicationController::OnAnswerReceived(const EventApplicationLaunchAppControlPtr &event)
index 86c7982..033ef63 100755 (executable)
@@ -27,9 +27,9 @@
 #include "ApplicationControlData.h"
 #include "ApplicationControl.h"
 #include "ApplicationCert.h"
+#include "Application.h"
 #include <Export.h>
 
-
 namespace DeviceAPI {
 namespace Application {
 class DLL_EXPORT ApplicationConverter : public WrtDeviceApis::CommonsJavaScript::Converter
index 98bb405..231e45e 100644 (file)
@@ -50,6 +50,8 @@
 // To get ppid
 #include <unistd.h>
 
+#include <TimeTracer.h>
+
 #include <Logger.h>
 
 namespace DeviceAPI {
@@ -410,8 +412,7 @@ namespace {
 }
 
 ApplicationManager::ApplicationManager() :
-       m_initialized(false),
-       m_app(NULL)
+       m_initialized(false)
 {
        
 }
@@ -440,15 +441,6 @@ ApplicationManager::~ApplicationManager()
        gLaunchAppControlPendingEventMap.eraseKey(this);
 }
 
-void ApplicationManager::getCurrentApplication(const EventApplicationGetCurrAppPtr& event)
-{
-       if (m_initialized == false) {
-               initialize();
-       }
-
-       EventRequestReceiver<EventApplicationGetCurrApp>::PostRequest(event);
-}
-
 void ApplicationManager::launch(const EventApplicationLaunchPtr& event)
 {
        if (m_initialized == false) {
@@ -498,14 +490,6 @@ void ApplicationManager::getAppsContext(const EventApplicationGetAppsContextPtr&
        EventRequestReceiver<EventApplicationGetAppsContext>::PostRequest(event);
 }
 
-void ApplicationManager::getAppContext(const EventApplicationGetAppContextPtr& event)
-{
-       if (m_initialized == false) {
-               initialize();
-       }
-
-       EventRequestReceiver<EventApplicationGetAppContext>::PostRequest(event);
-}
 
 void ApplicationManager::getAppsInfo(const EventApplicationGetAppsInfoPtr& event)
 {
@@ -516,14 +500,6 @@ void ApplicationManager::getAppsInfo(const EventApplicationGetAppsInfoPtr& event
        EventRequestReceiver<EventApplicationGetAppsInfo>::PostRequest(event);
 }
 
-void ApplicationManager::getAppInfo(const EventApplicationGetAppInfoPtr& event)
-{
-       if (m_initialized == false) {
-               initialize();
-       }
-
-       EventRequestReceiver<EventApplicationGetAppInfo>::PostRequest(event);
-}
 
 void ApplicationManager::addAppInfoEventListener(const EventApplicationAddAppInfoEventListenerPtr& event)
 {
@@ -543,25 +519,6 @@ void ApplicationManager::removeAppInfoEventListener(const EventApplicationRemove
        EventRequestReceiver<EventApplicationRemoveAppInfoEventListener>::PostRequest(event);
 }
 
-void ApplicationManager::getAppCerts(const EventApplicationGetAppCertsPtr& event)
-{
-       if (m_initialized == false) {
-               initialize();
-       }
-
-       EventRequestReceiver<EventApplicationGetAppCerts>::PostRequest(event);
-}
-
-
-void ApplicationManager::getAppSharedURI(const EventApplicationGetAppSharedURIPtr& event)
-{
-       if (m_initialized == false) {
-               initialize();
-       }
-
-       EventRequestReceiver<EventApplicationGetAppSharedURI>::PostRequest(event);
-}
-
 
 void ApplicationManager::invokeManualAnswerLaunchAppControl(service_h request, service_h reply,
                service_result_e result,
@@ -720,50 +677,231 @@ bool ApplicationManager::service_extra_data_callback(service_h service, const ch
 }
 
 
-void ApplicationManager::OnRequestReceived(const EventApplicationGetCurrAppPtr& event)
+ApplicationPtr ApplicationManager::getCurrentApplication()
 {
-       if (m_app != NULL) {
-               LoggerD("CurrentApplicaton Object is already created.");
-               event->setApp(m_app);
-               return;
+       std::string appId = get_current_app_id();
+
+       //ApplicationInformationPtr appinfo(new ApplicationInformation(appId));
+       pkgmgrinfo_appinfo_h handle;
+       TIME_TRACER_ITEM_BEGIN("(getCurrentApplication)pkgmgrinfo_appinfo_get_appinfo", 0);
+       int ret = pkgmgrinfo_appinfo_get_appinfo(appId.c_str(), &handle);
+       TIME_TRACER_ITEM_END("(getCurrentApplication)pkgmgrinfo_appinfo_get_appinfo", 0);
+       if (ret != PMINFO_R_OK) {
+               LoggerE("Fail to get appInfo");
+               ThrowMsg(UnknownException, "pkgmgrinfo_appinfo_get_appinfo error : unknown error");
        }
+       ApplicationInformationPtr appInfo = create_app_info(handle);
+       pkgmgrinfo_appinfo_destroy_appinfo(handle);
 
-       Try
+
+       ApplicationPtr app(new Application());
+       app->setAppInfo(appInfo);
+
+       LoggerD("set appinfo to application");
        {
-               std::string appId = get_current_app_id();
+               //int pid = getpid();
+               int pid = getppid();
+               std::stringstream sstr;
+               sstr << pid;
+               app->setContextId(sstr.str());
+       }
 
-               //ApplicationInformationPtr appinfo(new ApplicationInformation(appId));
-               pkgmgrinfo_appinfo_h handle;
-               int ret = pkgmgrinfo_appinfo_get_appinfo(appId.c_str(), &handle);
-               if (ret != PMINFO_R_OK) {
-                       LoggerE("Fail to get appInfo");
-                       return;
-               } 
-               ApplicationInformationPtr appInfo = create_app_info(handle);
-               pkgmgrinfo_appinfo_destroy_appinfo(handle);
+       return app;
+}
 
 
-               ApplicationPtr app(new Application());
-               app->setAppInfo(appInfo);
+ApplicationContextPtr ApplicationManager::getAppContext(const std::string id)
+{
+       int ret = 0;
+
+       std::string contextId = id;
+       int pid;
 
-               LoggerD("set appinfo to application");
+       if (contextId.empty())
+       {
+               //pid = getpid();
+               pid = getppid();
+
+               std::stringstream sstr;
+               sstr << pid;
+               contextId = sstr.str();
+       }
+       else
+       {
+               std::stringstream(contextId) >> pid;
+               if (pid <= 0)
                {
-                       //int pid = getpid();
-                       int pid = getppid();
-                       std::stringstream sstr;
-                       sstr << pid;
-                       app->setContextId(sstr.str());
+                       LoggerE("Given contextId is wrong");
+                       ThrowMsg(NotFoundException, "Given contextId is wrong");
                }
+       }
+
+       char *app_id = NULL;
 
-               event->setApp(app);
-               m_app = app;
+       TIME_TRACER_ITEM_BEGIN("(getAppContext)app_manager_get_app_id", 0);
+       ret = app_manager_get_app_id(pid, &app_id);
+       TIME_TRACER_ITEM_END("(getAppContext)app_manager_get_app_id", 0);
+       if(ret != APP_MANAGER_ERROR_NONE)
+       {
+               if(app_id)
+                       free(app_id);
+
+               switch(ret)
+               {
+               case APP_MANAGER_ERROR_NO_SUCH_APP:
+               case APP_MANAGER_ERROR_INVALID_PARAMETER:
+                       LoggerE("app_manager_get_app_id error : no such app");
+                       ThrowMsg(NotFoundException, "app_manager_get_app_id error : no such app");
+               default:
+                       LoggerE("app_manager_get_app_id error (" << ret << ")");
+                       ThrowMsg(UnknownException, "app_manager_get_app_id error : unknown error");
+               }
        }
-       Catch (WrtDeviceApis::Commons::Exception)
+
+       ApplicationContextPtr appContext(new ApplicationContext());
+       appContext->setAppId(app_id);
+       appContext->setContextId(contextId);
+
+       if(app_id)
+               free(app_id);   
+
+       return appContext;
+}
+
+
+ApplicationInformationPtr ApplicationManager::getAppInfo(const std::string id)
+{
+       std::string appId = id;
+       // in case of no argument, get application information of current.
+       if (appId.empty())
        {
-               LoggerE("Error on getAppInfo : " << _rethrown_exception.GetMessage());
-               event->setExceptionCode(Commons::ExceptionCodes::PlatformException);
+               appId = get_current_app_id();
        }
 
+       pkgmgrinfo_appinfo_h handle;
+       TIME_TRACER_ITEM_BEGIN("(getAppInfo)pkgmgrinfo_appinfo_get_appinfo", 0);
+       int ret = pkgmgrinfo_appinfo_get_appinfo(appId.c_str(), &handle);
+       TIME_TRACER_ITEM_END("(getAppInfo)pkgmgrinfo_appinfo_get_appinfo", 0);
+       if (ret != PMINFO_R_OK) {
+               ThrowMsg(NotFoundException, "Can not get appinfo");
+       }
+
+       ApplicationInformationPtr appInfo = create_app_info(handle);
+
+       pkgmgrinfo_appinfo_destroy_appinfo(handle);
+
+       return appInfo;
+}
+
+
+ApplicationCertArrayPtr ApplicationManager::getAppCerts(const std::string id)
+{
+       std::string appId = id;
+
+       // in case of no argument, get application information of current.
+       if (appId.empty())
+       {
+               appId = get_current_app_id();
+       }
+
+       TIME_TRACER_ITEM_BEGIN("(getAppCerts)getPackageByAppId", 0);
+       char* package = getPackageByAppId(appId.c_str());
+       TIME_TRACER_ITEM_END("(getAppCerts)getPackageByAppId", 0);
+       if (package == NULL)
+       {
+               LoggerE("Can not get package");
+               ThrowMsg(NotFoundException, "Can not get package");
+       }
+
+       package_info_h pkg_info;
+       int result = 0;
+
+       TIME_TRACER_ITEM_BEGIN("(getAppCerts)package_manager_get_package_info", 0);
+       result = package_manager_get_package_info(package, &pkg_info);
+       TIME_TRACER_ITEM_END("(getAppCerts)package_manager_get_package_info", 0);
+       if (result != PACKAGE_MANAGER_ERROR_NONE)
+       {
+               ThrowMsg(UnknownException, "Can not get package info");
+       }       
+
+       ApplicationCertArrayPtr certArray(new ApplicationCertArray());
+
+       TIME_TRACER_ITEM_BEGIN("(getAppCerts)package_info_foreach_cert_info", 0);
+       result = package_info_foreach_cert_info(pkg_info, package_cert_cb, (void*)certArray.Get());
+       TIME_TRACER_ITEM_END("(getAppCerts)package_info_foreach_cert_info", 0);
+       if (result != PACKAGE_MANAGER_ERROR_NONE)
+       {
+               ThrowMsg(UnknownException, "Can not get package cert info");
+       }
+
+       return certArray;
+}
+
+#define TIZENAPIS_APP_FILE_SCHEME              "file://"
+#define TIZENAPIS_APP_SLASH                            "/"
+#define TIZENAPIS_APP_SHARED                   "shared"
+
+
+std::string ApplicationManager::getAppSharedURI(const std::string id)
+{
+       std::string appId;
+
+       if (id.empty()) {
+               appId = get_current_app_id();
+       } else {
+               appId = id;
+       }
+
+       app_info_h handle;
+       char* pkg_name = NULL;
+       TIME_TRACER_ITEM_BEGIN("(getAppSharedURI)app_manager_get_app_info", 0);
+       int ret = app_manager_get_app_info(appId.c_str(), &handle);
+       TIME_TRACER_ITEM_END("(getAppSharedURI)app_manager_get_app_info", 0);
+       if (ret != APP_ERROR_NONE) {
+               LoggerD("Fail to get appinfo");
+               //throw NotFoundException("Fail to get appinfo");
+               ThrowMsg(NotFoundException, "Fail to get appinfo");
+       }
+
+       TIME_TRACER_ITEM_BEGIN("(getAppSharedURI)app_info_get_package", 0);
+       ret = app_info_get_package(handle, &pkg_name);
+       TIME_TRACER_ITEM_END("(getAppSharedURI)app_info_get_package", 0);
+       if ((ret != APP_ERROR_NONE) || (pkg_name == NULL)) {
+               LoggerD("Fail to get pkg_name");
+               //throw NotFoundException("Fail to get pkg_name");
+               ThrowMsg(NotFoundException, "Fail to get pkg_name");
+       }
+
+       app_info_destroy(handle);
+
+       pkgmgrinfo_pkginfo_h pkginfo_h;
+       char* root_path = NULL;
+
+       TIME_TRACER_ITEM_BEGIN("(getAppSharedURI)pkgmgrinfo_pkginfo_get_pkginfo", 0);
+       ret = pkgmgrinfo_pkginfo_get_pkginfo(pkg_name, &pkginfo_h);
+       TIME_TRACER_ITEM_END("(getAppSharedURI)pkgmgrinfo_pkginfo_get_pkginfo", 0);
+       if (ret != PMINFO_R_OK) {
+               free(pkg_name);
+               //throw UnknownException("Fail to get pkginfo");
+               ThrowMsg(UnknownException, "Fail to get pkginfo");
+       }
+
+       TIME_TRACER_ITEM_BEGIN("(getAppSharedURI)pkgmgrinfo_pkginfo_get_root_path", 0);
+       ret = pkgmgrinfo_pkginfo_get_root_path(pkginfo_h, &root_path);
+       TIME_TRACER_ITEM_END("(getAppSharedURI)pkgmgrinfo_pkginfo_get_root_path", 0);
+       if ((ret != PMINFO_R_OK) || (root_path == NULL)) {
+               LoggerE("Fail to get root path");
+               free(pkg_name);
+               //throw UnknownException("Fail to get rotpath");
+               ThrowMsg(UnknownException, "Fail to get rotpath");
+       }
+
+       std::string sharedURI = TIZENAPIS_APP_FILE_SCHEME + std::string(root_path) + TIZENAPIS_APP_SLASH + TIZENAPIS_APP_SHARED;
+       free(pkg_name);
+
+       pkgmgrinfo_pkginfo_destroy_pkginfo(pkginfo_h);
+
+       return sharedURI;
 }
 
 
@@ -1228,74 +1366,7 @@ void ApplicationManager::OnRequestReceived(const EventApplicationGetAppsContextP
        }
 }
 
-void ApplicationManager::OnRequestReceived(const EventApplicationGetAppContextPtr& event)
-{
-       Try
-       {
-               int ret = 0;
-
-               std::string contextId = event->getAppContextId();
-               int pid;
-
-               if (contextId.empty())
-               {
-                       //pid = getpid();
-                       pid = getppid();
-
-                       std::stringstream sstr;
-                       sstr << pid;
-                       contextId = sstr.str();
-               }
-               else
-               {
-                       std::stringstream(contextId) >> pid;
-                       if (pid <= 0)
-                       {
-                               LoggerE("Given contextId is wrong");
-                               event->setExceptionCode(Commons::ExceptionCodes::NotFoundException);
-                               return;
-                       }
-               }
 
-               char *app_id = NULL;
-
-               ret = app_manager_get_app_id(pid, &app_id);
-               if(ret != APP_MANAGER_ERROR_NONE)
-               {
-                       switch(ret)
-                       {
-                       case APP_MANAGER_ERROR_NO_SUCH_APP:
-                       case APP_MANAGER_ERROR_INVALID_PARAMETER:
-                               LoggerE("app_manager_get_app_id error : no such app");
-                               event->setExceptionCode(Commons::ExceptionCodes::NotFoundException);
-                               break;
-                       default:
-                               LoggerE("app_manager_get_app_id error (" << ret << ")");
-                               event->setExceptionCode(Commons::ExceptionCodes::PlatformException);
-                               break;
-                       }
-
-                       if(app_id)
-                               free(app_id);
-
-                       return;
-               }
-
-               ApplicationContextPtr appContext(new ApplicationContext());
-               appContext->setAppId(app_id);
-               appContext->setContextId(contextId);
-
-               event->setAppContext(appContext);
-
-               if(app_id)
-                       free(app_id);
-       }
-       Catch (WrtDeviceApis::Commons::Exception)
-       {
-               LoggerE("Error on getAppContext : " << _rethrown_exception.GetMessage());
-               event->setExceptionCode(Commons::ExceptionCodes::PlatformException);
-       }
-}
 
 void ApplicationManager::OnRequestReceived(const EventApplicationGetAppsInfoPtr& event)
 {
@@ -1316,34 +1387,6 @@ void ApplicationManager::OnRequestReceived(const EventApplicationGetAppsInfoPtr&
        }
 }
 
-void ApplicationManager::OnRequestReceived(const EventApplicationGetAppInfoPtr& event)
-{
-       Try
-       {
-               std::string appId = event->getAppId();
-               // in case of no argument, get application information of current.
-               if (appId.empty())
-               {
-                       appId = get_current_app_id();
-               }
-
-               pkgmgrinfo_appinfo_h handle;
-               int ret = pkgmgrinfo_appinfo_get_appinfo(appId.c_str(), &handle);
-               if (ret != PMINFO_R_OK) {
-                       event->setExceptionCode(Commons::ExceptionCodes::NotFoundException);
-                       return;
-               }
-
-               ApplicationInformationPtr appInfo = create_app_info(handle);
-               event->setAppInfo(appInfo);
-               pkgmgrinfo_appinfo_destroy_appinfo(handle);             
-       }
-       Catch (WrtDeviceApis::Commons::Exception)
-       {
-               LoggerE("Error on getAppInfo : " << _rethrown_exception.GetMessage());
-               event->setExceptionCode(Commons::ExceptionCodes::PlatformException);
-       }
-}
 
 void ApplicationManager::OnRequestReceived(const EventApplicationAddAppInfoEventListenerPtr& event)
 {
@@ -1410,114 +1453,6 @@ void ApplicationManager::OnRequestReceived(const EventApplicationRemoveAppInfoEv
 }
 
 
-void ApplicationManager::OnRequestReceived(const EventApplicationGetAppCertsPtr& event)
-{
-       Try
-       {
-               std::string appId = event->getAppId();
-
-               // in case of no argument, get application information of current.
-               if (appId.empty())
-               {
-                       appId = get_current_app_id();
-               }
-
-               char* package = getPackageByAppId(appId.c_str());
-               if (package == NULL)
-               {
-                       LoggerE("Can not get package");
-                       event->setExceptionCode(Commons::ExceptionCodes::NotFoundException);
-                       return;
-               }
-               
-               package_info_h pkg_info;
-               int result = 0;
-               
-               result = package_manager_get_package_info(package, &pkg_info);
-               if (result != PACKAGE_MANAGER_ERROR_NONE)
-               {
-                       event->setExceptionCode(Commons::ExceptionCodes::PlatformException);
-                       return;
-               }       
-
-               ApplicationCertArrayPtr certArray(new ApplicationCertArray());
-
-               result = package_info_foreach_cert_info(pkg_info, package_cert_cb, (void*)certArray.Get());
-               if (result != PACKAGE_MANAGER_ERROR_NONE)
-               {
-                       event->setExceptionCode(Commons::ExceptionCodes::PlatformException);
-                       return;
-               }
-
-               event->setAppCerts(certArray);
-       }
-       Catch (WrtDeviceApis::Commons::Exception)
-       {
-               LoggerE("Error on getAppInfo : " << _rethrown_exception.GetMessage());
-               event->setExceptionCode(Commons::ExceptionCodes::PlatformException);
-       }
-}
-
-#define TIZENAPIS_APP_FILE_SCHEME              "file://"
-#define TIZENAPIS_APP_SLASH                            "/"
-#define TIZENAPIS_APP_SHARED                   "shared"
-
-void ApplicationManager::OnRequestReceived(const EventApplicationGetAppSharedURIPtr& event)
-{
-       std::string id = event->getAppId();
-       std::string appId;
-
-       if (id.empty()) {
-               appId = get_current_app_id();
-       } else {
-               appId = id;
-       }
-
-       app_info_h handle;
-       char* pkg_name = NULL;
-       int ret = app_manager_get_app_info(appId.c_str(), &handle);
-       if (ret != APP_ERROR_NONE) {
-               LoggerD("Fail to get appinfo");
-               event->setExceptionCode(Commons::ExceptionCodes::NotFoundException);
-               return;
-       }
-
-       ret = app_info_get_package(handle, &pkg_name);
-       if ((ret != APP_ERROR_NONE) || (pkg_name == NULL)) {
-               LoggerD("Fail to get pkg_name");
-               event->setExceptionCode(Commons::ExceptionCodes::NotFoundException);
-               return;
-       }
-
-       app_info_destroy(handle);
-
-       pkgmgrinfo_pkginfo_h pkginfo_h;
-       char* root_path = NULL;
-
-       ret = pkgmgrinfo_pkginfo_get_pkginfo(pkg_name, &pkginfo_h);
-       if (ret != PMINFO_R_OK) {
-               free(pkg_name);
-               event->setExceptionCode(Commons::ExceptionCodes::PlatformException);
-               return;
-       }
-
-       ret = pkgmgrinfo_pkginfo_get_root_path(pkginfo_h, &root_path);
-       if ((ret != PMINFO_R_OK) || (root_path == NULL)) {
-               LoggerE("Fail to get root path");
-               free(pkg_name);
-               event->setExceptionCode(Commons::ExceptionCodes::PlatformException);
-               return;
-       }
-
-       std::string sharedURI = TIZENAPIS_APP_FILE_SCHEME + std::string(root_path) + TIZENAPIS_APP_SLASH + TIZENAPIS_APP_SHARED;
-       free(pkg_name);
-
-       pkgmgrinfo_pkginfo_destroy_pkginfo(pkginfo_h);
-
-       event->setSharedURI(sharedURI);
-}
-
-
 
 void ApplicationManager::onAppManagerEventInstalled(const char *appId)
 {
index 65c080c..8640820 100644 (file)
 #include "IApplicationManager.h"
 #include "ApplicationFactory.h"
 
+#include "Application.h"
+#include "ApplicationContext.h"
+#include "ApplicationInformation.h"
+#include "ApplicationCert.h"
+
 //#include <app_manager.h>
 #include <app_service.h>
 
@@ -40,42 +45,37 @@ class ApplicationManager: public IApplicationManager, public IAppManagerAppListC
 public:
        ApplicationManager();
        virtual ~ApplicationManager();
-       virtual void getCurrentApplication(const EventApplicationGetCurrAppPtr& event);
        virtual void launch(const EventApplicationLaunchPtr& event);
        virtual void kill(const EventApplicationKillPtr& event);
        virtual void launchAppControl(const EventApplicationLaunchAppControlPtr& event);
        virtual void findAppControl(const EventApplicationFindAppControlPtr& event);
        virtual void getAppsContext(const EventApplicationGetAppsContextPtr& event);
-       virtual void getAppContext(const EventApplicationGetAppContextPtr& event);
        virtual void getAppsInfo(const EventApplicationGetAppsInfoPtr& event);
-       virtual void getAppInfo(const EventApplicationGetAppInfoPtr& event);
        virtual void addAppInfoEventListener(const EventApplicationAddAppInfoEventListenerPtr& event);
        virtual void removeAppInfoEventListener(const EventApplicationRemoveAppInfoEventListenerPtr& event);
-       virtual void getAppCerts(const EventApplicationGetAppCertsPtr& event);
-       virtual void getAppSharedURI(const EventApplicationGetAppSharedURIPtr& event);
 
        void invokeManualAnswerLaunchAppControl(service_h request, service_h reply, service_result_e result,
                        EventApplicationLaunchAppControlReplyPtr &event);
-       //void InstalledApplicationChanged(app_manger_event_type_e event_type,const char *package);
        void invokeManualAnswerKill(int pid);
 
        static bool service_extra_data_callback(service_h service, const char *key, void* user_data);
 
+       static ApplicationPtr getCurrentApplication();
+       static ApplicationContextPtr getAppContext(const std::string id);
+       static ApplicationInformationPtr getAppInfo(const std::string id);
+       static ApplicationCertArrayPtr getAppCerts(const std::string id);
+       static std::string getAppSharedURI(const std::string appId);
+
 protected:
-       virtual void OnRequestReceived(const EventApplicationGetCurrAppPtr& event);
        virtual void OnRequestReceived(const EventApplicationLaunchPtr& event);
        virtual void OnRequestReceived(const EventApplicationKillPtr& event);
        virtual void OnRequestReceived(const EventApplicationLaunchAppControlPtr& event);
        virtual void OnRequestReceived(const EventApplicationLaunchAppControlReplyPtr& event);
        virtual void OnRequestReceived(const EventApplicationFindAppControlPtr& event);
        virtual void OnRequestReceived(const EventApplicationGetAppsContextPtr& event);
-       virtual void OnRequestReceived(const EventApplicationGetAppContextPtr& event);
        virtual void OnRequestReceived(const EventApplicationGetAppsInfoPtr& event);
-       virtual void OnRequestReceived(const EventApplicationGetAppInfoPtr& event);
        virtual void OnRequestReceived(const EventApplicationAddAppInfoEventListenerPtr& event);
        virtual void OnRequestReceived(const EventApplicationRemoveAppInfoEventListenerPtr& event);
-       virtual void OnRequestReceived(const EventApplicationGetAppCertsPtr& event);
-       virtual void OnRequestReceived(const EventApplicationGetAppSharedURIPtr& event);
 
        // inherited from IAppManagerAppListChangedCallbacks
        virtual void onAppManagerEventInstalled(const char *appId);
@@ -97,7 +97,6 @@ private:
        EventApplicationAppInfoEventListenerEmitters m_installedApplicationsEmitters;
        WatchIdMap      m_watchIdMap;
 
-       ApplicationPtr m_app;
 };
 
 class LaunchAppControlPendingEvent
index 2f15c1c..a522a50 100644 (file)
@@ -23,20 +23,15 @@ namespace Application{
 using namespace WrtDeviceApis::Commons;
 
 IApplicationManager::IApplicationManager() :
-               EventRequestReceiver<EventApplicationGetCurrApp>(ThreadEnum::APPLICATION_THREAD),
                EventRequestReceiver<EventApplicationLaunch>(ThreadEnum::APPLICATION_THREAD),
                EventRequestReceiver<EventApplicationKill>(ThreadEnum::APPLICATION_THREAD),
                EventRequestReceiver<EventApplicationLaunchAppControl>(ThreadEnum::APPLICATION_THREAD),
                EventRequestReceiver<EventApplicationLaunchAppControlReply>(ThreadEnum::APPLICATION_THREAD),
                EventRequestReceiver<EventApplicationFindAppControl>(ThreadEnum::APPLICATION_THREAD),
                EventRequestReceiver<EventApplicationGetAppsContext>(ThreadEnum::APPLICATION_THREAD),
-               EventRequestReceiver<EventApplicationGetAppContext>(ThreadEnum::APPLICATION_THREAD),
                EventRequestReceiver<EventApplicationGetAppsInfo>(ThreadEnum::APPLICATION_THREAD),
-               EventRequestReceiver<EventApplicationGetAppInfo>(ThreadEnum::APPLICATION_THREAD),
                EventRequestReceiver<EventApplicationAddAppInfoEventListener>(ThreadEnum::APPLICATION_THREAD),
-               EventRequestReceiver<EventApplicationRemoveAppInfoEventListener>(ThreadEnum::APPLICATION_THREAD),
-               EventRequestReceiver<EventApplicationGetAppCerts>(ThreadEnum::APPLICATION_THREAD),
-               EventRequestReceiver<EventApplicationGetAppSharedURI>(ThreadEnum::APPLICATION_THREAD)
+               EventRequestReceiver<EventApplicationRemoveAppInfoEventListener>(ThreadEnum::APPLICATION_THREAD)
 {
 }
 
index 8939313..4cc0523 100644 (file)
 
 #include <dpl/shared_ptr.h>
 #include <Commons/ThreadPool.h>
-#include "EventApplicationGetCurrApp.h"
 #include "EventApplicationLaunch.h"
 #include "EventApplicationKill.h"
 #include "EventApplicationLaunchAppControl.h"
 #include "EventApplicationFindAppControl.h"
 #include "EventApplicationGetAppsContext.h"
-#include "EventApplicationGetAppContext.h"
 #include "EventApplicationGetAppsInfo.h"
-#include "EventApplicationGetAppInfo.h"
 #include "EventApplicationAddAppInfoEventListener.h"
 #include "EventApplicationRemoveAppInfoEventListener.h"
-#include "EventApplicationGetAppCerts.h"
-#include "EventApplicationGetAppSharedURI.h"
 
 namespace DeviceAPI {
 namespace Application {
 
 class IApplicationManager :
-       public WrtDeviceApis::Commons::EventRequestReceiver<EventApplicationGetCurrApp>,
        public WrtDeviceApis::Commons::EventRequestReceiver<EventApplicationLaunch>,
        public WrtDeviceApis::Commons::EventRequestReceiver<EventApplicationKill>,
        public WrtDeviceApis::Commons::EventRequestReceiver<EventApplicationLaunchAppControl>,
        public WrtDeviceApis::Commons::EventRequestReceiver<EventApplicationLaunchAppControlReply>,
        public WrtDeviceApis::Commons::EventRequestReceiver<EventApplicationFindAppControl>,
        public WrtDeviceApis::Commons::EventRequestReceiver<EventApplicationGetAppsContext>,
-       public WrtDeviceApis::Commons::EventRequestReceiver<EventApplicationGetAppContext>,
        public WrtDeviceApis::Commons::EventRequestReceiver<EventApplicationGetAppsInfo>,
-       public WrtDeviceApis::Commons::EventRequestReceiver<EventApplicationGetAppInfo>,
        public WrtDeviceApis::Commons::EventRequestReceiver<EventApplicationAddAppInfoEventListener>,
-       public WrtDeviceApis::Commons::EventRequestReceiver<EventApplicationRemoveAppInfoEventListener>,
-       public WrtDeviceApis::Commons::EventRequestReceiver<EventApplicationGetAppCerts>,
-       public WrtDeviceApis::Commons::EventRequestReceiver<EventApplicationGetAppSharedURI>
+       public WrtDeviceApis::Commons::EventRequestReceiver<EventApplicationRemoveAppInfoEventListener>
 {
 public:
        virtual ~IApplicationManager();
-       virtual void getCurrentApplication(const EventApplicationGetCurrAppPtr& event) = 0;
        virtual void launch(const EventApplicationLaunchPtr& event) = 0;
        virtual void kill(const EventApplicationKillPtr& event) = 0;
        virtual void launchAppControl(const EventApplicationLaunchAppControlPtr& event) = 0;
        virtual void findAppControl(const EventApplicationFindAppControlPtr& event) = 0;
        virtual void getAppsContext(const EventApplicationGetAppsContextPtr& event) = 0;
-       virtual void getAppContext(const EventApplicationGetAppContextPtr& event) = 0;
        virtual void getAppsInfo(const EventApplicationGetAppsInfoPtr& event) = 0;
-       virtual void getAppInfo(const EventApplicationGetAppInfoPtr& event) = 0;
        virtual void addAppInfoEventListener(const EventApplicationAddAppInfoEventListenerPtr& event) = 0;
        virtual void removeAppInfoEventListener(const EventApplicationRemoveAppInfoEventListenerPtr& event) = 0;
-       virtual void getAppCerts(const EventApplicationGetAppCertsPtr& event) = 0;
-       virtual void getAppSharedURI(const EventApplicationGetAppSharedURIPtr& event) = 0;
 
 protected:
        IApplicationManager();
 
-       virtual void OnRequestReceived(const EventApplicationGetCurrAppPtr& event) = 0;
        virtual void OnRequestReceived(const EventApplicationLaunchPtr& event) = 0;
        virtual void OnRequestReceived(const EventApplicationKillPtr& event) = 0;
        virtual void OnRequestReceived(const EventApplicationLaunchAppControlPtr& event) = 0;
        virtual void OnRequestReceived(const EventApplicationLaunchAppControlReplyPtr& event) = 0;
        virtual void OnRequestReceived(const EventApplicationFindAppControlPtr& event) = 0;
        virtual void OnRequestReceived(const EventApplicationGetAppsContextPtr& event) = 0;
-       virtual void OnRequestReceived(const EventApplicationGetAppContextPtr& event) = 0;
        virtual void OnRequestReceived(const EventApplicationGetAppsInfoPtr& event) = 0;
-       virtual void OnRequestReceived(const EventApplicationGetAppInfoPtr& event) = 0;
        virtual void OnRequestReceived(const EventApplicationAddAppInfoEventListenerPtr& event) = 0;
        virtual void OnRequestReceived(const EventApplicationRemoveAppInfoEventListenerPtr& event) = 0;
-       virtual void OnRequestReceived(const EventApplicationGetAppCertsPtr& event) = 0;
-       virtual void OnRequestReceived(const EventApplicationGetAppSharedURIPtr& event) = 0;
  };
 
 typedef DPL::SharedPtr<IApplicationManager> IApplicationManagerPtr;
index 9171e37..8d3138c 100644 (file)
@@ -46,6 +46,7 @@
 #include "ApplicationInformationEventPrivateData.h"
 #include "JSApplicationEventCallbackManager.h"
 #include "JSApplication.h"
+#include "ApplicationManager.h"
 
 #include <TimeTracer.h>
 #include <Export.h>
@@ -153,28 +154,14 @@ JSValueRef JSApplicationManager::getCurrentApplication(JSContextRef context,
        JSValueRef* exception) 
 {
        TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0);
-       IApplicationManagerPtr appmgr;
-       ApplicationController *controller;
 
        try {
-               controller = static_cast<ApplicationController*>(JSObjectGetPrivate(thisObject));
-               if (!controller) {
-                       throw TypeMismatchException("No private object.");
-               }
-               appmgr = controller->getObject();
-
-       EventApplicationGetCurrAppPtr event(new EventApplicationGetCurrApp());
-       ApplicationConverterFactory::ConverterType converter = ApplicationConverterFactory::getConverter(context);
-
-               event->setForSynchronousCall();
-               appmgr->getCurrentApplication(event);
-               
-               if (event->getExceptionCode() != WrtDeviceApis::Commons::ExceptionCodes::None) {
-                       throw UnknownException("Unknown exception occured");
-               }
+               ApplicationPtr result = ApplicationManager::getCurrentApplication();
 
+               ApplicationConverterFactory::ConverterType converter = ApplicationConverterFactory::getConverter(context);
                TIME_TRACER_ITEM_END(__FUNCTION__, 0);
-               return JSApplication::makeObject(context, event->getApp()); 
+               return JSApplication::makeObject(context, result);
+
        } catch (...) {
                DeviceAPI::Common::UnknownException err("Unknown Error in ApplicationManager.getCurrentApplication().");
                return JSWebAPIErrorFactory::postException(context, exception, err);
@@ -182,7 +169,6 @@ JSValueRef JSApplicationManager::getCurrentApplication(JSContextRef context,
 }
 
 
-
 JSValueRef JSApplicationManager::launch(JSContextRef context, 
        JSObjectRef object, 
        JSObjectRef thisObject, 
@@ -192,9 +178,11 @@ JSValueRef JSApplicationManager::launch(JSContextRef context,
 {
        TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0);
        TIME_TRACER_ITEM_BEGIN("launch(async)", 0);
-       
+
+       TIME_TRACER_ITEM_BEGIN("launch(ACE)", 0);
        AceSecurityStatus status = APPLICATION_CHECK_ACCESS(APPLICATION_FUNCTION_API_LAUNCH);
        TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+       TIME_TRACER_ITEM_END("launch(ACE)", 0);
 
        try {
                IApplicationManagerPtr appmgr;
@@ -255,8 +243,10 @@ JSValueRef JSApplicationManager::kill(JSContextRef context,
        TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0);
        TIME_TRACER_ITEM_BEGIN("kill(async)", 0);
 
+       TIME_TRACER_ITEM_BEGIN("kill(ACE)", 0);
        AceSecurityStatus status = APPLICATION_CHECK_ACCESS(APPLICATION_FUNCTION_API_KILL);
        TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+       TIME_TRACER_ITEM_END("kill(ACE)", 0);
 
        try {
                IApplicationManagerPtr appmgr;
@@ -272,7 +262,6 @@ JSValueRef JSApplicationManager::kill(JSContextRef context,
 
                EventApplicationKillPtr event(new EventApplicationKill());
                JSCallbackManagerPtr callbackManager = JSCallbackManager::createObject(gContext);
-
         ArgumentValidator validator(context, argumentCount, arguments);
 
         // contextId
@@ -350,8 +339,10 @@ JSValueRef JSApplicationManager::launchAppControl(JSContextRef context,
        TIME_TRACER_ITEM_BEGIN("launchAppControl(async)", 0);
        TIME_TRACER_ITEM_BEGIN("launchAppControlReply(async)", 0);
 
+       TIME_TRACER_ITEM_BEGIN("launchAppControl(ACE)", 0);
        AceSecurityStatus status = APPLICATION_CHECK_ACCESS(APPLICATION_FUNCTION_API_LAUNCH_APP_CONTROL);
-       TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);  
+       TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+       TIME_TRACER_ITEM_END("launchAppControl(ACE)", 0);
 
        try {
                IApplicationManagerPtr appmgr;
@@ -579,38 +570,19 @@ JSValueRef JSApplicationManager::getAppContext(JSContextRef context,
        TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0);
 
        try {
-               IApplicationManagerPtr appmgr;
-               ApplicationController *controller;
-
-               controller = static_cast<ApplicationController*>(JSObjectGetPrivate(thisObject));
-               if (!controller) {
-                       throw TypeMismatchException("No private object.");
-               }
-               appmgr = controller->getObject();
-
-       EventApplicationGetAppContextPtr event(new EventApplicationGetAppContext());
-
                ArgumentValidator validator(context, argumentCount, arguments);
 
-        // contextId
-        std::string contextId = validator.toString(0, true, "");
-               event->setAppContextId(contextId);
-               event->setForSynchronousCall();
-
-               appmgr->getAppContext(event);
-
-               if (event->getExceptionCode() == ExceptionCodes::NotFoundException) {
-                       throw NotFoundException("Cannot found context with given context ID");
-               } else if (event->getExceptionCode() != ExceptionCodes::None) {
-                       throw UnknownException("Unknown exception occured");
-               }
+               ApplicationContextPtr result = ApplicationManager::getAppContext(validator.toString(0, true, ""));
+               ApplicationConverterFactory::ConverterType converter = ApplicationConverterFactory::getConverter(context);
 
-       ApplicationConverterFactory::ConverterType converter = ApplicationConverterFactory::getConverter(context);
                TIME_TRACER_ITEM_END(__FUNCTION__, 0);
-               return converter->toJSValueRefFromApplicationContext(event->getAppContext());
+               return converter->toJSValueRefFromApplicationContext(result);
+
        } catch (const BasePlatformException &err) {
         return JSWebAPIErrorFactory::postException(context, exception, err);
-    } catch (...) {
+    } catch (const WrtDeviceApis::Commons::NotFoundException& ex) {
+          return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::NOT_FOUND_ERROR, ex.GetMessage());
+       } catch (...) {
         DeviceAPI::Common::UnknownException err("Unknown Error in ApplicationManager.getAppContext().");
         return JSWebAPIErrorFactory::postException(context, exception, err);
     }
@@ -683,40 +655,19 @@ JSValueRef JSApplicationManager::getAppInfo(JSContextRef context,
        TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0);
 
        try {
-               IApplicationManagerPtr appmgr;
-               ApplicationController *controller;
-
-               controller = static_cast<ApplicationController*>(JSObjectGetPrivate(thisObject));
-               if (!controller) {
-                       throw TypeMismatchException("No private object.");
-               }
-               appmgr = controller->getObject();
-
-       EventApplicationGetAppInfoPtr event(new EventApplicationGetAppInfo());
-
-        ArgumentValidator validator(context, argumentCount, arguments);
-
-        // id
-        std::string id = validator.toString(0, true, "");
-               event->setAppId(id);
-
-               event->setForSynchronousCall();
+               ArgumentValidator validator(context, argumentCount, arguments);
 
-               appmgr->getAppInfo(event);
-               
-               if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::NotFoundException) {
-                       throw NotFoundException("Given package not found.");
-               } else if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::UnknownException) {
-                       throw UnknownException("Unknown error occurred.");
-               }
+               ApplicationInformationPtr result = ApplicationManager::getAppInfo(validator.toString(0, true, ""));
+               ApplicationConverterFactory::ConverterType converter = ApplicationConverterFactory::getConverter(context);
 
-       ApplicationConverterFactory::ConverterType converter = ApplicationConverterFactory::getConverter(context);
                TIME_TRACER_ITEM_END(__FUNCTION__, 0);
-               return converter->toJSValueRefFromApplicationInformation(event->getAppInfo());
-               
+               return converter->toJSValueRefFromApplicationInformation(result);
+
     } catch (const BasePlatformException &err) {
         return JSWebAPIErrorFactory::postException(context, exception, err);
-    } catch (...) {
+    } catch (const WrtDeviceApis::Commons::NotFoundException& ex) {
+          return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::NOT_FOUND_ERROR, ex.GetMessage());
+       } catch (...) {
         DeviceAPI::Common::UnknownException err("Unknown Error in ApplicationManager.getAppInfo().");
         return JSWebAPIErrorFactory::postException(context, exception, err);
     }
@@ -838,7 +789,7 @@ JSValueRef JSApplicationManager::removeAppInfoEventListener(JSContextRef context
                if (event->getExceptionCode() == ExceptionCodes::NotFoundException) {
                        throw NotFoundException("Watch id not found");
                }
-else if (event->getExceptionCode() != ExceptionCodes::None) {
+               else if (event->getExceptionCode() != ExceptionCodes::None) {
                        throw UnknownException("UnknownException Occured");
                }
 
@@ -863,44 +814,25 @@ JSValueRef JSApplicationManager::getAppCerts(JSContextRef context,
 {
        TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0);
 
+       TIME_TRACER_ITEM_BEGIN("(getAppCerts)ACE", 0);
        AceSecurityStatus status = APPLICATION_CHECK_ACCESS(APPLICATION_FUNCTION_API_GET_APP_CERTS);
        TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+       TIME_TRACER_ITEM_END("(getAppCerts)ACE", 0);
 
        try {
-               IApplicationManagerPtr appmgr;
-               ApplicationController *controller;
-
-               controller = static_cast<ApplicationController*>(JSObjectGetPrivate(thisObject));
-               if (!controller) {
-                       throw TypeMismatchException("No private object.");
-               }
-               appmgr = controller->getObject();
-
-       EventApplicationGetAppCertsPtr event(new EventApplicationGetAppCerts());
-
-        ArgumentValidator validator(context, argumentCount, arguments);
-
-        // id
-        std::string id = validator.toString(0, true, "");
-               event->setAppId(id);
-
-               event->setForSynchronousCall();
+               ArgumentValidator validator(context, argumentCount, arguments);
 
-               appmgr->getAppCerts(event);
+               ApplicationCertArrayPtr result = ApplicationManager::getAppCerts(validator.toString(0, true, ""));
+               ApplicationConverterFactory::ConverterType converter = ApplicationConverterFactory::getConverter(context);
 
-               if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::NotFoundException) {
-                       throw NotFoundException("Given package not found.");
-               } else if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::UnknownException) {
-                       throw UnknownException("Unknown error occurred.");
-               }
-               
-       ApplicationConverterFactory::ConverterType converter = ApplicationConverterFactory::getConverter(context);
                TIME_TRACER_ITEM_END(__FUNCTION__, 0);
-               return converter->toJSValueRefFromeApplicationCerts(event->getAppCerts());
-               
+               return converter->toJSValueRefFromeApplicationCerts(result);
+
     } catch (const BasePlatformException &err) {
         return JSWebAPIErrorFactory::postException(context, exception, err);
-    } catch (...) {
+    } catch (const WrtDeviceApis::Commons::NotFoundException& ex) {
+          return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::NOT_FOUND_ERROR, ex.GetMessage());
+       } catch (...) {
         DeviceAPI::Common::UnknownException err("Unknown Error in ApplicationManager.getAppCerts().");
         return JSWebAPIErrorFactory::postException(context, exception, err);
     }
@@ -917,40 +849,19 @@ JSValueRef JSApplicationManager::getAppSharedURI(JSContextRef context,
        TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0);
 
        try {
-               IApplicationManagerPtr appmgr;
-               ApplicationController *controller;
-
-               controller = static_cast<ApplicationController*>(JSObjectGetPrivate(thisObject));
-               if (!controller) {
-                       throw TypeMismatchException("No private object.");
-               }
-               appmgr = controller->getObject();
-
-       EventApplicationGetAppSharedURIPtr event(new EventApplicationGetAppSharedURI());
-
-        ArgumentValidator validator(context, argumentCount, arguments);
-
-        // id
-        std::string id = validator.toString(0, true, "");
-               event->setAppId(id);
-
-               event->setForSynchronousCall();
+               ArgumentValidator validator(context, argumentCount, arguments);
 
-               appmgr->getAppSharedURI(event);
-               
-               if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::NotFoundException) {
-                       throw NotFoundException("Given package not found.");
-               } else if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::UnknownException) {
-                       throw UnknownException("Unknown error occurred.");
-               }
+               std::string result = ApplicationManager::getAppSharedURI(validator.toString(0, true, ""));
+               ApplicationConverterFactory::ConverterType converter = ApplicationConverterFactory::getConverter(context);
 
-       ApplicationConverterFactory::ConverterType converter = ApplicationConverterFactory::getConverter(context);
                TIME_TRACER_ITEM_END(__FUNCTION__, 0);
-               return converter->toJSValueRef(event->getSharedURI());
+               return converter->toJSValueRef(result);
 
     } catch (const BasePlatformException &err) {
         return JSWebAPIErrorFactory::postException(context, exception, err);
-    } catch (...) {
+    } catch (const WrtDeviceApis::Commons::NotFoundException& ex) {
+          return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::NOT_FOUND_ERROR, ex.GetMessage());
+       } catch (...) {
         DeviceAPI::Common::UnknownException err("Unknown Error in ApplicationManager.getAppSharedURI().");
         return JSWebAPIErrorFactory::postException(context, exception, err);
     }
index 35aae29..6d4a45e 100644 (file)
@@ -30,6 +30,9 @@
 #include "ApplicationUtil.h"
 #include "JSRequestedApplicationControl.h"
 #include <Export.h>
+
+#include <TimeTracer.h>
+
 #include <Logger.h>
 
 using namespace WrtDeviceApis::Commons;
@@ -189,6 +192,7 @@ JSValueRef JSRequestedApplicationControl::replyResult(JSContextRef context,
        const JSValueRef arguments[], 
        JSValueRef* exception) 
 {
+       TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0);
        JSRequestedApplicationControlPriv *priv = static_cast<JSRequestedApplicationControlPriv*>(JSObjectGetPrivate(thisObject));
 
        Try {
@@ -204,6 +208,7 @@ JSValueRef JSRequestedApplicationControl::replyResult(JSContextRef context,
                        resultArray = converter->toApplicationControlDataArray(arguments[0]);
                }
                providerMgr->replyResult(resultArray);
+               TIME_TRACER_ITEM_END(__FUNCTION__, 0);
        } Catch (ConversionException) {
         LoggerE("Exception: "<<_rethrown_exception.GetMessage());
                return JSWebAPIErrorFactory::postException(context, exception,JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage());
@@ -228,6 +233,7 @@ JSValueRef JSRequestedApplicationControl::replyFailure(JSContextRef context,
        const JSValueRef arguments[], 
        JSValueRef* exception) 
 {
+       TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0);
        JSRequestedApplicationControlPriv *priv = static_cast<JSRequestedApplicationControlPriv*>(JSObjectGetPrivate(thisObject));
 
        Try {
@@ -237,6 +243,7 @@ JSValueRef JSRequestedApplicationControl::replyFailure(JSContextRef context,
 
                RequestedApplicationControlPtr providerMgr = priv->getObject();
                providerMgr->replyFailure();
+               TIME_TRACER_ITEM_END(__FUNCTION__, 0);
        } Catch (NotFoundException) {
            LoggerE("Exception: "<<_rethrown_exception.GetMessage());
                return JSWebAPIErrorFactory::postException(context, exception,JSWebAPIErrorFactory::NOT_FOUND_ERROR, _rethrown_exception.GetMessage());
index 11fccb8..5c3c3c9 100644 (file)
@@ -19,6 +19,9 @@
 #include <app_service.h>
 #include <app_manager.h>
 #include "RequestedApplicationControl.h"
+
+#include <TimeTracer.h>
+
 #include <Logger.h>
 
 namespace DeviceAPI {
@@ -94,16 +97,20 @@ void RequestedApplicationControl::replyResult(std::vector<ApplicationControlData
                ThrowMsg(NotFoundException, "Cannot find caller");
        } else {
                bool running = false;
+               TIME_TRACER_ITEM_BEGIN("(replyResult)app_manager_is_running", 0);
                int ret = app_manager_is_running(m_callerAppId.c_str(), &running);
+               TIME_TRACER_ITEM_END("(replyResult)app_manager_is_running", 0);
                if ((ret != APP_MANAGER_ERROR_NONE) || !running) {
                        LoggerE("caller is not running");
                        ThrowMsg(NotFoundException, "Cannot find caller");
                }
        }
 
+       TIME_TRACER_ITEM_BEGIN("(replyResult)service_reply_to_launch_request", 0);
        if (service_reply_to_launch_request(reply, m_appControl->getService_h(), SERVICE_RESULT_SUCCEEDED) != SERVICE_ERROR_NONE) {
                ThrowMsg(NotFoundException, "Cannot find caller");
        }
+       TIME_TRACER_ITEM_END("(replyResult)service_reply_to_launch_request", 0);
 
        service_destroy(reply);
 }
@@ -119,16 +126,20 @@ void RequestedApplicationControl::replyFailure()
                ThrowMsg(NotFoundException, "Cannot find caller");
        } else {
                bool running = false;
+               TIME_TRACER_ITEM_BEGIN("(replyFailure)app_manager_is_running", 0);
                int ret = app_manager_is_running(m_callerAppId.c_str(), &running);
+               TIME_TRACER_ITEM_END("(replyFailure)app_manager_is_running", 0);
                if ((ret != APP_MANAGER_ERROR_NONE) || !running) {
                        LoggerE("caller is not running");
                        ThrowMsg(NotFoundException, "Cannot find caller");
                }
        }
 
+       TIME_TRACER_ITEM_BEGIN("(replyFailure)service_reply_to_launch_request", 0);
        if (service_reply_to_launch_request(reply, m_appControl->getService_h(), SERVICE_RESULT_FAILED) != SERVICE_ERROR_NONE) {
                ThrowMsg(NotFoundException, "Cannot find caller");
        }
+       TIME_TRACER_ITEM_END("(replyFailure)service_reply_to_launch_request", 0);
 
        service_destroy(reply);
 }
index ef41704..ec55b77 100755 (executable)
@@ -31,6 +31,38 @@ class Calendar : public ICalendar
     Calendar();
     virtual ~Calendar();
 
+       virtual void addEvent(IEventAddEventPtr &event) {
+               OnRequestReceived(event);
+       }
+
+       virtual void updateEvent(IEventUpdateEventPtr &event) {
+               OnRequestReceived(event);
+       }
+
+       virtual void deleteEvent(IEventDeleteEventPtr &event) {
+               OnRequestReceived(event);
+       }
+
+       virtual void createEventFromString(IEventCreateEventFromStringPtr &event) {
+               OnRequestReceived(event);
+       }
+
+       virtual void exportEventToString(IEventExportEventToStringPtr &event) {
+               OnRequestReceived(event);
+       }
+
+       virtual void watchChanges(IEventWatchChangesPtr &event) {
+               OnRequestReceived(event);
+       }
+
+       virtual void clearWatch(IEventClearWatchPtr &event) {
+               OnRequestReceived(event);
+       }
+
+       virtual void get(IEventGetPtr &event) {
+               OnRequestReceived(event);
+       }
+
   protected:
     virtual void OnRequestReceived(const IEventAddEventPtr &event);
     virtual void OnRequestReceived(const IEventAddEventsPtr &events);
index e18bdf2..cd99c53 100755 (executable)
@@ -32,6 +32,18 @@ class CalendarManager : public ICalendarManager
     CalendarManager();
     virtual ~CalendarManager();
 
+       virtual void getDefaultCalendar(const IEventGetDefaultCalendarPtr &event) {
+               OnRequestReceived(event);
+       }
+
+       virtual void getUnifiedCalendar(const IEventGetUnifiedCalendarPtr &event) {
+               OnRequestReceived(event);
+       }
+
+       virtual void getCalendar(const IEventGetCalendarPtr &event) {
+               OnRequestReceived(event);
+       }
+
   protected:
        virtual void OnRequestReceived(const IEventGetCalendarsPtr &event);
        virtual void OnRequestReceived(const IEventGetDefaultCalendarPtr &event);
index 51126fd..2965f3f 100755 (executable)
@@ -24,19 +24,19 @@ namespace DeviceAPI {
 namespace Calendar {
 
 ICalendar::ICalendar() :
-    WrtDeviceApis::Commons::EventRequestReceiver<IEventAddEvent>(WrtDeviceApis::Commons::ThreadEnum::CALENDAR_THREAD),
-    WrtDeviceApis::Commons::EventRequestReceiver<IEventAddEvents>(WrtDeviceApis::Commons::ThreadEnum::CALENDAR_THREAD),
-    WrtDeviceApis::Commons::EventRequestReceiver<IEventDeleteEvent>(WrtDeviceApis::Commons::ThreadEnum::CALENDAR_THREAD),
-    WrtDeviceApis::Commons::EventRequestReceiver<IEventDeleteEvents>(WrtDeviceApis::Commons::ThreadEnum::CALENDAR_THREAD),
-    WrtDeviceApis::Commons::EventRequestReceiver<IEventUpdateEvent>(WrtDeviceApis::Commons::ThreadEnum::CALENDAR_THREAD),
-    WrtDeviceApis::Commons::EventRequestReceiver<IEventUpdateEvents>(WrtDeviceApis::Commons::ThreadEnum::CALENDAR_THREAD),
-    WrtDeviceApis::Commons::EventRequestReceiver<IEventFindEvents>(WrtDeviceApis::Commons::ThreadEnum::CALENDAR_THREAD),
-    WrtDeviceApis::Commons::EventRequestReceiver<IEventCreateEventFromString>(WrtDeviceApis::Commons::ThreadEnum::CALENDAR_THREAD),
-    WrtDeviceApis::Commons::EventRequestReceiver<IEventExportEventToString>(WrtDeviceApis::Commons::ThreadEnum::CALENDAR_THREAD),
-    WrtDeviceApis::Commons::EventRequestReceiver<IEventWatchChanges>(WrtDeviceApis::Commons::ThreadEnum::CALENDAR_THREAD),
-    WrtDeviceApis::Commons::EventRequestReceiver<IEventClearWatch>(WrtDeviceApis::Commons::ThreadEnum::CALENDAR_THREAD),
-    WrtDeviceApis::Commons::EventRequestReceiver<IEventExpandEventRecurrence>(WrtDeviceApis::Commons::ThreadEnum::CALENDAR_THREAD),
-    WrtDeviceApis::Commons::EventRequestReceiver<IEventGet>(WrtDeviceApis::Commons::ThreadEnum::CALENDAR_THREAD),
+    WrtDeviceApis::Commons::EventRequestReceiver<IEventAddEvent>(WrtDeviceApis::Commons::ThreadEnum::NULL_THREAD),
+    WrtDeviceApis::Commons::EventRequestReceiver<IEventAddEvents>(WrtDeviceApis::Commons::ThreadEnum::NULL_THREAD),
+    WrtDeviceApis::Commons::EventRequestReceiver<IEventDeleteEvent>(WrtDeviceApis::Commons::ThreadEnum::NULL_THREAD),
+    WrtDeviceApis::Commons::EventRequestReceiver<IEventDeleteEvents>(WrtDeviceApis::Commons::ThreadEnum::NULL_THREAD),
+    WrtDeviceApis::Commons::EventRequestReceiver<IEventUpdateEvent>(WrtDeviceApis::Commons::ThreadEnum::NULL_THREAD),
+    WrtDeviceApis::Commons::EventRequestReceiver<IEventUpdateEvents>(WrtDeviceApis::Commons::ThreadEnum::NULL_THREAD),
+    WrtDeviceApis::Commons::EventRequestReceiver<IEventFindEvents>(WrtDeviceApis::Commons::ThreadEnum::NULL_THREAD),
+    WrtDeviceApis::Commons::EventRequestReceiver<IEventCreateEventFromString>(WrtDeviceApis::Commons::ThreadEnum::NULL_THREAD),
+    WrtDeviceApis::Commons::EventRequestReceiver<IEventExportEventToString>(WrtDeviceApis::Commons::ThreadEnum::NULL_THREAD),
+    WrtDeviceApis::Commons::EventRequestReceiver<IEventWatchChanges>(WrtDeviceApis::Commons::ThreadEnum::NULL_THREAD),
+    WrtDeviceApis::Commons::EventRequestReceiver<IEventClearWatch>(WrtDeviceApis::Commons::ThreadEnum::NULL_THREAD),
+    WrtDeviceApis::Commons::EventRequestReceiver<IEventExpandEventRecurrence>(WrtDeviceApis::Commons::ThreadEnum::NULL_THREAD),
+    WrtDeviceApis::Commons::EventRequestReceiver<IEventGet>(WrtDeviceApis::Commons::ThreadEnum::NULL_THREAD),
     m_id(UNDEFINED_ID),
     m_accountId(UNDEFINED_CALENDAR_ID),
     m_name(""),
index 311a543..e0fecf0 100755 (executable)
@@ -23,10 +23,10 @@ namespace DeviceAPI {
 namespace Calendar {
 
 ICalendarManager::ICalendarManager() :
-    WrtDeviceApis::Commons::EventRequestReceiver< IEventGetCalendars >(WrtDeviceApis::Commons::ThreadEnum::CALENDAR_THREAD),
-    WrtDeviceApis::Commons::EventRequestReceiver< IEventGetDefaultCalendar >(WrtDeviceApis::Commons::ThreadEnum::CALENDAR_THREAD),
-    WrtDeviceApis::Commons::EventRequestReceiver< IEventGetUnifiedCalendar >(WrtDeviceApis::Commons::ThreadEnum::CALENDAR_THREAD),
-    WrtDeviceApis::Commons::EventRequestReceiver< IEventGetCalendar >(WrtDeviceApis::Commons::ThreadEnum::CALENDAR_THREAD)
+    WrtDeviceApis::Commons::EventRequestReceiver< IEventGetCalendars >(WrtDeviceApis::Commons::ThreadEnum::NULL_THREAD),
+    WrtDeviceApis::Commons::EventRequestReceiver< IEventGetDefaultCalendar >(WrtDeviceApis::Commons::ThreadEnum::NULL_THREAD),
+    WrtDeviceApis::Commons::EventRequestReceiver< IEventGetUnifiedCalendar >(WrtDeviceApis::Commons::ThreadEnum::NULL_THREAD),
+    WrtDeviceApis::Commons::EventRequestReceiver< IEventGetCalendar >(WrtDeviceApis::Commons::ThreadEnum::NULL_THREAD)
 {
 }
 
index 233fb9b..2423e82 100644 (file)
@@ -113,14 +113,16 @@ static void MappedDataControlGetValueCallback(bundle* b, int request_code, appsv
                        LoggerD("data null, can not send result to JS Layer");
                        return;
                }
+
+               pendingEvent = (EventGetValuePendingEvent *)data;
                
                if (DataControlAsyncCallbackManagerSingleton::Instance().isMappedDataControlGC())
                {
                        LoggerD("private object is garbage collected");
+                       delete pendingEvent;
                        return;
                }
 
-               pendingEvent = (EventGetValuePendingEvent *)data;
                consumer = (MappedDataControlConsumer*)pendingEvent->getThisObject();
                event = pendingEvent->getEvent();
 
@@ -257,14 +259,15 @@ static void MappedDataControlAddValueCallback(bundle* b, int request_code, appsv
                        return;
                }
 
+               pendingEvent = (EventAddValuePendingEvent *)data;
+
                if (DataControlAsyncCallbackManagerSingleton::Instance().isMappedDataControlGC())
                {
                        LoggerD("private object is garbage collected");
+                       delete pendingEvent;
                        return;
                }
-
-
-               pendingEvent = (EventAddValuePendingEvent *)data;
+                               
                consumer = (MappedDataControlConsumer*)pendingEvent->getThisObject();
                event = pendingEvent->getEvent();
 
@@ -331,14 +334,15 @@ static void MappedDataControlRemoveValueCallback(bundle* b, int request_code, ap
                        return;
                }
 
-               
+               pendingEvent = (EventRemoveValuePendingEvent *)data;
+
                if (DataControlAsyncCallbackManagerSingleton::Instance().isMappedDataControlGC())
                {
                        LoggerD("private object is garbage collected");
+                       delete pendingEvent;
                        return;
                }
-
-               pendingEvent = (EventRemoveValuePendingEvent *)data;
+                               
                consumer = (MappedDataControlConsumer*)pendingEvent->getThisObject();
                event = pendingEvent->getEvent();
 
@@ -406,13 +410,15 @@ static void MappedDataControlUpdateValueCallback(bundle* b, int request_code, ap
                        return;
                }
                
+               pendingEvent = (EventUpdateValuePendingEvent *)data;
+
                if (DataControlAsyncCallbackManagerSingleton::Instance().isMappedDataControlGC())
                {
                        LoggerD("private object is garbage collected");
+                       delete pendingEvent;
                        return;
                }
-
-               pendingEvent = (EventUpdateValuePendingEvent *)data;
+               
                consumer = (MappedDataControlConsumer*)pendingEvent->getThisObject();
                event = pendingEvent->getEvent();
 
index 6ed1e69..c5dee10 100644 (file)
@@ -120,13 +120,15 @@ static void sqldataControlSelectCallback(bundle* b, int request_code, appsvc_res
                        return;
                }
 
+               pendingEvent = (EventSelectPendingEvent *)data;
+               
                if (DataControlAsyncCallbackManagerSingleton::Instance().isSQLDataControlGC())
                {
                        LoggerD("private object is garbage collected");
+                       delete pendingEvent;
                        return;
                }
-
-               pendingEvent = (EventSelectPendingEvent *)data;
+               
                consumer = (SQLDataControlConsumer*)pendingEvent->getThisObject();
                event = pendingEvent->getEvent();
 
@@ -190,14 +192,15 @@ static void sqldataControlInsertCallback(bundle* b, int request_code, appsvc_res
                        return;
                }
 
+               pendingEvent = (EventInsertPendingEvent *)data;
+
                if (DataControlAsyncCallbackManagerSingleton::Instance().isSQLDataControlGC())
                {
                        LoggerD("private object is garbage collected");
+                       delete pendingEvent;
                        return;
                }
-               
-
-               pendingEvent = (EventInsertPendingEvent *)data;
+                               
                consumer = (SQLDataControlConsumer*)pendingEvent->getThisObject();
                event = pendingEvent->getEvent();
 
@@ -258,12 +261,6 @@ static void sqldataControlDeleteCallback(bundle* b, int request_code, appsvc_res
                return;
        }
 
-       if (DataControlAsyncCallbackManagerSingleton::Instance().isSQLDataControlGC())
-       {
-               LoggerD("private object is garbage collected");
-               return;
-       }
-
        EventDeletePendingEvent* pendingEvent = NULL;
        SQLDataControlConsumer *consumer = NULL;
        EventDeletePtr event;
@@ -277,6 +274,14 @@ static void sqldataControlDeleteCallback(bundle* b, int request_code, appsvc_res
                }
 
                pendingEvent = (EventDeletePendingEvent *)data;
+
+               if (DataControlAsyncCallbackManagerSingleton::Instance().isSQLDataControlGC())
+               {
+                       LoggerD("private object is garbage collected");
+                       delete pendingEvent;
+                       return;
+               }
+               
                consumer = (SQLDataControlConsumer*)pendingEvent->getThisObject();
                event = pendingEvent->getEvent();
 
@@ -337,14 +342,15 @@ static void sqldataControlUpdateCallback(bundle* b, int request_code, appsvc_res
                        return;
                }
 
+
+               pendingEvent = (EventUpdatePendingEvent *)data;
+               
                if (DataControlAsyncCallbackManagerSingleton::Instance().isSQLDataControlGC())
                {
                        LoggerD("private object is garbage collected");
+                       delete pendingEvent;
                        return;
                }
-
-
-               pendingEvent = (EventUpdatePendingEvent *)data;
                consumer = (SQLDataControlConsumer*)pendingEvent->getThisObject();
                event = pendingEvent->getEvent();
 
index 5dd8e44..41a3d44 100644 (file)
@@ -648,7 +648,7 @@ void Mms::readBody(msg_struct_t& messageData)
                        }
                }
        }
-
+       msg_release_struct(&mms_struct);
 }
 
 
index 76fac86..6b7c359 100644 (file)
@@ -114,8 +114,10 @@ JSValueRef JSPackageManager::install(JSContextRef context,
 {
        TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0);
 
+       TIME_TRACER_ITEM_BEGIN("install(ACE)", 0);
        AceSecurityStatus status = PACKAGE_CHECK_ACCESS(PACKAGE_FUNCTION_API_INSTALL);
        TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+       TIME_TRACER_ITEM_END("install(ACE)", 0);
 
        try {
                ArgumentValidator validator(context, argumentCount, arguments);
@@ -170,8 +172,10 @@ JSValueRef JSPackageManager::uninstall(JSContextRef context,
 {
        TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0);
 
+       TIME_TRACER_ITEM_BEGIN("uninstall(ACE)", 0);
        AceSecurityStatus status = PACKAGE_CHECK_ACCESS(PACKAGE_FUNCTION_API_INSTALL);
        TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+       TIME_TRACER_ITEM_END("uninstall(ACE)", 0);
 
        try {
                ArgumentValidator validator(context, argumentCount, arguments);
@@ -226,8 +230,10 @@ JSValueRef JSPackageManager::getPackagesInfo(JSContextRef context,
 {
        TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0);
 
+       TIME_TRACER_ITEM_BEGIN("getPackagesInfo(ACE)", 0);
        AceSecurityStatus status = PACKAGE_CHECK_ACCESS(PACKAGE_FUNCTION_API_GET_PACKAGES_INFO);
        TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+       TIME_TRACER_ITEM_END("getPackagesInfo(ACE)", 0);
 
        try {
                ArgumentValidator validator(context, argumentCount, arguments);
@@ -261,8 +267,10 @@ JSValueRef JSPackageManager::getPackageInfo(JSContextRef context,
 {
        TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0);
 
+       TIME_TRACER_ITEM_BEGIN("(getPackageInfo) ACE", 0);
        AceSecurityStatus status = PACKAGE_CHECK_ACCESS(PACKAGE_FUNCTION_API_GET_PACKAGE_INFO);
        TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+       TIME_TRACER_ITEM_END("(getPackageInfo) ACE", 0);
 
        try {
                ArgumentValidator validator(context, argumentCount, arguments);
@@ -290,8 +298,10 @@ JSValueRef JSPackageManager::setPackageInfoEventListener(JSContextRef context,
 {
        TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0);
 
+       TIME_TRACER_ITEM_BEGIN("(setPackageInfoEventListener) ACE", 0);
        AceSecurityStatus status = PACKAGE_CHECK_ACCESS(PACKAGE_FUNCTION_API_SET_PACKAGE_INFO_EVENT_LISTENER);
        TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+       TIME_TRACER_ITEM_END("(setPackageInfoEventListener) ACE", 0);
 
        try {
                ArgumentValidator validator(context, argumentCount, arguments);
@@ -343,8 +353,10 @@ JSValueRef JSPackageManager::unsetPackageInfoEventListener(JSContextRef context,
 {
        TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0);
 
+       TIME_TRACER_ITEM_BEGIN("(unsetPackageInfoEventListener) ACE", 0);
        AceSecurityStatus status = PACKAGE_CHECK_ACCESS(PACKAGE_FUNCTION_API_UNSET_PACKAGE_INFO_EVENT_LISTENER);
        TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+       TIME_TRACER_ITEM_END("(unsetPackageInfoEventListener) ACE", 0);
 
        try {
                PackageManager::getInstance()->unsetPackageInfoEventListener();
index 1c07d55..ab6a62e 100644 (file)
@@ -37,6 +37,9 @@
 #include "PackageManager.h"
 #include "PackageInformation.h"
 #include "JSPackageInformation.h"
+
+#include <TimeTracer.h>
+
 #include <Logger.h>
 
 using namespace WrtDeviceApis::Commons;
@@ -719,7 +722,9 @@ PackageInformation* PackageManager::getPackageInfo(string pkgId)
        if (pkgId.empty() || !pkgId.compare("null")) {
                char *pkg_id = NULL;
 
+               TIME_TRACER_ITEM_BEGIN("(getPackageInfo) get_current_pkg_id", 0);
                int ret = get_current_pkg_id(&pkg_id);
+               TIME_TRACER_ITEM_END("(getPackageInfo) get_current_pkg_id", 0);
                if((ret != APP_MANAGER_ERROR_NONE) || (pkg_id == NULL)) {
                        LoggerE("Can not get app id from current pid");
                        throw NotFoundException("Can't find given package");
@@ -729,12 +734,16 @@ PackageInformation* PackageManager::getPackageInfo(string pkgId)
        }
 
        pkgmgrinfo_pkginfo_h handle;
+       TIME_TRACER_ITEM_BEGIN("(getPackageInfo) pkgmgrinfo_pkginfo_get_pkginfo", 0);
        int ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgId.c_str(), &handle);
+       TIME_TRACER_ITEM_END("(getPackageInfo) pkgmgrinfo_pkginfo_get_pkginfo", 0);
        if (ret != PMINFO_R_OK) {
                throw NotFoundException("Can't find given package");
        }
 
+       TIME_TRACER_ITEM_BEGIN("(getPackageInfo) create_pkg_info", 0);
        PackageInformation* pkgInfo = create_pkg_info(handle);
+       TIME_TRACER_ITEM_END("(getPackageInfo) create_pkg_info", 0);
        pkgmgrinfo_appinfo_destroy_appinfo(handle);
 
        if (pkgInfo == NULL) {
@@ -755,7 +764,9 @@ void PackageManager::getPackagesInfo(PackageInfoCallbackData *user_data)
 void PackageManager::setPackageInfoEventListener(PackageInfoEventCallback * eventCB)
 {
        if (m_manager_handle == NULL) {
+               TIME_TRACER_ITEM_BEGIN("(setPackageInfoEventListener) pkgmgr_client_new", 0);
                m_manager_handle = pkgmgr_client_new(PC_LISTENING);
+               TIME_TRACER_ITEM_END("(setPackageInfoEventListener) pkgmgr_client_new", 0);
                if (m_manager_handle == NULL) {
                        throw UnknownException("Fail to create package manager handle");
                }
@@ -763,7 +774,9 @@ void PackageManager::setPackageInfoEventListener(PackageInfoEventCallback * even
 
        eventCB->setEventHandler(&m_manager_handle);
 
+       TIME_TRACER_ITEM_BEGIN("(setPackageInfoEventListener) pkgmgr_client_listen_status", 0);
        pkgmgr_client_listen_status(m_manager_handle, app_list_changed_cb_broker, eventCB);
+       TIME_TRACER_ITEM_END("(setPackageInfoEventListener) pkgmgr_client_listen_status", 0);
 }
 
 void PackageManager::unsetPackageInfoEventListener()
@@ -773,7 +786,9 @@ void PackageManager::unsetPackageInfoEventListener()
                return;
        }
 
+       TIME_TRACER_ITEM_BEGIN("(unsetPackageInfoEventListener) pkgmgr_client_free", 0);
        pkgmgr_client_free(m_manager_handle);
+       TIME_TRACER_ITEM_END("(unsetPackageInfoEventListener) pkgmgr_client_free", 0);
        m_manager_handle = NULL;
 }