#include "JSAudio.h"
#include "MediaConverter.h"
#include "plugin_config.h"
+#include "MediaContentAsyncCallbackManager.h"
using namespace TizenApis::Commons;
using namespace TizenApis::Api::Tizen;
const JSValueRef arguments[],
JSValueRef* exception )
{
-
LogDebug("JSMediacontent::findFolders entered");
MediacontentPrivObject *privateObject;
MediaConverterFactory::ConverterType converter = MediaConverterFactory::getConverter(context);
cbm = JSCallbackManager::createObject(globalContext);
-
- // Protect the super object until the callback operation is finished.
- JSValueProtect(globalContext, thisObject);
+ cbm->setObject(thisObject);
Try
{
dplEvent->setForAsynchronousCall(&MediacontentManagerController::getInstance());
mediacontent->findFolder(dplEvent);
+
+ MediaContentAsyncCallbackManagerSingleton::Instance().registerCallbackManager(cbm, globalContext);
}
Catch(UnsupportedException)
{
return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong object");
}
-
AceSecurityStatus status = MEDIACONTENT_CHECK_ACCESS(
MEDIACONTENT_FUNCTION_API_FIND_ITEMS);
MediaConverter mediaConverter(globalContext);
cbm = JSCallbackManager::createObject(globalContext);
+ cbm->setObject(thisObject);
- // Protect the super object until the callback operation is finished.
- JSValueProtect(globalContext, thisObject);
Try
{
IMediacontentPtr mediacontent = getMediacontentObject(context, thisObject, exception);
IEventBrowseFolderPtr dplEvent(new IEventBrowseFolder());
- JSValueRef onSuccessForCbm = NULL, onErrorForCbm = NULL;
+ JSValueRef onSuccessForCbm = NULL, onErrorForCbm = NULL;
if(argumentCount >= 1) //MediaItemArraySuccessCB successCallback
{
if(!(validator.isNullOrUndefined(arguments[2])) && (folderId.length() > 0) )
{
LogDebug("folderId:"+ folderId);
+
+ int nFolderId = 0;
+ istringstream(folderId) >> nFolderId; //string -> int
+
+ if (nFolderId<0)
+ {
+ cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context,
+ JSTizenException::INVALID_VALUES_ERROR, "Argument is invalid"));
+ return JSValueMakeUndefined(context);
+ }
+
dplEvent->setFolderID(folderId);
}
}
}
if(argumentCount >= 5) //optional SortMode? sortMode
{
- if(JSValueIsObject(context, arguments[4]))
+
+ if ( JSValueIsObject(context, arguments[4]) &&
+ !JSValueIsNull(context, arguments[4]) &&
+ !JSValueIsUndefined(context, arguments[4]) &&
+ !JSIsArrayValue(context, arguments[4]))
{
LogDebug("sortmode is object");
- // Though the sortMode is a single type, we save it in an array internally.
- TizenApis::Api::Tizen::SortModeArrayPtr sortModes(new TizenApis::Api::Tizen::SortModeArray());
- sortModes->push_back(filterConverter->toSortMode(arguments[4]));
- dplEvent->setSortModes(sortModes);
+ dplEvent->setSortMode(filterConverter->toSortMode(arguments[4]));
}
else if(!validator.isNullOrUndefined(arguments[4])) //nullable
{
if(argumentCount >= 6) //optional unsigned long? count
{
long count = filterConverter->toLong(arguments[5]);
- if(count != 0.0)
+
+ if(count > 0)
{
dplEvent->setLimit(count);
}
+ else if ( count == 0)
+ {
+ dplEvent->setLimit(-1); // -1 is all row.
+ }
else
{
- dplEvent->setLimit(-1);
+ cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context,
+ JSTizenException::INVALID_VALUES_ERROR, "Argument is invalid"));
+ return JSValueMakeUndefined(context);
}
}
if(argumentCount >= 7) //optional unsigned long? offset
{
- long limit = filterConverter->toLong(arguments[6]);
- if(limit != 0.0)
+ long offset = filterConverter->toLong(arguments[6]);
+ if(offset != 0)
{
- dplEvent->setLimit(limit);
+ dplEvent->setOffset(offset);
}
else
{
- dplEvent->setLimit(-1);
+ dplEvent->setOffset(0);
}
}
dplEvent->setPrivateData( DPL::StaticPointerCast<IEventPrivateData> (cbm));
dplEvent->setForAsynchronousCall(&MediacontentManagerController::getInstance());
mediacontent->browseFolder(dplEvent);
+
+ MediaContentAsyncCallbackManagerSingleton::Instance().registerCallbackManager(cbm, globalContext);
}
Catch(UnsupportedException)
{
MediaConverterFactory::ConverterType converter = MediaConverterFactory::getConverter(context);
cbm = JSCallbackManager::createObject(globalContext);
-
- // Protect the super object until the callback operation is finished.
- JSValueProtect(globalContext, thisObject);
+ cbm->setObject(thisObject);
Try
{
dplEvent->setForAsynchronousCall(&MediacontentManagerController::getInstance());
mediacontent->updateMediaItems(dplEvent);
+ MediaContentAsyncCallbackManagerSingleton::Instance().registerCallbackManager(cbm, globalContext);
}
Catch(UnsupportedException)
{
return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong object");
}
- AceSecurityStatus status = MEDIACONTENT_CHECK_ACCESS(
- MEDIACONTENT_FUNCTION_API_UPDATE_ITEM);
+ AceSecurityStatus status = MEDIACONTENT_CHECK_ACCESS(MEDIACONTENT_FUNCTION_API_UPDATE_ITEM);
TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);