# -----------------------------------------------------------------------------
INCLUDE(FindPkgConfig)
-PKG_SEARCH_MODULE(webkit2 REQUIRED ewebkit2)
-PKG_SEARCH_MODULE(dpl REQUIRED dpl-efl)
-PKG_SEARCH_MODULE(dpl-event REQUIRED dpl-event-efl)
-PKG_SEARCH_MODULE(wrt-plugins-types REQUIRED wrt-plugins-types)
-PKG_SEARCH_MODULE(wrt-deviceapis-commons REQUIRED wrt-plugins-commons)
-PKG_SEARCH_MODULE(wrt-deviceapis-commons-javascript REQUIRED wrt-plugins-commons-javascript)
-PKG_SEARCH_MODULE(wrt-plugins-widgetdb REQUIRED wrt-plugins-widgetdb)
+PKG_CHECK_MODULES(webkit2 REQUIRED ewebkit2)
+PKG_CHECK_MODULES(dpl REQUIRED dpl-efl)
+PKG_CHECK_MODULES(dpl-event REQUIRED dpl-event-efl)
+PKG_CHECK_MODULES(wrt-plugins-types REQUIRED wrt-plugins-types)
+PKG_CHECK_MODULES(wrt-deviceapis-commons REQUIRED wrt-plugins-commons)
+PKG_CHECK_MODULES(wrt-deviceapis-commons-javascript REQUIRED wrt-plugins-commons-javascript)
+PKG_CHECK_MODULES(wrt-plugins-widgetdb REQUIRED wrt-plugins-widgetdb)
INCLUDE_DIRECTORIES(
${webkit2_INCLUDE_DIRS}
Name: wrt-plugins-tizen
Summary: JavaScript plugins for WebRuntime
-Version: 0.4.10
+Version: 0.4.11
Release: 0
Group: Development/Libraries
License: Apache License, Version 2.0
+++ /dev/null
-//
-// Tizen Web Device API
-// Copyright (c) 2013 Samsung Electronics Co., Ltd.
-//
-// Licensed under the Apache License, Version 2.0 (the License);
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-
-#include "ArgumentValidationChecker.h"
-#include "JSTizenException.h"
-
-
-#include <dlog.h>
-#include <stdarg.h>
-
-#undef LOG_TAG
-#define LOG_TAG "TIZEN_DEVICEAPI"
-
-using namespace std;
-
-namespace DeviceAPI {
-namespace Common {
-
-
-void ArgumentValidationChecker::check(JSContextRef ctx, int argumentCount, const JSValueRef arguments [ ], int convertedArgumentCount, JSValueRef convertedArguments [ ], Option option, ...){
- va_list var_args;
- va_start (var_args, option);
- Option opt = option;
- int index = 0;
- while( opt != END){
- Type type = static_cast<Type>(va_arg(var_args, int));
- JSObjectRef testObject = NULL;
- bool nullable = ((opt & NULLABLE) == NULLABLE );
- JSValueRef jsException = NULL;
-
- if( index >= convertedArgumentCount ){
- LOGE("invalid argument check code");
- va_end (var_args);
- return;
- }
-
- if( argumentCount <= index ){
- if( !nullable )
- convertedArguments[index] = JSValueMakeUndefined(ctx);
- else
- convertedArguments[index] = JSValueMakeNull(ctx);
- testObject = NULL;
- }else{
- convertedArguments[index] = arguments[index];
- if( JSValueIsObject(ctx, arguments[index]) )
- testObject = JSValueToObject(ctx, arguments[index], NULL);
- else
- testObject = NULL;
- }
-
- if( JSValueIsNull(ctx, convertedArguments[index]) && nullable){
- if( type == ArgumentValidationChecker::UserDefine)
- va_arg(var_args, JSClassRef);
- if( type == ArgumentValidationChecker::SelfCheck)
- va_arg(var_args, SelfChecker);
-
- opt = static_cast<Option>(va_arg (var_args, int));
- index++;
- continue;
- }
-
-
- switch( type ){
- case ArgumentValidationChecker::Float:
- case ArgumentValidationChecker::Long:
- {
- double testValue = JSValueToNumber(ctx, convertedArguments[index], &jsException );
- if( jsException != NULL )
- throw ArgumentValidationException(JSTizenException::TYPE_MISMATCH_ERROR, "Could not converting to number", index);
- if( ArgumentValidationChecker::Float == type && testValue != testValue )
- throw ArgumentValidationException(JSTizenException::TYPE_MISMATCH_ERROR, "Converted value is nan", index);
- break;
- }
- case ArgumentValidationChecker::String:
- {
- JSStringRef convertedstr = JSValueToStringCopy(ctx, convertedArguments[index], &jsException);
- if( jsException != NULL){
- throw ArgumentValidationException(JSTizenException::TYPE_MISMATCH_ERROR, "Could not converting to string", index);
- }
- JSStringRelease(convertedstr);
- break;
- }
- case ArgumentValidationChecker::Boolean:
- //Boolean can convert from any types.
- break;
- case ArgumentValidationChecker::Function:
- if( testObject == NULL || !JSObjectIsFunction(ctx, testObject) )
- throw ArgumentValidationException(JSTizenException::TYPE_MISMATCH_ERROR, "argument is not function", index);
- break;
- case ArgumentValidationChecker::Object:
- if( testObject == NULL )
- throw ArgumentValidationException(JSTizenException::TYPE_MISMATCH_ERROR, "argument is not object", index);
- break;
- case ArgumentValidationChecker::Array:
- if( !JSIsArrayValue(ctx, convertedArguments[index])){
- JSObjectRef jsArray = JSCreateArrayObject(ctx, 0, NULL);
- JSSetArrayElement(ctx, jsArray, 0, convertedArguments[index]);
- convertedArguments[index] = jsArray;
- }
- break;
- case ArgumentValidationChecker::UserDefine:
- {
- JSClassRef classType = va_arg(var_args, JSClassRef);
- if( !JSValueIsObjectOfClass(ctx, convertedArguments[index],classType) )
- throw ArgumentValidationException(JSTizenException::TYPE_MISMATCH_ERROR, "argument is not wanted object", index);
- break;
- }
- case ArgumentValidationChecker::SelfCheck:
- {
- SelfChecker checker = va_arg(var_args, SelfChecker);
- if( !checker(convertedArguments[index]) )
- throw ArgumentValidationException(JSTizenException::TYPE_MISMATCH_ERROR, "argument is not wanted object", index);
- break;
- }
- }
-
- opt = static_cast<Option>(va_arg (var_args, int));
- index++;
- }
- va_end (var_args);
-}
-
-
-}
-}
+++ /dev/null
-//
-// Tizen Web Device API
-// Copyright (c) 2013 Samsung Electronics Co., Ltd.
-//
-// Licensed under the Apache License, Version 2.0 (the License);
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-
-#ifndef _WRTPLUGINS_TIZEN_ARGUMENTVALIDATIONCHECKER_
-#define _WRTPLUGINS_TIZEN_ARGUMENTVALIDATIONCHECKER_
-
-#include <string>
-#include <JavaScriptCore/JavaScript.h>
-
-namespace DeviceAPI {
-namespace Common{
-
-class ArgumentValidationException{
-public:
- std::string mTizenException;
- std::string mMessage;
- int mInvalidArgumentIndex;
- ArgumentValidationException(const std::string tizenException ,const std::string message):mTizenException(tizenException),mMessage(message),mInvalidArgumentIndex(-1){}
- ArgumentValidationException(const std::string tizenException ,const std::string message, int index):mTizenException(tizenException),mMessage(message),mInvalidArgumentIndex(index){}
-};
-
-
-
-class ArgumentValidationChecker{
- public :
- typedef bool (* SelfChecker)(JSValueRef value);
-
- /**
- * @brief Argument Validation options
- * MANDATORY - Must existed
- * OPTIONAL - Can be omitted
- * NULLABLE - Can be use NULL value
- * END - Variable argument terminator symbol
- */
- enum Option { MANDATORY = 0x01 , OPTIONAL = 0x02, NULLABLE = 0x04, END = 0x00 };
-
- enum Type { Float, Long, String, Function, Boolean, Object, Array, UserDefine, SelfCheck };
-
- /**
- * @brief check argment validation
- *
- * @remarks
- * Option phase instruction
- *
- * OPTIONS => OPTION, OPTIONS | OPTION,"END"
- * OPTION => FIRST, SECOND
- * FIRST => "MANDATORY" | "OPTIONAL" NULLABLE
- * NULLABLE => "|NULLABLE" | ""
- * SECOND => "Float" | "Long" | "String" | "Function" | "Boolean" | "Object" | "Array" | "UserDefine", CLASSREF | "SelfCheck", CHECKFUN
- * CLASSREF => ,JSClassRef
- * CHECKFUN => ,SelfChecker
- *
- * @param[in] ctx Context
- * @param[in] oirginArgumentCount Number of passed arguments count
- * @param[in] originArguments Passed arguments
- * @param[in] convertedArgumentCount Number of argument count in spec
- * @param[out] convertedArguments Converted arguments in proper types
- * @param[in] option Argument options
- *
- */
- static void check(JSContextRef ctx, int oirginArgumentCount , const JSValueRef originArguments[], int convertedArgumentCount , JSValueRef convertedArguments[], Option option, ...);
-};
-
-}
-}
-
-#endif //_WRTPLUGINS_TIZEN_ARGUMENTVALIDATIONCHECKER_
-
SET(SRCS
- JSTizenException.cpp
- TizenExceptionData.cpp
- JSTizenExceptionFactory.cpp
- JSWebAPIError.cpp
- ArgumentValidationChecker.cpp
- CallbackUserData.cpp
- GlobalContextManager.cpp
- ArgumentValidator.cpp
- JSUtil.cpp
- PlatformException.cpp
- MultiCallbackUserData.cpp
- JSWebAPIErrorFactory.cpp
- JSWebAPIError2.cpp
- WebAPIError.cpp
+ JSTizenException.cpp
+ TizenExceptionData.cpp
+ JSTizenExceptionFactory.cpp
+ JSWebAPIError.cpp
+ CallbackUserData.cpp
+ GlobalContextManager.cpp
+ ArgumentValidator.cpp
+ JSUtil.cpp
+ PlatformException.cpp
+ MultiCallbackUserData.cpp
+ JSWebAPIErrorFactory.cpp
+ JSWebAPIError2.cpp
+ WebAPIError.cpp
)
ADD_LIBRARY(${COMMON_TARGET_NAME} SHARED ${SRCS})
#include "MultiCallbackUserData.h"
#include "GlobalContextManager.h"
-
-#include <dlog.h>
-
-#undef LOG_TAG
-#define LOG_TAG "TIZEN_DEVICEAPI"
+#include "PlatformException.h"
+#include "Logger.h"
+#include "JSUtil.h"
using namespace std;
namespace DeviceAPI {
namespace Common {
-MultiCallbackUserData::MultiCallbackUserData(JSContextRef globalCtx): mContext(globalCtx){
+MultiCallbackUserData::MultiCallbackUserData(JSContextRef globalCtx): mContext(globalCtx), mObject(NULL){
+}
+
+MultiCallbackUserData::MultiCallbackUserData(JSContextRef globalCtx, JSObjectRef object): mContext(globalCtx), mObject(object){
+ if( mObject )
+ JSValueProtect(mContext, mObject);
}
MultiCallbackUserData::~MultiCallbackUserData(){
if( !GlobalContextManager::getInstance()->isAliveGlobalContext(mContext)){
+ //Remove Callback functions in Native Map
CallbackMapT::iterator itr;
for( itr = mCallbacks.begin() ; itr != mCallbacks.end() ; ++itr){
JSObjectRef t = itr->second;
if( t != NULL )
JSValueUnprotect(mContext, t);
}
+
+ //Remove Callback Object
+ if( mObject ){
+ JSValueUnprotect(mContext, mObject);
+ mObject = NULL;
+ }
}
}
void MultiCallbackUserData::setCallback(const string &key, JSObjectRef callback){
+
+ // Callback Object Case
+ if( mObject ){
+ JSUtil::setProperty(mContext, mObject, key.c_str(), callback, kJSPropertyAttributeNone);
+ return;
+ }
+
+ // Callback function Case
CallbackMapT::iterator itr;
itr = mCallbacks.find(key);
if( itr != mCallbacks.end() && itr->second != NULL){
return;
}
+ // Callback Object case
+ if( mObject ){
+ try{
+ // Getting callback value
+ JSValueRef callbackValue = JSUtil::getProperty(mContext, mObject, key.c_str());
+
+ // Testing existing
+ if( JSValueIsUndefined(mContext, callbackValue) ){
+ LOGE("There is no such callback[%s]", key.c_str());
+ return;
+ }
+
+ JSObjectRef callbackObject = JSUtil::JSValueToObject(mContext, callbackValue);
+
+ // Testing type validation
+ if( !JSObjectIsFunction( mContext, callbackObject) ){
+ LOGE("%s is not function", key.c_str());
+ return;
+ }
+
+ JSValueRef exception = NULL;
+ JSObjectCallAsFunction(mContext, callbackObject, NULL, count, obj, &exception);
+
+ // check Exception in function call
+ if( exception != NULL ){
+ throw UnknownException(mContext, exception);
+ }
+ }catch( const BasePlatformException& err){
+ LOGE("Error in Callback invoke - %s:%s", err.getName().c_str(), err.getMessage().c_str());
+ }
+ return;
+ }
+
+ // Callback function case
CallbackMapT::iterator itr;
itr = mCallbacks.find(key);
if( itr == mCallbacks.end()){
class MultiCallbackUserData{
public:
MultiCallbackUserData(JSContextRef globalCtx);
+ MultiCallbackUserData(JSContextRef globalCtx, JSObjectRef object);
virtual ~MultiCallbackUserData();
JSContextRef getContext();
void setCallback(const std::string &key, JSObjectRef callback);
private:
JSContextRef mContext;
+ JSObjectRef mObject;
typedef std::map<const std::string, JSObjectRef> CallbackMapT;
std::map<const std::string, JSObjectRef> mCallbacks;
};
int errorCode = 0;
int id = 0;
contacts_record_h contacts_record = NULL;
+ contacts_record_h get_contacts_record = NULL;
ContactPtr contact(NULL);
Try
ThrowMsg(PlatformException, "Error during executing contacts_db_insert_record()");
}
- contacts_record = NULL;
- errorCode = contacts_db_get_record(_contacts_contact._uri, contactId, &contacts_record);
- if(errorCode != CONTACTS_ERROR_NONE || contacts_record == NULL)
+ errorCode = contacts_db_get_record(_contacts_contact._uri, contactId, &get_contacts_record);
+ if(errorCode != CONTACTS_ERROR_NONE || get_contacts_record == NULL)
ThrowMsg(PlatformException, "No contact just inserted (id:" << contactId << ")");
ContactObjectP2AConverterPtr contactObjConverterForInserted(
- new ContactObjectP2AConverter(contacts_record, false));
+ new ContactObjectP2AConverter(get_contacts_record, false));
ContactPtr insertedContact = contactObjConverterForInserted->getAbstractContact();
contact->copy(insertedContact);
event->setExceptionCode(ExceptionCodes::UnknownException);
}
- if(contacts_record != NULL)
- contacts_record_destroy(contacts_record, true);
+ if(get_contacts_record != NULL)
+ contacts_record_destroy(get_contacts_record, true);
}
void AddressBook::AddressBookAddBatch(const EventAddressBookAddBatchPtr &event)
{
// LogDebug("entered");
+ m_numbersJSObjIsSet = false;
+ m_emailsJSObjIsSet = false;
+ m_anniversariesJSObjIsSet = false;
+ m_urlsJSObjIsSet = false;
+ m_addressesJSObjIsSet = false;
+ m_organizationsJSObjIsSet = false;
m_notesJSObjIsSet = false;
m_groupIdsJSObjIsSet = false;
- m_context = NULL;
+
+ m_numbersObj = NULL;
+ m_numbersJSValue = NULL;
+
+ m_emailsObj = NULL;
+ m_emailsJSValue = NULL;
+
+ m_anniversariesObj = NULL;
+ m_anniversariesJSValue = NULL;
+
+ m_urlsObj = NULL;
+ m_urlsJSValue = NULL;
+
+ m_addressesObj = NULL;
+ m_addressesJSValue = NULL;
+
+ m_organizationsObj = NULL;
+ m_organizationsJSValue = NULL;
+
m_groupIdsObj = NULL;
m_groupIdsJSValue = NULL;
+ m_notesObj = NULL;
+ m_notesJSValue = NULL;
+
+ m_context = NULL;
+
}
Contact::~Contact()
if (m_platformContactObjectList != NULL)
contacts_list_destroy(m_platformContactObjectList, true);
+ if(numbersJSObjIsSet()){
+ JSContextRef contextRef = getContext();
+ JSObjectRef tempJSObject = getNumbersJSObj();
+ JSValueUnprotect(contextRef, tempJSObject);
+ }
+
+ if(EmailsJSObjIsSet()){
+ JSContextRef contextRef = getContext();
+ JSObjectRef tempJSObject = getEmailsJSObj();
+ JSValueUnprotect(contextRef, tempJSObject);
+ }
+
+ if(anniversariesJSObjIsSet()){
+ JSContextRef contextRef = getContext();
+ JSObjectRef tempJSObject = getAnniversariesJSObj();
+ JSValueUnprotect(contextRef, tempJSObject);
+ }
+
+ if(urlsJSObjIsSet()){
+ JSContextRef contextRef = getContext();
+ JSObjectRef tempJSObject = getUrlsJSObj();
+ JSValueUnprotect(contextRef, tempJSObject);
+ }
+
+ if(addressesJSObjIsSet()){
+ JSContextRef contextRef = getContext();
+ JSObjectRef tempJSObject = getAddressesJSObj();
+ JSValueUnprotect(contextRef, tempJSObject);
+ }
+
+ if(organizationsJSObjIsSet()){
+ JSContextRef contextRef = getContext();
+ JSObjectRef tempJSObject = getOrganizationsJSObj();
+ JSValueUnprotect(contextRef, tempJSObject);
+ }
+
if(groupIdsJSObjIsSet()){
JSContextRef contextRef = getContext();
JSObjectRef tempJSObject = getGroupIdsJSObj();
m_platformContactObjectList = contacts_list;
}
+void Contact::setNumbersJSObj(bool value, JSObjectRef initObj)
+{
+ m_numbersJSObjIsSet = value;
+ m_numbersObj = initObj;
+}
+
+bool Contact::numbersJSObjIsSet() const
+{
+ return m_numbersJSObjIsSet;
+}
+
+JSObjectRef Contact::getNumbersJSObj()
+{
+ return m_numbersObj;
+}
+
+JSValueRef Contact::getNumbersJSValue()
+{
+ return m_numbersJSValue;
+}
+
+void Contact::setEmailsJSObj(bool value, JSObjectRef initObj)
+{
+ m_emailsJSObjIsSet = value;
+ m_emailsObj = initObj;
+}
+
+bool Contact::EmailsJSObjIsSet() const
+{
+ return m_emailsJSObjIsSet;
+}
+
+JSObjectRef Contact::getEmailsJSObj()
+{
+ return m_emailsObj;
+}
+
+JSValueRef Contact::getEmailsJSValue()
+{
+ return m_emailsJSValue;
+}
+
+void Contact::setAnniversariesJSObj(bool value, JSObjectRef initObj)
+{
+ m_anniversariesJSObjIsSet = value;
+ m_anniversariesObj = initObj;
+}
+
+bool Contact::anniversariesJSObjIsSet() const
+{
+ return m_anniversariesJSObjIsSet;
+}
+
+JSObjectRef Contact::getAnniversariesJSObj()
+{
+ return m_anniversariesObj;
+}
+
+JSValueRef Contact::getAnniversariesJSValue()
+{
+ return m_anniversariesJSValue;
+}
+
+void Contact::setUrlsJSObj(bool value, JSObjectRef initObj)
+{
+ m_urlsJSObjIsSet = value;
+ m_urlsObj = initObj;
+}
+
+bool Contact::urlsJSObjIsSet() const
+{
+ return m_urlsJSObjIsSet;
+}
+
+JSObjectRef Contact::getUrlsJSObj()
+{
+ return m_urlsObj;
+}
+
+JSValueRef Contact::getUrlsJSValue()
+{
+ return m_urlsJSValue;
+}
+
+void Contact::setAddressesJSObj(bool value, JSObjectRef initObj)
+{
+ m_addressesJSObjIsSet = value;
+ m_addressesObj = initObj;
+}
+
+bool Contact::addressesJSObjIsSet() const
+{
+ return m_addressesJSObjIsSet;
+}
+
+JSObjectRef Contact::getAddressesJSObj()
+{
+ return m_addressesObj;
+}
+
+JSValueRef Contact::getAddressesJSValue()
+{
+ return m_addressesJSValue;
+}
+
+void Contact::setOrganizationsJSObj(bool value, JSObjectRef initObj)
+{
+ m_organizationsJSObjIsSet = value;
+ m_organizationsObj = initObj;
+}
+
+bool Contact::organizationsJSObjIsSet() const
+{
+ return m_organizationsJSObjIsSet;
+}
+
+JSObjectRef Contact::getOrganizationsJSObj()
+{
+ return m_organizationsObj;
+}
+
+JSValueRef Contact::getOrganizationsJSValue()
+{
+ return m_organizationsJSValue;
+}
+
void Contact::setNotesJSObj(bool value, JSObjectRef initObj)
{
m_notesJSObjIsSet = value;
contacts_record_h getPlatformContactObject() const { return m_platformContactObject; };
+ void setNumbersJSObj(bool value, JSObjectRef initObj);
+ bool numbersJSObjIsSet() const;
+ JSObjectRef getNumbersJSObj();
+ JSValueRef getNumbersJSValue();
+
+ void setEmailsJSObj(bool value, JSObjectRef initObj);
+ bool EmailsJSObjIsSet() const;
+ JSObjectRef getEmailsJSObj();
+ JSValueRef getEmailsJSValue();
+
+ void setAnniversariesJSObj(bool value, JSObjectRef initObj);
+ bool anniversariesJSObjIsSet() const;
+ JSObjectRef getAnniversariesJSObj();
+ JSValueRef getAnniversariesJSValue();
+
+ void setUrlsJSObj(bool value, JSObjectRef initObj);
+ bool urlsJSObjIsSet() const;
+ JSObjectRef getUrlsJSObj();
+ JSValueRef getUrlsJSValue();
+
+ void setAddressesJSObj(bool value, JSObjectRef initObj);
+ bool addressesJSObjIsSet() const;
+ JSObjectRef getAddressesJSObj();
+ JSValueRef getAddressesJSValue();
+
+ void setOrganizationsJSObj(bool value, JSObjectRef initObj);
+ bool organizationsJSObjIsSet() const;
+ JSObjectRef getOrganizationsJSObj();
+ JSValueRef getOrganizationsJSValue();
+
void setNotesJSObj(bool value, JSObjectRef initObj);
bool notesJSObjIsSet() const;
JSObjectRef getNotesJSObj();
contacts_record_h m_platformContactObject;
contacts_list_h m_platformContactObjectList;
+ bool m_numbersJSObjIsSet;
+ JSObjectRef m_numbersObj;
+ JSValueRef m_numbersJSValue;
+
+ bool m_emailsJSObjIsSet;
+ JSObjectRef m_emailsObj;
+ JSValueRef m_emailsJSValue;
+
+ bool m_anniversariesJSObjIsSet;
+ JSObjectRef m_anniversariesObj;
+ JSValueRef m_anniversariesJSValue;
+
+ bool m_urlsJSObjIsSet;
+ JSObjectRef m_urlsObj;
+ JSValueRef m_urlsJSValue;
+
+ bool m_addressesJSObjIsSet;
+ JSObjectRef m_addressesObj;
+ JSValueRef m_addressesJSValue;
+
+ bool m_organizationsJSObjIsSet;
+ JSObjectRef m_organizationsObj;
+ JSValueRef m_organizationsJSValue;
+
bool m_notesJSObjIsSet;
JSObjectRef m_notesObj;
JSValueRef m_notesJSValue;
const ScopedJSStringRef notesStr(JSStringCreateWithUTF8CString(CONTACT_ATTRIBUTE_NOTES));
const ScopedJSStringRef phoneNumbersStr(JSStringCreateWithUTF8CString(CONTACT_ATTRIBUTE_PHONE_NUMBERS));
const ScopedJSStringRef emailsStr(JSStringCreateWithUTF8CString(CONTACT_ATTRIBUTE_EMAILS));
+ const ScopedJSStringRef anniversariesStr(JSStringCreateWithUTF8CString(CONTACT_ATTRIBUTE_ANNIVERSARIES));
+ const ScopedJSStringRef organizationsStr(JSStringCreateWithUTF8CString(CONTACT_ATTRIBUTE_ORGANIZATIONS));
+ const ScopedJSStringRef urlsStr(JSStringCreateWithUTF8CString(CONTACT_ATTRIBUTE_URLS));
JSObjectRef jsObject = toJSObjectRef(jsValue);
JSValueRef nameData = JSObjectGetProperty(m_context, jsObject, nameStr.get(), NULL);
JSValueRef emailsData = JSObjectGetProperty(m_context, jsObject, emailsStr.get(), NULL);
JSValueRef groupIdsData = JSObjectGetProperty(m_context, jsObject, groupIdsStr.get(), NULL);
JSValueRef notesData = JSObjectGetProperty(m_context, jsObject, notesStr.get(), NULL);
+ JSValueRef anniversariesData = JSObjectGetProperty(m_context, jsObject, anniversariesStr.get(), NULL);
+ JSValueRef organizationsData = JSObjectGetProperty(m_context, jsObject, organizationsStr.get(), NULL);
+ JSValueRef urlsData = JSObjectGetProperty(m_context, jsObject, urlsStr.get(), NULL);
ContactNamePtr name;
ContactAddressArrayPtr addresses;
ContactEmailAddressArrayPtr emails;
StringArrayPtr groupIds;
StringArrayPtr notes;
+ ContactAnniversaryArrayPtr anniversaries;
+ ContactOrganizationArrayPtr organizations;
+ ContactWebSiteArrayPtr urls;
Validator validator(m_context);
tempContact->setNotes(notes);
}
+ if (!validator.isNullOrUndefined(anniversariesData)) {
+ anniversaries = toContactAnniversaryArray(anniversariesData);
+ tempContact->setAnniversaries(anniversaries);
+ }
+
+ if (!validator.isNullOrUndefined(organizationsData)) {
+ organizations = toContactOrganizationArray(organizationsData);
+ tempContact->setOrganizations(organizations);
+ }
+
+ if (!validator.isNullOrUndefined(urlsData)) {
+ urls = toContactWebSiteArray(urlsData);
+ tempContact->setUrls(urls);
+ }
+
return tempContact;
// return JSContact::getContact(m_context, jsValue);
ContactGroupArrayPtr ContactConverter::toContactGroupArray(const JSValueRef &jsValue)
{
- if(JSContactGroupArray::isObjectOfClass(m_context, jsValue))
- return JSContactGroupArray::getContactGroupArray(m_context, jsValue);
-
if(!JSIsArrayValue(m_context, jsValue))
ThrowMsg(WrtDeviceApis::Commons::ConversionException, "ContactGroupArray is not array.");
ContactAnniversaryArrayPtr ContactConverter::toContactAnniversaryArray(const JSValueRef &jsValue)
{
- if(JSContactAnniversaryArray::isObjectOfClass(m_context, jsValue))
- return JSContactAnniversaryArray::getContactAnniversaryArray(m_context, jsValue);
-
if(!JSIsArrayValue(m_context, jsValue))
ThrowMsg(WrtDeviceApis::Commons::ConversionException, "ContactAnniversaryArray is not array.");
ContactPhoneNumberArrayPtr ContactConverter::toContactPhoneNumberArray(const JSValueRef &jsValue)
{
- if(JSContactPhoneNumberArray::isObjectOfClass(m_context, jsValue))
- return JSContactPhoneNumberArray::getContactPhoneNumberArray(m_context, jsValue);
-
if(!JSIsArrayValue(m_context, jsValue))
ThrowMsg(WrtDeviceApis::Commons::ConversionException, "ContactPhoneNumberArray is not array.");
ContactEmailAddressArrayPtr ContactConverter::toContactEmailAddressArray(const JSValueRef &jsValue)
{
- if(JSContactEmailAddressArray::isObjectOfClass(m_context, jsValue))
- return JSContactEmailAddressArray::getContactEmailAddressArray(m_context, jsValue);
-
+ LogDebug("1");
if(!JSIsArrayValue(m_context, jsValue))
ThrowMsg(WrtDeviceApis::Commons::ConversionException, "ContactEmailAddressArray is not array.");
JSObjectRef jsObject = toJSObjectRef(jsValue);
for (std::size_t i = 0; i < JSGetArrayLength(m_context, jsObject); ++i) {
+
+ LogDebug("count : " << i);
JSValueRef element = JSGetArrayElement(m_context, jsObject, i);
result->push_back(toContactEmailAddress(element));
}
ContactAddressTypeArrayPtr ContactConverter::toContactAddressTypeArray(const JSValueRef &jsValue)
{
- if(JSContactAddressTypeArray::isObjectOfClass(m_context, jsValue))
- return JSContactAddressTypeArray::getContactAddressTypeArray(m_context, jsValue);
-
if(!JSIsArrayValue(m_context, jsValue))
ThrowMsg(WrtDeviceApis::Commons::ConversionException, "ContactAddressTypeArray is not array.");
ContactPhoneNumberTypeArrayPtr ContactConverter::toContactPhoneNumberTypeArray(const JSValueRef &jsValue)
{
- if(JSContactPhoneNumberTypeArray::isObjectOfClass(m_context, jsValue))
- return JSContactPhoneNumberTypeArray::getContactPhoneNumberTypeArray(m_context, jsValue);
-
if(!JSIsArrayValue(m_context, jsValue))
ThrowMsg(WrtDeviceApis::Commons::ConversionException, "ContactEmailAddressTypeArray is not array.");
ContactEmailAddressTypeArrayPtr ContactConverter::toContactEmailAddressTypeArray(const JSValueRef &jsValue)
{
- if(JSContactEmailAddressTypeArray::isObjectOfClass(m_context, jsValue))
- return JSContactEmailAddressTypeArray::getContactEmailAddressTypeArray(m_context, jsValue);
-
if(!JSIsArrayValue(m_context, jsValue))
ThrowMsg(WrtDeviceApis::Commons::ConversionException, "ContactEmailAddressTypeArray is not array.");
}
}
- LogDebug("organization->getLogoURIIsSet() : " << organization->getLogoURIIsSet());
// ContactOrganization.logoURI
if(organization->getLogoURIIsSet())
{
- LogDebug("organization->getLogoURI() : " << organization->getLogoURI());
string logoURI = organization->getLogoURI();
if(!logoURI.empty())
{
-// logoURI = ContactUtility::convertUriToPath(logoURI);
- LogDebug("logoURI.c_str() : " << logoURI.c_str());
-
+ logoURI = ContactUtility::convertUriToPath(logoURI);
errorCode = contacts_record_set_str(child_record, _contacts_company.logo, logoURI.c_str());
- LogDebug("errorCode : " << errorCode);
if(errorCode != CONTACTS_ERROR_NONE)
{
LogWarning("importing logoURI N (err:" << errorCode << ", str:" << logoURI << ")");
child_record = NULL;
- if(ContactUtility::checkStrIsUInt(groupId))
+ if(!ContactUtility::checkStrIsUInt(groupId))
{
LogWarning("groupId (" << groupId << ") is wrong.");
continue;
ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is null");
}
JSContextRef gContext = priv->getContext();
- ContactConverterFactory::ConverterType converter =
- ContactConverterFactory::getConverter(gContext);
+ ContactConverterFactory::ConverterType converter = ContactConverterFactory::getConverter(gContext);
ContactPtr contact = getPrivData(object);
- return converter->toJSValueRef(contact->getAddresses());
+
+ DPL::SharedPtr<Contact> newContactT = DPL::StaticPointerCast<Contact>(contact);
+ if(newContactT->addressesJSObjIsSet()){
+ return newContactT->getAddressesJSObj();
+ }else{
+ JSValueRef tempJSValue = newContactT->getAddressesJSValue();
+ tempJSValue = converter->toJSValueRef(newContactT->getAddresses());
+
+ JSObjectRef convertedJSObject = newContactT->getAddressesJSObj();
+ convertedJSObject = JSValueToObject( gContext, tempJSValue, NULL );
+ newContactT->setAddressesJSObj(true, convertedJSObject);
+
+ JSValueProtect(gContext, convertedJSObject);
+ newContactT->setContext(gContext);
+ return tempJSValue;
+ }
}
Catch(WrtDeviceApis::Commons::Exception)
{
ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is null");
}
JSContextRef gContext = priv->getContext();
- ContactConverterFactory::ConverterType converter =
- ContactConverterFactory::getConverter(gContext);
+ ContactConverterFactory::ConverterType converter = ContactConverterFactory::getConverter(gContext);
ContactPtr contact = getPrivData(object);
- return converter->toJSValueRef(contact->getPhoneNumbers());
+
+ DPL::SharedPtr<Contact> newContactT = DPL::StaticPointerCast<Contact>(contact);
+ if(newContactT->numbersJSObjIsSet()){
+ return newContactT->getNumbersJSObj();
+ }else{
+ JSValueRef tempJSValue = newContactT->getNumbersJSValue();
+ tempJSValue = converter->toJSValueRef(newContactT->getPhoneNumbers());
+
+ JSObjectRef convertedJSObject = newContactT->getNumbersJSObj();
+ convertedJSObject = JSValueToObject( gContext, tempJSValue, NULL );
+ newContactT->setNumbersJSObj(true, convertedJSObject);
+
+ JSValueProtect(gContext, convertedJSObject);
+ newContactT->setContext(gContext);
+ return tempJSValue;
+ }
}
Catch(WrtDeviceApis::Commons::Exception)
{
}
JSContextRef gContext = priv->getContext();
- ContactConverterFactory::ConverterType converter =
- ContactConverterFactory::getConverter(gContext);
+ ContactConverterFactory::ConverterType converter = ContactConverterFactory::getConverter(gContext);
ContactPtr contact = getPrivData(object);
- return converter->toJSValueRef(contact->getEmails());
+
+ DPL::SharedPtr<Contact> newContactT = DPL::StaticPointerCast<Contact>(contact);
+ if(newContactT->EmailsJSObjIsSet()){
+ LogDebug("return init value");
+ return newContactT->getEmailsJSObj();
+ }else{
+ LogDebug("new array");
+ JSValueRef tempJSValue = newContactT->getEmailsJSValue();
+ tempJSValue = converter->toJSValueRef(newContactT->getEmails());
+
+ JSObjectRef convertedJSObject = newContactT->getEmailsJSObj();
+ convertedJSObject = JSValueToObject( gContext, tempJSValue, NULL );
+ newContactT->setEmailsJSObj(true, convertedJSObject);
+
+ JSValueProtect(gContext, convertedJSObject);
+ newContactT->setContext(gContext);
+ return tempJSValue;
+ }
}
Catch(WrtDeviceApis::Commons::Exception)
{
{
Try
{
- ContactConverterFactory::ConverterType converter =
- ContactConverterFactory::getConverter(context);
+ JSContactPriv *priv = static_cast<JSContactPriv*>(JSObjectGetPrivate(object));
+ if (!priv) {
+ ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is null");
+ }
+ JSContextRef gContext = priv->getContext();
+
+ ContactConverterFactory::ConverterType converter = ContactConverterFactory::getConverter(gContext);
ContactPtr contact = getPrivData(object);
- return converter->toJSValueRef(contact->getAnniversaries());
+
+ DPL::SharedPtr<Contact> newContactT = DPL::StaticPointerCast<Contact>(contact);
+ if(newContactT->anniversariesJSObjIsSet()){
+ return newContactT->getAnniversariesJSObj();
+ }else{
+ JSValueRef tempJSValue = newContactT->getAnniversariesJSValue();
+ tempJSValue = converter->toJSValueRef(newContactT->getAnniversaries());
+
+ JSObjectRef convertedJSObject = newContactT->getAnniversariesJSObj();
+ convertedJSObject = JSValueToObject( gContext, tempJSValue, NULL );
+ newContactT->setAnniversariesJSObj(true, convertedJSObject);
+
+ JSValueProtect(gContext, convertedJSObject);
+ newContactT->setContext(gContext);
+ return tempJSValue;
+ }
}
Catch(WrtDeviceApis::Commons::Exception)
{
{
Try
{
- ContactConverterFactory::ConverterType converter =
- ContactConverterFactory::getConverter(context);
+ JSContactPriv *priv = static_cast<JSContactPriv*>(JSObjectGetPrivate(object));
+ if (!priv) {
+ ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is null");
+ }
+ JSContextRef gContext = priv->getContext();
+
+ ContactConverterFactory::ConverterType converter = ContactConverterFactory::getConverter(gContext);
ContactPtr contact = getPrivData(object);
- return converter->toJSValueRef(contact->getOrganizations());
+
+ DPL::SharedPtr<Contact> newContactT = DPL::StaticPointerCast<Contact>(contact);
+ if(newContactT->organizationsJSObjIsSet()){
+ return newContactT->getOrganizationsJSObj();
+ }else{
+ JSValueRef tempJSValue = newContactT->getOrganizationsJSValue();
+ tempJSValue = converter->toJSValueRef(newContactT->getOrganizations());
+
+ JSObjectRef convertedJSObject = newContactT->getOrganizationsJSObj();
+ convertedJSObject = JSValueToObject( gContext, tempJSValue, NULL );
+ newContactT->setOrganizationsJSObj(true, convertedJSObject);
+
+ JSValueProtect(gContext, convertedJSObject);
+ newContactT->setContext(gContext);
+ return tempJSValue;
+ }
}
Catch(WrtDeviceApis::Commons::Exception)
{
{
Try
{
- ContactConverterFactory::ConverterType converter =
- ContactConverterFactory::getConverter(context);
+ JSContactPriv *priv = static_cast<JSContactPriv*>(JSObjectGetPrivate(object));
+ if (!priv) {
+ ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is null");
+ }
+ JSContextRef gContext = priv->getContext();
+
+ ContactConverterFactory::ConverterType converter = ContactConverterFactory::getConverter(gContext);
ContactPtr contact = getPrivData(object);
- return converter->toJSValueRef(contact->getUrls());
+
+ DPL::SharedPtr<Contact> newContactT = DPL::StaticPointerCast<Contact>(contact);
+ if(newContactT->urlsJSObjIsSet()){
+ return newContactT->getUrlsJSObj();
+ }else{
+ JSValueRef tempJSValue = newContactT->getUrlsJSValue();
+ tempJSValue = converter->toJSValueRef(newContactT->getUrls());
+
+ JSObjectRef convertedJSObject = newContactT->getUrlsJSObj();
+ convertedJSObject = JSValueToObject( gContext, tempJSValue, NULL );
+ newContactT->setUrlsJSObj(true, convertedJSObject);
+
+ JSValueProtect(gContext, convertedJSObject);
+ newContactT->setContext(gContext);
+ return tempJSValue;
+ }
}
Catch(WrtDeviceApis::Commons::Exception)
{
#define CONTACT_ATTR_NUMBER "number"
#define CONTACT_ATTR_TYPES "types"
-#define CONTACT_ATTR_IS_DEFAULT "idDefault"
+#define CONTACT_ATTR_IS_DEFAULT "isDefault"
namespace DeviceAPI {
namespace Contact {
--- /dev/null
+//
+// Tizen Web Device API
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#include "ContentExif.h"
+#include <Logger.h>
+
+
+namespace DeviceAPI {
+namespace Content {
+
+ContentExif::ContentExif(std::string path)
+{
+ fp = fopen(path.c_str(), "rb+");
+ m_exifBuf = NULL;
+}
+
+ContentExif::~ContentExif()
+{
+ if(fp)
+ {
+ fclose(fp);
+ }
+ if(!m_exifBuf)
+ {
+ free(m_exifBuf);
+ }
+}
+
+unsigned char ContentExif::nextByte()
+{
+ return getc(fp);
+}
+
+int ContentExif::read_1_byte (void)
+{
+ int c;
+
+ //todo. check EOF
+ c = nextByte();
+
+ return c;
+}
+
+/* Read 2 bytes, convert to unsigned int */
+/* All 2-byte quantities in JPEG markers are MSB first */
+unsigned int ContentExif::read_2_bytes (void)
+{
+ int c1, c2;
+
+ //todo. check EOF
+ c1 = nextByte();
+ c2 = nextByte();
+ return (((unsigned int) c1) << 8) + ((unsigned int) c2);
+}
+
+int ContentExif::LodExif()
+{
+ unsigned char soi[2];
+
+ if(fp == NULL) return 0;
+
+ for (int i = 0; i < sizeof(soi); i++)
+ soi[i] = (unsigned char) read_1_byte();
+
+ //check soi tag for jpeg
+ if (soi[0]!=0xFF || soi[1]!=0xD8)
+ {
+ LogDebug("can not find SOI tag");
+ return -1;
+ }
+
+ //App marker
+ for(;;)
+ {
+ unsigned char app[2];
+ for( int i = 0; i < sizeof(app); i++)
+ app[i] = (unsigned char) read_1_byte();
+
+ printf("marker:%02x %02x \n",app[0],app[1]);
+ if(app[0] == 0xFF && app[1] == 0xE1)
+ break;
+ else if(app[0] != 0xFF || !(app[1]==0xEE ||app[1]==0xE0))
+ {
+ LogDebug("Not supported image type.");
+ return -1;
+ }
+
+ unsigned int marker_size = read_2_bytes();
+
+ for( int i =0 ; i < marker_size - 2; i++)
+ read_1_byte();
+ }
+
+ unsigned int len = read_2_bytes() - 8;
+ if (len < 0)
+ {
+ LogDebug("Wrong Image");
+ return -2;
+ }
+
+ //check exif header
+ unsigned char exif[6];
+ for (int i = 0; i < 6; i++)
+ exif[i] = (unsigned char) read_1_byte();
+
+ if (exif[0] != 0x45 || exif[1] != 0x78 || exif[2] != 0x69 ||exif[3] != 0x66)
+ {
+ LogDebug("can not find EXIF tag");
+ return -1;
+ }
+
+ m_exifBuf = (unsigned char*)calloc(len,sizeof(unsigned char));
+
+ fread(m_exifBuf, 1, len,fp);
+
+ /* check endian type */
+ if (m_exifBuf[0] == 0x49 && m_exifBuf[1] == 0x49)
+ {
+ m_endianType = false;
+ }
+ else if (m_exifBuf[0] == 0x4D && m_exifBuf[1] == 0x4D)
+ {
+ m_endianType = true;
+ }
+ else
+ {
+ LogDebug("can not find endian tag");
+ return -1;
+ }
+
+ /* Get first IFD offset (offset to IFD0) */
+ if (m_endianType)
+ {
+ if (m_exifBuf[4] != 0) return 0;
+ if (m_exifBuf[5] != 0) return 0;
+ m_offset = m_exifBuf[6];
+ m_offset <<= 8;
+ m_offset += m_exifBuf[7];
+ }
+ else
+ {
+ if (m_exifBuf[7] != 0) return 0;
+ if (m_exifBuf[6] != 0) return 0;
+ m_offset = m_exifBuf[5];
+ m_offset <<= 8;
+ m_offset += m_exifBuf[4];
+ }
+
+ if (m_offset > len - 2) return 0; /* check end of data segment */
+
+ /* Get the number of directory entries contained in this IFD */
+ if (m_endianType)
+ {
+ m_tagCount = m_exifBuf[m_offset];
+ m_tagCount <<= 8;
+ m_tagCount += m_exifBuf[m_offset+1];
+ }
+ else
+ {
+ m_tagCount = m_exifBuf[m_offset+1];
+ m_tagCount <<= 8;
+ m_tagCount += m_exifBuf[m_offset];
+ }
+ if (m_tagCount == 0) return 0;
+ m_offset += 2;
+
+ return 1;
+}
+
+bool ContentExif::SetExifChar(unsigned int tag, unsigned char value)
+{
+ unsigned int _tag;
+ bool isfound = false;
+ for(unsigned int i = 0; i < m_tagCount; i++)
+ {
+ if(m_endianType)
+ {
+ _tag = m_exifBuf[m_offset];
+ _tag <<= 8;
+ _tag += m_exifBuf[m_offset+1];
+ }
+ else
+ {
+ _tag = m_exifBuf[m_offset+1];
+ _tag <<= 8;
+ _tag += m_exifBuf[m_offset];
+ }
+ if(_tag == tag)
+ {
+ isfound = true;
+ break;
+ }
+
+ m_offset += 12;
+ }
+
+ if(isfound)
+ {
+ if (m_endianType) {
+ m_exifBuf[m_offset+2] = 0; /* Format = unsigned short (2 octets) */
+ m_exifBuf[m_offset+3] = 3;
+ m_exifBuf[m_offset+4] = 0; /* Number Of Components = 1 */
+ m_exifBuf[m_offset+5] = 0;
+ m_exifBuf[m_offset+6] = 0;
+ m_exifBuf[m_offset+7] = 1;
+ m_exifBuf[m_offset+8] = 0;
+ m_exifBuf[m_offset+9] = value;
+ m_exifBuf[m_offset+10] = 0;
+ m_exifBuf[m_offset+11] = 0;
+ } else {
+ m_exifBuf[m_offset+2] = 3; /* Format = unsigned short (2 octets) */
+ m_exifBuf[m_offset+3] = 0;
+ m_exifBuf[m_offset+4] = 1; /* Number Of Components = 1 */
+ m_exifBuf[m_offset+5] = 0;
+ m_exifBuf[m_offset+6] = 0;
+ m_exifBuf[m_offset+7] = 0;
+ m_exifBuf[m_offset+8] = value;
+ m_exifBuf[m_offset+9] = 0;
+ m_exifBuf[m_offset+10] = 0;
+ m_exifBuf[m_offset+11] = 0;
+ }
+
+ fseek(fp, (4 + 2 + 6 + 2) + m_offset, SEEK_SET);
+ fwrite(m_exifBuf + 2 + m_offset, 1, 10, fp);
+ }
+ return isfound;
+}
+
+
+} // Content
+} // DeviceAPI
--- /dev/null
+//
+// Tizen Web Device API
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+
+#ifndef _PLATFORM_CONTENT_EXIF_H_
+#define _PLATFORM_CONTENT_EXIF_H_
+
+#include <string>
+
+namespace DeviceAPI {
+namespace Content {
+
+#define EXIF_TAG_ORIENTATION 0x0112
+
+class ContentExif
+{
+public:
+ ContentExif(std::string path);
+ virtual ~ContentExif();
+
+ int LodExif();
+ bool SetExifChar(unsigned int tag, unsigned char value);
+
+private:
+
+ int read_1_byte();
+ unsigned int read_2_bytes();
+ unsigned char nextByte();
+
+
+ FILE *fp;
+
+ std::string m_path;
+ bool m_endianType;
+ unsigned char *m_exifBuf;
+ unsigned int m_tagCount;
+ unsigned int m_offset;
+};
+
+} // Content
+} // DeviceAPI
+
+#endif // _PLATFORM_CONTENT_UTILITY_H_
\ No newline at end of file
{
if ( MEDIA_CONTENT_ERROR_NONE !=
media_info_foreach_media_from_db (filter, mediaItemCallback, eBrowse.Get()))
- {
+ {
LogError("error ( media_folder_foreach_folder_from_db ) : " << ret);
eBrowse->setResult(false);
}
else
- {
+ {
eBrowse->setResult(true);
}
}
{
MediacontentImagePtr imagePtr = DPL::DynamicPointerCast<MediacontentImage>(mediaPtr);
- if(imagePtr && (imagePtr->isChangedOrientaion()
- || imagePtr->isChangedLatitude() || imagePtr->isChangedLongitude()))
+ if(imagePtr)
{
image_meta_h img=NULL;
if ( MEDIA_CONTENT_ERROR_NONE == media_info_get_image(media, &img))
{
if(imagePtr->isChangedOrientaion())
{
- if ( MEDIA_CONTENT_ERROR_NONE !=
+ if ( MEDIA_CONTENT_ERROR_NONE !=
image_meta_set_orientation (img, convertToOrientation(imagePtr->getImageOrientation())))
{
- LogDebug("Error: set orientation");
+ LogDebug("Error: set orientation");
ret = false;
}
}
media_info_set_latitude(media, imagePtr->getImageLatitude())
)
{
- LogDebug("Error: set Latitude");
+ LogDebug("Error: set Latitude");
ret = false;
}
if ( MEDIA_CONTENT_ERROR_NONE != image_meta_destroy(img))
{
- LogDebug("Error: destroy media info");
+ LogDebug("Error: destroy media info");
ret = false;
}
ret = false;
}
}
-
+
}
if(type.compare("VIDEO") ==0 )
{
MediacontentVideoPtr videoPtr = DPL::DynamicPointerCast<MediacontentVideo>(mediaPtr);
- if (videoPtr && ( videoPtr->isChangedArtists () || videoPtr->isChangedAlbum()
- || videoPtr->isChangedLatitude() ||videoPtr->isChangedLongitude()) )
+ if (videoPtr)
{
video_meta_h video = NULL;
LogDebug("Error: set play count");
ret = false;
- }
+ }
}
if (videoPtr->isChangedPlayedTime())
if ( MEDIA_CONTENT_ERROR_NONE != video_meta_destroy(video))
{
- LogDebug("Error: destroy video meta");
+ LogDebug("Error: destroy video meta");
ret = false;
}
// limitations under the License.
//
+#include <libexif/exif-loader.h>
#include <Commons/StringUtils.h>
#include <Commons/ThreadPool.h>
#include "IContentManager.h"
#include "ContentVideo.h"
#include "ContentAudio.h"
#include "ContentManager.h"
+#include "ContentExif.h"
+#include "ContentUtility.h"
+
namespace DeviceAPI {
namespace Content {
return ret;
}
+bool IMediacontentManager::updateMetadata(MediacontentImagePtr &ptr)
+{
+ LogDebug("ContentManager::updateMetadata called");
+ string orientation = ptr->getImageOrientation();
+ unsigned char orientation_value;
+ LogDebug("ContentManager::updateMetadata called1");
+ if ( orientation.compare("NORMAL")==0)
+ {
+ orientation_value= 1; //MEDIA_CONTENT_ORIENTATION_NORMAL
+ }
+ else if (orientation.compare("FLIP_HORIZONTAL")==0)
+ {
+ orientation_value = 2; //MEDIA_CONTENT_ORIENTATION_HFLIP;
+ }
+ else if (orientation.compare("ROTATE_180")==0)
+ {
+ orientation_value = 3; //MEDIA_CONTENT_ORIENTATION_ROT_180;
+ }
+ else if (orientation.compare("FLIP_VERTICAL")==0)
+ {
+ orientation_value = 4; //MEDIA_CONTENT_ORIENTATION_VFLIP;
+ }
+ else if (orientation.compare("TRANSPOSE")==0)
+ {
+ orientation_value = 5; //MEDIA_CONTENT_ORIENTATION_TRANSPOSE;
+ }
+ else if (orientation.compare("ROTATE_90")==0)
+ {
+ orientation_value = 6; //MEDIA_CONTENT_ORIENTATION_ROT_90;
+ }
+ else if (orientation.compare("TRANSVERSE")==0)
+ {
+ orientation_value = 7; //MEDIA_CONTENT_ORIENTATION_TRANSVERSE;
+ }
+ else if (orientation.compare("ROTATE_270")==0)
+ {
+ orientation_value = 8; //MEDIA_CONTENT_ORIENTATION_ROT_270;
+ }
+ else
+ {
+ LogDebug("wrong value.");
+ return false;
+ }
+ LogDebug("ContentManager::updateMetadata called2");
+ string real_path = ContentUtility::convertUriToPath(ptr->getFilePath());
+ ContentExif exif(real_path.c_str());
+ int res = exif.LodExif();
+ if( res == 0)
+ {
+ ThrowMsg(WrtDeviceApis::Commons::InvalidArgumentException, "Invalid image");
+ return false;
+ }
+ else if(res < 0)
+ {
+ ThrowMsg(WrtDeviceApis::Commons::UnsupportedException, "Not supported image type");
+ return false;
+
+ }
+ exif.SetExifChar(EXIF_TAG_ORIENTATION,orientation_value);
+
+
+ return true;
+
+}
+
}
}
#include "IEventUpdate.h"
#include "IEventUpdateBatch.h"
#include "IEventFind.h"
+#include "ContentMedia.h"
+#include "ContentImage.h"
+
namespace DeviceAPI {
CONTENT_AUDIO
} MediacontentType;
- virtual void findFolder(IEventFindFolderPtr &ptr);
+ virtual void findFolder(IEventFindFolderPtr &ptr);
virtual void updateMedia(IEventUpdateMediaPtr &ptr);
virtual void browseFolder(IEventBrowseFolderPtr &ptr);
virtual void updateMediaItems(IEventUpdateMediaItemsPtr &ptr);
virtual bool scanFile(scanCompletedCallback callback, std::string path, void* user_data);
virtual bool setListener(void* user_data);
virtual bool unsetListener();
+ virtual bool updateMetadata(MediacontentImagePtr &ptr);
virtual void OnRequestReceived(const IEventFindFolderPtr &value) = 0;
virtual void OnRequestReceived(const IEventUpdateMediaPtr &value) = 0;
- virtual void OnRequestReceived(const IEventBrowseFolderPtr &value) = 0;
- virtual void OnRequestReceived(const IEventUpdateMediaItemsPtr &value) = 0;
-
+ virtual void OnRequestReceived(const IEventBrowseFolderPtr &value) = 0;
+ virtual void OnRequestReceived(const IEventUpdateMediaItemsPtr &value) = 0;
+
};
typedef DPL::SharedPtr<IMediacontentManager> IMediacontentManagerPtr;
#include <MultiCallbackUserData.h>
#include <GlobalContextManager.h>
#include <FilterConverter.h>
+#include "JSUtil.h"
#include "ContentFactory.h"
#include "ContentController.h"
#include "plugin_config.h"
#include "ContentAsyncCallbackManager.h"
#include "ContentListener.h"
+#include "ContentVideo.h"
+#include "ContentImage.h"
+
using namespace DeviceAPI::Common;
using namespace DeviceAPI::Tizen;
{ CONTENT_FUNCTION_API_SCAN_FILE, scanFile, kJSPropertyAttributeNone },
{ CONTENT_FUNCTION_API_SET_CHANGE_LISTENER, setChangeListener, kJSPropertyAttributeNone },
{ CONTENT_FUNCTION_API_UNSET_CHANGE_LISTENER, unsetChangeListener,kJSPropertyAttributeNone},
+ { CONTENT_FUNCTION_API_UPDATE_METADATA, updateMetadata,kJSPropertyAttributeNone},
{ 0, 0, 0 }
};
};
JSValueRef JSMediacontentManager::getFolders(
- JSContextRef context,
+ JSContextRef context,
JSObjectRef object,
- JSObjectRef thisObject,
+ JSObjectRef thisObject,
size_t argumentCount,
const JSValueRef arguments[],
JSValueRef* exception )
MediaContentAsyncCallbackManagerSingleton::Instance().registerCallbackManager(cbm, globalContext);
}
- Catch(UnsupportedException)
+ Catch(WrtDeviceApis::Commons::UnsupportedException)
{
LogWarning("Exception: "<<_rethrown_exception.GetMessage());
return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, _rethrown_exception.GetMessage());
}
- Catch(InvalidArgumentException)
+ Catch(WrtDeviceApis::Commons::InvalidArgumentException)
{
LogWarning("Exception: "<<_rethrown_exception.GetMessage());
return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, _rethrown_exception.GetMessage());
}
- Catch(ConversionException)
+ Catch(WrtDeviceApis::Commons::ConversionException)
{
LogWarning("Exception: "<<_rethrown_exception.GetMessage());
return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage());
}
- Catch (NotFoundException)
+ Catch(WrtDeviceApis::Commons::NotFoundException)
{
LogWarning("Exception: "<<_rethrown_exception.GetMessage());
return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_FOUND_ERROR, _rethrown_exception.GetMessage());
}
- Catch(Exception)
+ Catch(WrtDeviceApis::Commons::Exception)
{
LogWarning("Exception: "<<_rethrown_exception.GetMessage());
return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, _rethrown_exception.GetMessage());
JSValueRef JSMediacontentManager::findItems(
- JSContextRef context,
+ JSContextRef context,
JSObjectRef object,
- JSObjectRef thisObject,
+ JSObjectRef thisObject,
size_t argumentCount,
- const JSValueRef arguments[],
+ const JSValueRef arguments[],
JSValueRef* exception )
{
if(argumentCount >= 5) //optional SortMode? sortMode
{
- if ( JSValueIsObject(context, arguments[4]) &&
- !JSValueIsNull(context, arguments[4]) &&
+ if ( JSValueIsObject(context, arguments[4]) &&
+ !JSValueIsNull(context, arguments[4]) &&
!JSValueIsUndefined(context, arguments[4]) &&
!JSIsArrayValue(context, arguments[4]))
{
MediaContentAsyncCallbackManagerSingleton::Instance().registerCallbackManager(cbm, globalContext);
}
- Catch(UnsupportedException)
+ Catch(WrtDeviceApis::Commons::UnsupportedException)
{
LogWarning("Exception: "<<_rethrown_exception.GetMessage());
return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, _rethrown_exception.GetMessage());
}
- Catch(InvalidArgumentException)
+ Catch(WrtDeviceApis::Commons::InvalidArgumentException)
{
LogWarning("Exception: "<<_rethrown_exception.GetMessage());
return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, _rethrown_exception.GetMessage());
}
- Catch(ConversionException)
+ Catch(WrtDeviceApis::Commons::ConversionException)
{
LogWarning("Exception: "<<_rethrown_exception.GetMessage());
return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage());
}
- Catch (NotFoundException)
+ Catch(WrtDeviceApis::Commons::NotFoundException)
{
LogWarning("Exception: "<<_rethrown_exception.GetMessage());
return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_FOUND_ERROR, _rethrown_exception.GetMessage());
}
- Catch(Exception)
+ Catch(WrtDeviceApis::Commons::Exception)
{
LogWarning("Exception: "<<_rethrown_exception.GetMessage());
return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, _rethrown_exception.GetMessage());
if((argumentCount >= 1) && (JSIsArrayValue(context, arguments[0]))) //MediaItem[] items
{
events = converter->toVectorOfMediaItem(arguments[0]);
- if(!events)
+ if(!events)
{
ThrowMsg(ConversionException, "Items type mismatched.");
}
ThrowMsg(ConversionException, "Items type mismatched.");
}
- if(argumentCount >= 2) //Function? successCallback,
+ if(argumentCount >= 2) //Function? successCallback,
{
if(validator.isCallback(arguments[1]))
{
}
}
- if(argumentCount >= 3) //ErrorCallback? errorCallback,
+ if(argumentCount >= 3) //ErrorCallback? errorCallback,
{
if(validator.isCallback(arguments[2]))
{
MediaContentAsyncCallbackManagerSingleton::Instance().registerCallbackManager(cbm, globalContext);
}
- Catch(UnsupportedException)
+ Catch(WrtDeviceApis::Commons::UnsupportedException)
{
LogWarning("Exception: "<<_rethrown_exception.GetMessage());
return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, _rethrown_exception.GetMessage());
}
- Catch(InvalidArgumentException)
+ Catch(WrtDeviceApis::Commons::InvalidArgumentException)
{
LogWarning("Exception: "<<_rethrown_exception.GetMessage());
return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, _rethrown_exception.GetMessage());
}
- Catch(ConversionException)
+ Catch(WrtDeviceApis::Commons::ConversionException)
{
LogWarning("Exception: "<<_rethrown_exception.GetMessage());
return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage());
}
- Catch (NotFoundException)
+ Catch(WrtDeviceApis::Commons::NotFoundException)
{
LogWarning("Exception: "<<_rethrown_exception.GetMessage());
return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_FOUND_ERROR, _rethrown_exception.GetMessage());
}
- Catch(Exception)
+ Catch(WrtDeviceApis::Commons::Exception)
{
LogWarning("Exception: "<<_rethrown_exception.GetMessage());
return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, _rethrown_exception.GetMessage());
Validator validator(context);
Try
- {
+ {
IMediacontentManagerPtr contentMgr = getContentManagerPrivObject(context, thisObject, exception);
-
+
//parameter : MediaItem item
-
+
JSObjectRef arg;
if(argumentCount >= 1)
{
!JSValueIsObjectOfClass(context, arguments[0], JSAudio::getClassRef()) &&
!JSValueIsObjectOfClass(context, arguments[0], JSVideo::getClassRef())) {
ThrowMsg(ConversionException, "Item type mismatched.");
- }
+ }
arg = JSValueToObject(context, arguments[0], exception);
}
else
ThrowMsg(ConversionException, "Item type mismatched.");
}
- MediacontentMediaPtr event = JSMedia::getMediaObject(arg);
-
+ MediacontentMediaPtr event;
IEventUpdateMediaPtr dplEvent(new IEventUpdateMedia());
+
+ if(JSValueIsObjectOfClass(context, arguments[0], JSImage::getClassRef())){
+
+ JSValueRef geoValRef = JSUtil::getProperty(context ,
+ JSUtil::JSValueToObject(context, arguments[0]), "geolocation");
+ JSObjectRef geoObjRef = JSUtil::JSValueToObject(context, geoValRef);
+ double latitude = JSUtil::JSValueToDouble(context,
+ JSUtil::getProperty(context, geoObjRef, "latitude"));
+
+ double longitude = JSUtil::JSValueToDouble(context,
+ JSUtil::getProperty(context, geoObjRef, "longitude"));
+
+ MediacontentImagePtr imgPtr = JSImage::getImageObject(arg);
+ imgPtr->setImageLatitude(latitude);
+ imgPtr->setImageLongitude(longitude);
+
+ }
+ else if(JSValueIsObjectOfClass(context, arguments[0], JSVideo::getClassRef())){
+ JSValueRef geoValRef = JSUtil::getProperty(context ,
+ JSUtil::JSValueToObject(context, arguments[0]), "geolocation");
+ JSObjectRef geoObjRef = JSUtil::JSValueToObject(context, geoValRef);
+
+ double latitude = JSUtil::JSValueToDouble(context,
+ JSUtil::getProperty(context, geoObjRef, "latitude"));
+
+ double longitude = JSUtil::JSValueToDouble(context,
+ JSUtil::getProperty(context, geoObjRef, "longitude"));
+
+ MediacontentVideoPtr vedioPtr = JSVideo::getVideoObject(arg);
+ vedioPtr->setVideoLatitude(latitude);
+ vedioPtr->setVideoLongitude(longitude);
+ }
+
+ event = JSMedia::getMediaObject(arg);
dplEvent->setMediaItem(event);
+
dplEvent->setForSynchronousCall();
contentMgr->updateMedia(dplEvent);
if (!(dplEvent->getResult())) {
- ThrowMsg(UnknownException, "updating failed by unknown reason.");
+ ThrowMsg(WrtDeviceApis::Commons::Exception, "updating failed by unknown reason.");
}
}
- Catch(UnsupportedException)
+ Catch(WrtDeviceApis::Commons::UnsupportedException)
{
LogWarning("Exception: "<<_rethrown_exception.GetMessage());
return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, _rethrown_exception.GetMessage());
}
- Catch(InvalidArgumentException)
+ Catch(WrtDeviceApis::Commons::InvalidArgumentException)
{
LogWarning("Exception: "<<_rethrown_exception.GetMessage());
return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, _rethrown_exception.GetMessage());
}
- Catch(ConversionException)
+ Catch(WrtDeviceApis::Commons::ConversionException)
{
LogWarning("Exception: "<<_rethrown_exception.GetMessage());
return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage());
}
- Catch (NotFoundException)
+ Catch(WrtDeviceApis::Commons::NotFoundException)
{
LogWarning("Exception: "<<_rethrown_exception.GetMessage());
return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_FOUND_ERROR, _rethrown_exception.GetMessage());
}
- Catch(Exception)
+ Catch(WrtDeviceApis::Commons::Exception)
{
LogWarning("Exception: "<<_rethrown_exception.GetMessage());
return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, _rethrown_exception.GetMessage());
contentMgr->scanFile(_scanCompletedCallback,path,(void*)callback);
}
- Catch(UnsupportedException)
+ Catch(WrtDeviceApis::Commons::UnsupportedException)
{
LogWarning("Exception: "<<_rethrown_exception.GetMessage());
return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, _rethrown_exception.GetMessage());
}
- Catch(InvalidArgumentException)
+ Catch(WrtDeviceApis::Commons::InvalidArgumentException)
{
LogWarning("Exception: "<<_rethrown_exception.GetMessage());
return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, _rethrown_exception.GetMessage());
}
- Catch(ConversionException)
+ Catch(WrtDeviceApis::Commons::ConversionException)
{
LogWarning("Exception: "<<_rethrown_exception.GetMessage());
return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage());
}
- Catch (NotFoundException)
+ Catch(WrtDeviceApis::Commons::NotFoundException)
{
LogWarning("Exception: "<<_rethrown_exception.GetMessage());
return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_FOUND_ERROR, _rethrown_exception.GetMessage());
}
- Catch(Exception)
+ Catch(WrtDeviceApis::Commons::Exception)
{
LogWarning("Exception: "<<_rethrown_exception.GetMessage());
return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, _rethrown_exception.GetMessage());
ThrowMsg(Exception, "Unknown exception is occured by platfrom");
}
}
- Catch(UnsupportedException)
+ Catch(WrtDeviceApis::Commons::UnsupportedException)
{
LogWarning("Exception: "<<_rethrown_exception.GetMessage());
return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, _rethrown_exception.GetMessage());
}
- Catch(InvalidArgumentException)
+ Catch(WrtDeviceApis::Commons::InvalidArgumentException)
{
LogWarning("Exception: "<<_rethrown_exception.GetMessage());
return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, _rethrown_exception.GetMessage());
}
- Catch(ConversionException)
+ Catch(WrtDeviceApis::Commons::ConversionException)
{
LogWarning("Exception: "<<_rethrown_exception.GetMessage());
return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage());
}
- Catch (NotFoundException)
+ Catch(WrtDeviceApis::Commons::NotFoundException)
{
LogWarning("Exception: "<<_rethrown_exception.GetMessage());
return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_FOUND_ERROR, _rethrown_exception.GetMessage());
}
- Catch(Exception)
+ Catch(WrtDeviceApis::Commons::Exception)
{
LogWarning("Exception: "<<_rethrown_exception.GetMessage());
return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, _rethrown_exception.GetMessage());
ThrowMsg(Exception, "Unknown exception is occured by platfrom");
}
}
- Catch(UnsupportedException)
+ Catch(WrtDeviceApis::Commons::UnsupportedException)
{
LogWarning("Exception: "<<_rethrown_exception.GetMessage());
return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, _rethrown_exception.GetMessage());
}
- Catch(InvalidArgumentException)
+ Catch(WrtDeviceApis::Commons::InvalidArgumentException)
{
LogWarning("Exception: "<<_rethrown_exception.GetMessage());
return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, _rethrown_exception.GetMessage());
}
- Catch(ConversionException)
+ Catch(WrtDeviceApis::Commons::ConversionException)
{
LogWarning("Exception: "<<_rethrown_exception.GetMessage());
return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage());
}
- Catch (NotFoundException)
+ Catch(WrtDeviceApis::Commons::NotFoundException)
{
LogWarning("Exception: "<<_rethrown_exception.GetMessage());
return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_FOUND_ERROR, _rethrown_exception.GetMessage());
}
- Catch(Exception)
+ Catch(WrtDeviceApis::Commons::Exception)
{
LogWarning("Exception: "<<_rethrown_exception.GetMessage());
return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, _rethrown_exception.GetMessage());
}
+JSValueRef JSMediacontentManager::updateMetadata(
+ JSContextRef context,
+ JSObjectRef object,
+ JSObjectRef thisObject,
+ size_t argumentCount,
+ const JSValueRef arguments[],
+ JSValueRef* exception)
+{
+LogDebug("JSContentManagerManager::updateMetadata entered");
+
+
+ MediacontentManagerPrivObject *privateObject;
+ privateObject = static_cast<MediacontentManagerPrivObject*>(JSObjectGetPrivate(thisObject));
+ if (!privateObject) {
+ return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "private object is null");
+ }
+
+ AceSecurityStatus status = CONTENT_CHECK_ACCESS(CONTENT_FUNCTION_API_UPDATE_METADATA);
+ TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+
+ Validator validator(context);
+
+ Try
+ {
+ IMediacontentManagerPtr contentMgr = getContentManagerPrivObject(context, thisObject, exception);
+
+ JSObjectRef arg;
+ if(argumentCount >= 1){
+ if (!JSValueIsObjectOfClass(context, arguments[0],JSImage::getClassRef())){
+ ThrowMsg(UnsupportedException, "Not supported type.");
+ }
+ arg = JSValueToObject(context, arguments[0], exception);
+ }
+ else{
+ ThrowMsg(ConversionException, "Invalid content type.");
+ }
+
+ MediacontentImagePtr content = JSImage::getImageObject(arg);
+
+ if (!(contentMgr->updateMetadata(content))) {
+ ThrowMsg(WrtDeviceApis::Commons::Exception, "updating metadata is failed by unknown reason.");
+ }
+ }
+ Catch(WrtDeviceApis::Commons::UnsupportedException)
+ {
+ LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+ return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, _rethrown_exception.GetMessage());
+ }
+ Catch(WrtDeviceApis::Commons::InvalidArgumentException)
+ {
+ LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+ return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, _rethrown_exception.GetMessage());
+ }
+ Catch(WrtDeviceApis::Commons::ConversionException)
+ {
+ LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+ return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage());
+ }
+ Catch(WrtDeviceApis::Commons::NotFoundException)
+ {
+ LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+ return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_FOUND_ERROR, _rethrown_exception.GetMessage());
+ }
+ Catch(WrtDeviceApis::Commons::Exception)
+ {
+ LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+ return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, _rethrown_exception.GetMessage());
+ }
+
+ return JSValueMakeUndefined(context);
+
+}
const JSClassRef JSMediacontentManager::getClassRef() {
}
-const JSClassDefinition* JSMediacontentManager::getClassInfo()
+const JSClassDefinition* JSMediacontentManager::getClassInfo()
{
return &m_classInfo;
}
-void JSMediacontentManager::initialize(JSContextRef context, JSObjectRef object)
+void JSMediacontentManager::initialize(JSContextRef context, JSObjectRef object)
{
LogDebug("JSContentManager initialize entered");
MediacontentManagerPrivObject *privateObject = static_cast<MediacontentManagerPrivObject*>(JSObjectGetPrivate(object));
- if (NULL == privateObject)
+ if (NULL == privateObject)
{
LogDebug("Create ContenttManagerPrivObject");
IMediacontentManagerPtr contentManager = MediacontentFactory::getInstance().createMediacontentManagerObject();
privateObject = new MediacontentManagerPrivObject(context, contentManager);
- if (!JSObjectSetPrivate(object, static_cast<void*>(privateObject)))
+ if (!JSObjectSetPrivate(object, static_cast<void*>(privateObject)))
{
delete privateObject;
}
}
-void JSMediacontentManager::finalize(JSObjectRef object)
+void JSMediacontentManager::finalize(JSObjectRef object)
{
LogDebug("Entered");
MediacontentManagerPrivObject* priv = static_cast<MediacontentManagerPrivObject*> (JSObjectGetPrivate(object));
JSValueRef* exception)
{
MediacontentManagerPrivObject *priv = static_cast<MediacontentManagerPrivObject*>(JSObjectGetPrivate(object));
- if (priv)
+ if (priv)
{
return priv->getObject();
}
}
-}
+}
* The callback invoked when getting a property's value.
*/
static JSValueRef getProperty(
- JSContextRef context,
- JSObjectRef object,
- JSStringRef propertyName,
+ JSContextRef context,
+ JSObjectRef object,
+ JSStringRef propertyName,
JSValueRef* exception);
/**
* The callback invoked when an object is used as the target of an 'instanceof' expression.
*/
static bool hasInstance(
- JSContextRef context,
- JSObjectRef constructor,
- JSValueRef possibleInstance,
+ JSContextRef context,
+ JSObjectRef constructor,
+ JSValueRef possibleInstance,
JSValueRef* exception);
static JSValueRef getFolders(
- JSContextRef context,
+ JSContextRef context,
JSObjectRef object,
- JSObjectRef thisObject,
+ JSObjectRef thisObject,
size_t argumentCount,
- const JSValueRef arguments[],
+ const JSValueRef arguments[],
JSValueRef* exception);
static JSValueRef updateItem(
size_t argumentCount,
const JSValueRef arguments[],
JSValueRef* exception);
-
+
static JSValueRef findItems(
- JSContextRef context,
+ JSContextRef context,
JSObjectRef object,
- JSObjectRef thisObject,
+ JSObjectRef thisObject,
size_t argumentCount,
const JSValueRef arguments[],
JSValueRef* exception);
JSValueRef* exception);
+ static JSValueRef updateMetadata(
+ JSContextRef context,
+ JSObjectRef object,
+ JSObjectRef thisObject,
+ size_t argumentCount,
+ const JSValueRef arguments[],
+ JSValueRef* exception);
+
+
/**
* This structure contains properties and callbacks that define a type of object.
*/
static JSClassRef m_jsClassRef;
};
-}
-}
+}
+}
#endif //_JS_TIZEN_CONTENTMANAGER_H_
#include <JSTizenException.h>
#include <SecurityExceptions.h>
+#include "JSUtil.h"
#include "JSImage.h"
JSStaticValue JSImage::m_property[] =
{
// { TIZEN_CONTENT_IMAGE_UID, getPropertyUid, NULL, kJSPropertyAttributeReadOnly},
- { TIZEN_CONTENT_IMAGE_GEOLOCATION, getPropertyGeoLocation, setPropertyGeolocation, kJSPropertyAttributeNone},
+// { TIZEN_CONTENT_IMAGE_GEOLOCATION, getPropertyGeoLocation, setPropertyGeolocation, kJSPropertyAttributeNone},
{ TIZEN_CONTENT_IMAGE_WIDTH, getPropertyWidth, NULL, kJSPropertyAttributeReadOnly},
- { TIZEN_CONTENT_IMAGE_HEIGHT, getPropertyHeight, NULL, kJSPropertyAttributeReadOnly},
- { TIZEN_CONTENT_IMAGE_ORIENTATION, getPropertyOrientation, setPropertyOrientation, kJSPropertyAttributeNone},
+ { TIZEN_CONTENT_IMAGE_HEIGHT, getPropertyHeight, NULL, kJSPropertyAttributeReadOnly},
+ { TIZEN_CONTENT_IMAGE_ORIENTATION, getPropertyOrientation, setPropertyOrientation, kJSPropertyAttributeNone},
{ 0, 0, 0, 0 }
};
void JSImage::initialize(JSContextRef context, JSObjectRef object)
{
LogDebug( "entered" );
- ImagePrivObject *priv =
- static_cast<ImagePrivObject*>( JSObjectGetPrivate( object ) );
+ ImagePrivObject *priv = static_cast<ImagePrivObject*>( JSObjectGetPrivate( object ) );
+
if (!priv) {
MediacontentImagePtr privateData(new MediacontentImage());
priv = new ImagePrivObject(context, privateData);
}
else {
LogDebug("private object already exists");
+ MediacontentImagePtr image = getImageObject(object);
+ DeviceAPI::Tizen::SimpleCoordinatesPtr geoPtr(new SimpleCoordinates(image->getImageLatitude(),image->getImageLongitude()));
+ JSUtil::setProperty(context, object, TIZEN_CONTENT_IMAGE_GEOLOCATION,
+ JSSimpleCoordinates::createJSObject(context,geoPtr),
+ kJSPropertyAttributeNone);
}
}
void JSImage::finalize(JSObjectRef object)
{
LogDebug( "entered" );
- ImagePrivObject *priv = static_cast<ImagePrivObject*>( JSObjectGetPrivate( object ) ) ;
+ ImagePrivObject *priv = static_cast<ImagePrivObject*>( JSObjectGetPrivate( object ) ) ;
if (priv != NULL)
{
delete (priv);
priv = NULL;
- JSObjectSetPrivate(object, NULL);
+ JSObjectSetPrivate(object, NULL);
}
}
}
return result;
}
-
+
JSValueRef JSImage::getPropertyGeoLocation(
JSContextRef context,
JSObjectRef object,
MediacontentImagePtr image = getImageObject(object);
LogDebug("lati :" << image->getImageLatitude());
- LogDebug("longi :" << image->getImageLongitude());
+ LogDebug("longi :" << image->getImageLongitude());
DeviceAPI::Tizen::SimpleCoordinatesPtr geoPtr(new SimpleCoordinates(image->getImageLatitude(),image->getImageLongitude()));
return JSSimpleCoordinates::createJSObject(context,geoPtr);
JSValueRef JSImage::getPropertyWidth(
JSContextRef context,
- JSObjectRef object,
- JSStringRef propertyName,
+ JSObjectRef object,
+ JSStringRef propertyName,
JSValueRef* exception)
{
LogDebug("entered");
#include "ContentConverter.h"
#include "JSVideo.h"
+#include "JSUtil.h"
#define TIZEN_CONTENT_VIDEO_ATTRIBUTENAME "VideoContent"
#define TIZEN_CONTENT_VIDEO_GEOLOCATION "geolocation"
JSStaticValue JSVideo::m_property[] =
{
- { TIZEN_CONTENT_VIDEO_GEOLOCATION, getPropertyGeoLocation, setPropertyGeoLocation, kJSPropertyAttributeNone},
+// { TIZEN_CONTENT_VIDEO_GEOLOCATION, getPropertyGeoLocation, setPropertyGeoLocation, kJSPropertyAttributeNone},
{ TIZEN_CONTENT_VIDEO_ALBUM, getPropertyAlbum, NULL, kJSPropertyAttributeReadOnly},
{ TIZEN_CONTENT_VIDEO_ARTIST, getPropertyArtist, NULL, kJSPropertyAttributeReadOnly},
- { TIZEN_CONTENT_VIDEO_DURATION, getPropertyDuration, NULL, kJSPropertyAttributeReadOnly},
+ { TIZEN_CONTENT_VIDEO_DURATION, getPropertyDuration, NULL, kJSPropertyAttributeReadOnly},
{ TIZEN_CONTENT_VIDEO_WIDTH, getPropertyWidth, NULL, kJSPropertyAttributeReadOnly},
- { TIZEN_CONTENT_VIDEO_HEIGHT, getPropertyHeight, NULL, kJSPropertyAttributeReadOnly},
+ { TIZEN_CONTENT_VIDEO_HEIGHT, getPropertyHeight, NULL, kJSPropertyAttributeReadOnly},
{ 0, 0, 0, 0 }
};
{
LogDebug( "entered" );
VideoPrivObject *priv = static_cast<VideoPrivObject*>( JSObjectGetPrivate( object ) );
- if (!priv)
+ if (!priv)
{
MediacontentVideoPtr privateData(new MediacontentVideo());
priv = new VideoPrivObject(context, privateData);
JSObjectSetPrivate(object, static_cast<void*>(priv));
- LogDebug("new event is created" );
+ LogDebug("new pravite object is created" );
}
else {
LogDebug("private object already exists");
+ MediacontentVideoPtr video = getVideoObject(object);
+ DeviceAPI::Tizen::SimpleCoordinatesPtr geoPtr(new SimpleCoordinates(video->getVideoLatitude(),video->getVideoLongitude()));
+ JSUtil::setProperty(context, object, TIZEN_CONTENT_VIDEO_GEOLOCATION,
+ JSSimpleCoordinates::createJSObject(context,geoPtr),
+ kJSPropertyAttributeNone);
}
}
void JSVideo::finalize(JSObjectRef object)
{
LogDebug( "entered" );
- VideoPrivObject *priv = static_cast<VideoPrivObject*>( JSObjectGetPrivate( object ) ) ;
+ VideoPrivObject *priv = static_cast<VideoPrivObject*>( JSObjectGetPrivate( object ) ) ;
if (priv != NULL)
{
delete (priv);
priv = NULL;
- JSObjectSetPrivate(object, NULL);
+ JSObjectSetPrivate(object, NULL);
}
priv = NULL;
{
LogDebug("JSVideo::getClassRef()");
- if (!m_jsClassRef)
+ if (!m_jsClassRef)
{
m_jsClassRef = JSClassCreate(&m_classInfo);
}
{
LogDebug("entered");
VideoPrivObject *priv = static_cast<VideoPrivObject*>(JSObjectGetPrivate(object));
- if(!priv)
+ if(!priv)
{
ThrowMsg(NullPointerException, "Private object is null");
}
MediacontentVideoPtr result = priv->getObject();
- if (!result)
+ if (!result)
{
ThrowMsg(NullPointerException, "Private object is null");
}
return result;
}
-
+
JSValueRef JSVideo::getPropertyGeoLocation(
JSContextRef context,
JSObjectRef object,
{
Converter converter(context);
MediacontentVideoPtr video = getVideoObject(object);
- SimpleCoordinatesPtr geoPtr(new SimpleCoordinates(video->getVideoLatitude(),video->getVideoLongitude()));
+ SimpleCoordinatesPtr geoPtr(new SimpleCoordinates(video->getVideoLatitude(),video->getVideoLongitude()));
return JSSimpleCoordinates::createJSObject(context,geoPtr);
}
Catch(Exception)
{
Converter converter(context);
MediacontentVideoPtr video = getVideoObject(object);
-
+
DeviceAPI::Tizen::SimpleCoordinatesPtr geoLocation =
DeviceAPI::Tizen::JSSimpleCoordinates::getSimpleCoordinates(context, value);
{
LogDebug("entered");
Try
- {
+ {
Converter converter(context);
MediacontentVideoPtr video = getVideoObject(object);
JSObjectRef jsResult = JSCreateArrayObject(context, 0, NULL);
JSValueRef val = converter.toJSValueRef(artist);
if(!JSSetArrayElement(context, jsResult, i, val)){
- ThrowMsg(UnknownException, "Could not insert value into js array");
+ ThrowMsg(WrtDeviceApis::Commons::UnsupportedException, "Could not insert value into js array");
}
}
#define CONTENT_FEATURE_API_READ "http://tizen.org/privilege/content.read"
#define CONTENT_FEATURE_API_WRITE "http://tizen.org/privilege/content.write"
+#define CONTENT_FEATURE_API_MANAGER_WRITE "http://tizen.org/privilege/contentmanager.write"
+
#define CONTENT_DEVICE_CAP_READ "content.read"
#define CONTENT_DEVICE_CAP_WRITE "content.write"
+#define CONTENT_DEVICE_CAP_MANAGER_WRITE "contentmanager.write"
+
using namespace WrtDeviceApis::Commons;
*/
ACE_CREATE_DEVICE_CAP(DEVICE_CAP_CONTENT_READ, CONTENT_DEVICE_CAP_READ);
ACE_CREATE_DEVICE_CAP(DEVICE_CAP_CONTENT_WRITE, CONTENT_DEVICE_CAP_WRITE);
+ ACE_CREATE_DEVICE_CAP(DEVICE_CAP_CONTENT_MANAGER_WRITE, CONTENT_DEVICE_CAP_MANAGER_WRITE);
ACE_CREATE_DEVICE_CAPS_LIST(EMPTY_DEVICE_LIST);
ACE_CREATE_DEVICE_CAPS_LIST(DEVICE_LIST_CONTENT_READ);
ACE_CREATE_DEVICE_CAPS_LIST(DEVICE_LIST_CONTENT_WRITE);
ACE_ADD_DEVICE_CAP(DEVICE_LIST_CONTENT_WRITE, DEVICE_CAP_CONTENT_WRITE);
+ ACE_CREATE_DEVICE_CAPS_LIST(DEVICE_LIST_CONTENT_MANAGER_WRITE);
+ ACE_ADD_DEVICE_CAP(DEVICE_LIST_CONTENT_MANAGER_WRITE, DEVICE_CAP_CONTENT_MANAGER_WRITE);
+
/**
* Api Features
*/
ACE_CREATE_FEATURE(FEATURE_CONTENT_READ, CONTENT_FEATURE_API_READ);
ACE_CREATE_FEATURE(FEATURE_CONTENT_WRITE, CONTENT_FEATURE_API_WRITE);
+ ACE_CREATE_FEATURE(FEATURE_CONTENT_MANAGER_WRITE, CONTENT_FEATURE_API_MANAGER_WRITE);
ACE_CREATE_FEATURE_LIST(CONTENT_FEATURES_CONTENT_READ_WRITE);
ACE_ADD_API_FEATURE(CONTENT_FEATURES_CONTENT_READ_WRITE, FEATURE_CONTENT_READ);
ACE_CREATE_FEATURE_LIST(CONTENT_FEATURES_CONTENT_WRITE);
ACE_ADD_API_FEATURE(CONTENT_FEATURES_CONTENT_WRITE, FEATURE_CONTENT_WRITE);
+
+ ACE_CREATE_FEATURE_LIST(CONTENT_FEATURES_CONTENT_MANAGER_WRITE);
+ ACE_ADD_API_FEATURE(CONTENT_FEATURES_CONTENT_MANAGER_WRITE, FEATURE_CONTENT_MANAGER_WRITE);
#if 0
ACE_CREATE_FEATURE_LIST(CONTENT_FEATURES_CONTENT);
ACE_ADD_API_FEATURE(CONTENT_FEATURES_CONTENT,
FEATURE_CONTENT);
-
+
ACE_CREATE_FEATURE_LIST(CONTENT_FEATURES_READ);
ACE_ADD_API_FEATURE(CONTENT_FEATURES_READ,
FEATURE_CONTENT_READ);
CONTENT_FUNCTION_API_UNSET_CHANGE_LISTENER,
unsetListenerFunc));
+ //updateMetadata
+ AceFunction updateMetadataFunc = ACE_CREATE_FUNCTION(
+ FUNCTION_UPDATE_METADATA,
+ CONTENT_FUNCTION_API_UPDATE_METADATA,
+ CONTENT_FEATURES_CONTENT_MANAGER_WRITE,
+ DEVICE_LIST_CONTENT_MANAGER_WRITE);
+
+ contentMapping.insert(std::make_pair(
+ CONTENT_FUNCTION_API_UPDATE_METADATA,
+ updateMetadataFunc));
+
return contentMapping;
}
#define CONTENT_FUNCTION_API_SCAN_FILE "scanFile"
#define CONTENT_FUNCTION_API_SET_CHANGE_LISTENER "setChangeListener"
#define CONTENT_FUNCTION_API_UNSET_CHANGE_LISTENER "unsetChangeListener"
+#define CONTENT_FUNCTION_API_UPDATE_METADATA "updateMetadata"
+
DECLARE_FUNCTION_GETTER(Content);
}
Converter converter(context);
+
+ AceSecurityStatus status = FILESYSTEM_CHECK_ACCESS(FILESYSTEM_FUNCTION_API_TO_URI);
+ TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+
+
try {
- AceSecurityStatus status = FILESYSTEM_CHECK_ACCESS(FILESYSTEM_FUNCTION_API_TO_URI);
- TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
-
int widgetId = WrtAccessSingleton::Instance().getWidgetId();
return converter.toJSValueRef(privateObject->getObject()->getNode()->toUri(widgetId));
} catch(const WrtDeviceApis::Commons::ConversionException& ex) {
size_t index = 0;
JSValueRef reserveArguments[4];
+ AceSecurityStatus status = FILESYSTEM_CHECK_ACCESS(FILESYSTEM_FUNCTION_API_OPEN_STREAM);
+ TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+
+
try {
for (index = 0; index < 4; index++) {
std::string vpath = Utils::toVirtualPath(globalContext, path);
AccessModeInfo am = AccessModeInfo(mode, vpath);
- AceSecurityStatus status = FILESYSTEM_ACCESSMODE_CHECK_ACCESS(FILESYSTEM_FUNCTION_API_OPEN_STREAM, am);
+ status = FILESYSTEM_ACCESSMODE_CHECK_ACCESS(FILESYSTEM_FUNCTION_API_OPEN_STREAM, am);
TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
JSContextRef globalContext = privateObject->getContext();
AceSecurityStatus status = FILESYSTEM_CHECK_ACCESS(FILESYSTEM_FUNCTION_API_READ_AS_TEXT);
+ TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
size_t index = 0;
JSValueRef reserveArguments[3];
reserveArguments[index] = JSValueMakeUndefined(context);
}
- TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+
JSValueRef onSuccess = getFunction(globalContext, reserveArguments[0]);
JSValueRef onError = NULL;
JSValueRef reserveArguments[5];
JSCallbackManagerPtr cbm = JSCallbackManager::createObject(globalContext);
+ AceSecurityStatus status = FILESYSTEM_CHECK_ACCESS(FILESYSTEM_FUNCTION_API_COPY_TO);
+ TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+
+
try {
for (index = 0; index < 5; index++)
std::string virtualDestPath = Utils::toVirtualPath(globalContext, dest->getFullPath());
AccessModeInfo amode = AccessModeInfo(AM_WRITE, virtualDestPath);
- AceSecurityStatus status = FILESYSTEM_ACCESSMODE_CHECK_ACCESS(
+ status = FILESYSTEM_ACCESSMODE_CHECK_ACCESS(
FILESYSTEM_FUNCTION_API_COPY_TO,
amode);
JSValueRef reserveArguments[5];
JSCallbackManagerPtr cbm = JSCallbackManager::createObject(globalContext);
+ AceSecurityStatus status = FILESYSTEM_CHECK_ACCESS(FILESYSTEM_FUNCTION_API_MOVE_TO);
+ TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+
try {
for (index = 0; index < 5; index++) {
}
AceSecurityStatus status = FILESYSTEM_CHECK_ACCESS(FILESYSTEM_FUNCTION_API_CREATE_DIR);
-
TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
}
AceSecurityStatus status = FILESYSTEM_CHECK_ACCESS(FILESYSTEM_FUNCTION_API_CREATE_FILE);
-
TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch error");
}
+ AceSecurityStatus status = FILESYSTEM_CHECK_ACCESS(FILESYSTEM_FUNCTION_API_RESOLVE);
+ TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
if (privateObject->getObject()->getNode()->getType() != NT_DIRECTORY) {
return JSTizenExceptionFactory::postException(context, exception, JSTizenException::IO_ERROR, "IO error");
}
Converter converter(context);
+
+
+
+
try {
+
+
if (argc < 1) {
ThrowMsg(InvalidArgumentException, "Invalid path name");
}
- AceSecurityStatus status = FILESYSTEM_CHECK_ACCESS(FILESYSTEM_FUNCTION_API_RESOLVE);
- TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+
IPathPtr path = converter.toPath(argv[0]);
if (!privateObject) {
return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch error");
}
+
+ AceSecurityStatus status = FILESYSTEM_CHECK_ACCESS(FILESYSTEM_FUNCTION_API_DELETE_DIR);
+ TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
if (argc < 2) {
return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error");
JSValueRef reserveArguments[4];
JSCallbackManagerPtr cbm = JSCallbackManager::createObject(globalContext);
+
+
+
try {
for (index = 0; index < 4; index++) {
if (index < argc)
reserveArguments[index] = JSValueMakeUndefined(context);
}
- AceSecurityStatus status = FILESYSTEM_CHECK_ACCESS(FILESYSTEM_FUNCTION_API_DELETE_DIR);
-
- TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
JSValueRef onSuccess = NULL;
JSValueRef onError = NULL;
JSValueRef reserveArguments[3];
JSCallbackManagerPtr cbm = JSCallbackManager::createObject(globalContext);
+ AceSecurityStatus status = FILESYSTEM_CHECK_ACCESS(FILESYSTEM_FUNCTION_API_DELETE_FILE);
+ TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+
+
try {
for (index = 0; index < 3; index++) {
if (index < argc)
reserveArguments[index] = JSValueMakeUndefined(context);
}
- AceSecurityStatus status = FILESYSTEM_CHECK_ACCESS(FILESYSTEM_FUNCTION_API_DELETE_FILE);
-
- TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
if ((privateObject->getObject()->getNode()->getPermissions() & PERM_WRITE) == 0) {
return JSTizenExceptionFactory::postException(context, exception, JSTizenException::PERMISSION_DENIED_ERROR, "Permission denied error");
return JSValueMakeUndefined(context);
}
+ AceSecurityStatus status = FILESYSTEM_CHECK_ACCESS(FILESYSTEM_FUNCTION_API_GET_STORAGE);
+ TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+
if (argc < 2) {
return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error");
}
- AceSecurityStatus status = FILESYSTEM_CHECK_ACCESS(FILESYSTEM_FUNCTION_API_GET_STORAGE);
- TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
-
-
JSContextRef globalContext = privateObject->getContext();
ConverterPtr converter = ConverterFactory::getConverter(globalContext);
JSCallbackManagerPtr cbm = JSCallbackManager::createObject(globalContext);
return JSValueMakeUndefined(context);
}
- if (argc < 1) {
- return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error");
- }
-
-
AceSecurityStatus status = FILESYSTEM_CHECK_ACCESS(FILESYSTEM_FUNCTION_API_LIST_STORAGE);
TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+
-
+ if (argc < 1) {
+ return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error");
+ }
+
JSContextRef globalContext = privateObject->getContext();
ConverterPtr converter = ConverterFactory::getConverter(globalContext);
JSCallbackManagerPtr cbm = JSCallbackManager::createObject(globalContext);
return JSValueMakeUndefined(context);
}
+ AceSecurityStatus status = FILESYSTEM_CHECK_ACCESS(FILESYSTEM_FUNCTION_API_ADD_STORAGE_LISTENER);
+ TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+
if (argc < 1) {
return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "TYPE_MISMATCH_ERROR");
}
- AceSecurityStatus status = FILESYSTEM_CHECK_ACCESS(FILESYSTEM_FUNCTION_API_ADD_STORAGE_LISTENER);
- TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+
JSContextRef globalContext = privateObject->getContext();
JSCallbackManagerPtr cbm = JSCallbackManager::createObject(globalContext);
return JSValueMakeUndefined(context);
}
+ AceSecurityStatus status = FILESYSTEM_CHECK_ACCESS(FILESYSTEM_FUNCTION_API_REMOVE_STORAGE_LISTENER);
+ TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+
if (argc < 1) {
return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error");
}
- AceSecurityStatus status = FILESYSTEM_CHECK_ACCESS(FILESYSTEM_FUNCTION_API_REMOVE_STORAGE_LISTENER);
- TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+
JSContextRef globalContext = privateObject->getContext();
ConverterPtr converter = ConverterFactory::getConverter(globalContext);
PrivateObject* privateObject = static_cast<PrivateObject*>(JSObjectGetPrivate(thisObject));
if (!privateObject) {
return JSValueMakeUndefined(context);
+
}
+ AceSecurityStatus status = FILESYSTEM_CHECK_ACCESS(FILESYSTEM_FUNCTION_API_MGR_RESOLVE_ID);
+ TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+
if (argc < 2) {
return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error");
}
size_t index = 0;
JSValueRef reserveArguments[4];
JSCallbackManagerPtr cbm = JSCallbackManager::createObject(globalContext);
+
+
try {
for (index = 0; index < 4; index++) {
if (index < argc)
INSTALL(
DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ DESTINATION ${DESTINATION_HEADER_PREFIX}/messaging
FILES_MATCHING PATTERN "*.h" PATTERN "CMakeFiles" EXCLUDE
-)
+)
\ No newline at end of file
MSG_CLASS_TYPE_T classType; /**< Message class type. See enum _MSG_CLASS_TYPE_E */
msg_storage_id_t storageId; /**< Indicates where the message is saved. see enum _MSG_FOLDER_TYPE_E*/
msg_struct_list_s *addr_list;
+ GList *addressList;
char replyAddress[MAX_PHONE_NUMBER_LEN+1]; /**< Indicates the reply address. */
char subject[MAX_SUBJECT_LEN+1]; /**< Indicates the message subject. */
time_t displayTime; /**< Indicates the display time related to the specific operation. */
+ time_t scheduledTime; /**< Indicates the time to send scheduled message. */
msg_network_status_t networkStatus; /**< Indicates the network status of the message. */
msg_encode_type_t encodeType; /**< Indicates the string encoding type. */
bool bRead; /**< Indicates whether the message is read or not. */
size_t dataSize; /**< Indicates the data size. The unit is byte. */
void *pData; /**< Indicates the message payload information as a body. default character encoding is UTF-8*/
void *pMmsData; /**< Indicates the message payload information as a body. default character encoding is UTF-8*/
+ size_t mmsDataSize;
} MSG_MESSAGE_HIDDEN_S;
MSG_STATUS_REPORT_SMS, /**< SMS-STATUS-REPORT */
MSG_SYNCML_CP, /**< SyncML Message CP */
MSG_LBS_SMS, /**< LBS Message */
+ MSG_SOS_SMS, /**< SOS Message */
MSG_REJECT_SMS, /**< Reject Message */
MSG_CONCAT_SIM_SMS, /**< Concatenated Message in SIM */
pTmp->bBackup = dbHandle.getColumnToInt(index++);
pTmp->priority = dbHandle.getColumnToInt(index++);
pTmp->direction= dbHandle.getColumnToInt(index++);
- index++; // This field is reserved.
+ pTmp->addressList = NULL;
+
+ pTmp->scheduledTime = (time_t)dbHandle.getColumnToInt(index++);
dbHandle.getColumnToString(index++, MAX_SUBJECT_LEN, pTmp->subject);
pTmp->addr_list = addr_list;
+ // For GList *addressList
+ msg_struct_s *addrStruct = NULL;
+ MSG_ADDRESS_INFO_S *addrInfo = NULL;
+
+ addrStruct = new msg_struct_s;
+ memset(addrStruct, 0x00, sizeof(msg_struct_s));
+
+ addrStruct->type = MSG_STRUCT_ADDRESS_INFO;
+ addrStruct->data = new MSG_ADDRESS_INFO_S;
+ memset(addrStruct->data, 0x00, sizeof(MSG_ADDRESS_INFO_S));
+
+ addrInfo = (MSG_ADDRESS_INFO_S *)addrStruct->data;
+
+ addrInfo->addressType = address->addressType;
+ addrInfo->recipientType = address->recipientType;
+ addrInfo->contactId = address->contactId;
+ strncpy(addrInfo->addressVal, address->addressVal, MAX_ADDRESS_VAL_LEN);
+ strncpy(addrInfo->displayName, address->displayName, MAX_DISPLAY_NAME_LEN);
+ addrInfo->displayName[MAX_DISPLAY_NAME_LEN] = '\0';
+
+ pTmp->addressList = g_list_append(pTmp->addressList, addrStruct);
+
pTmp->attachCount = dbHandle.getColumnToInt(index++);
dbHandle.getColumnToString(index++, MSG_FILEPATH_LEN_MAX, pTmp->thumbPath);
JSAttributeFilter.cpp
JSAttributeRangeFilter.cpp
JSCompositeFilter.cpp
- JSAbstractFilterArray.cpp
JSSortMode.cpp
FilterConverter.cpp
JSSimpleCoordinates.cpp
#include "JSAttributeFilter.h"
#include "JSAttributeRangeFilter.h"
#include "JSCompositeFilter.h"
-#include "JSAbstractFilterArray.h"
#include "JSSortMode.h"
#include "FilterConverter.h"
ThrowMsg(NullPointerException, "JSValueRef is NULL.");
if(!JSValueIsObject(m_context, arg))
- ThrowMsg(InvalidArgumentException, "Filter is not object.");
+ return FilterPtr(NULL);
+ //ThrowMsg(InvalidArgumentException, "Filter is not object.");
if(JSCompositeFilter::isObjectOfClass(m_context, arg))
return DPL::StaticPointerCast<IFilter>(JSCompositeFilter::getCompositeFilter(m_context, arg));
if(JSAttributeRangeFilter::isObjectOfClass(m_context, arg))
return DPL::StaticPointerCast<IFilter>(JSAttributeRangeFilter::getAttributeRangeFilter(m_context, arg));
- ThrowMsg(WrtDeviceApis::Commons::ConversionException, "Wrong attribute");
+ //ThrowMsg(WrtDeviceApis::Commons::ConversionException, "Wrong attribute");
return FilterPtr(NULL);
}
if(arg == NULL)
ThrowMsg(NullPointerException, "FilterArray is NULL.");
- return WrtDeviceApis::CommonsJavaScript::JSUtils::makeObject(m_context, JSAbstractFilterArray::getClassRef(), arg);
+ int size = arg->size();
+
+ JSObjectRef resultObject = JSCreateArrayObject(m_context, 0, NULL);
+ if (!resultObject)
+ ThrowMsg(ConversionException, "Can not create array object.");
+
+ for(int i = 0; i < size; i++)
+ {
+ JSValueRef jsvalue = toJSValueRef(arg->at(i));
+ if(jsvalue == NULL)
+ continue;
+
+ if (!JSSetArrayElement(m_context, resultObject, i, jsvalue))
+ ThrowMsg(ConversionException, "Can not fill Filter array.");
+ }
+
+ return static_cast<JSValueRef>(resultObject);
}
FilterArrayPtr FilterConverter::toFilterArray(const JSValueRef& arg)
if(arg == NULL)
ThrowMsg(NullPointerException, "JSValueRef is NULL.");
- if(JSAbstractFilterArray::isObjectOfClass(m_context, arg))
- return JSAbstractFilterArray::getAbstractFilterArray(m_context, arg);
-
if(!JSIsArrayValue(m_context, arg))
ThrowMsg(InvalidArgumentException, "JSValueRef is not Array.");
for(unsigned int i=0; i<length; i++)
{
JSValueRef value = JSGetArrayElement(m_context, obj, i);
-
- if(JSValueIsNull(m_context, value) || JSValueIsUndefined(m_context, value)) {
- ThrowMsg(InvalidArgumentException, "CompositeFilter.filters has null elements.");
+ if(value == NULL)
+ {
+ LogWarning("value is NULL (" << i << ")");
+ continue;
}
- FilterPtr filter;
- Try {
- filter = toFilter(value);
- } Catch (Exception) {
- ThrowMsg(InvalidArgumentException, "Element is not an AbstractFilter (" << i << ")");
+ FilterPtr filter(NULL);
+ filter = toFilter(value);
+ if(filter == NULL)
+ {
+ LogWarning("Element is not an AbstractFilter (" << i << ")");
+ continue;
}
retVal->push_back(filter);
if(arg == NULL)
ThrowMsg(NullPointerException, "CompositeFilter is NULL.");
- return WrtDeviceApis::CommonsJavaScript::JSUtils::makeObject(m_context, JSCompositeFilter::getClassRef(), arg);
+ const ScopedJSStringRef jsStrFilters(JSStringCreateWithUTF8CString(TIZEN_FILTER_CONVERTER_ATTRIBUTE_FILTERS));
+ JSValueRef jsValueFilters = toJSValueRef(arg->getFilters());
+
+ JSObjectRef jsValueResult = WrtDeviceApis::CommonsJavaScript::JSUtils::makeObject(m_context, JSCompositeFilter::getClassRef(), arg);
+
+ JSObjectSetProperty(m_context, jsValueResult, jsStrFilters.get(), jsValueFilters, kJSPropertyAttributeNone, NULL);
+
+ return jsValueResult;
}
CompositeFilterPtr FilterConverter::toCompositeFilter(const JSValueRef& arg)
if(!JSCompositeFilter::isObjectOfClass(m_context, arg))
ThrowMsg(WrtDeviceApis::Commons::ConversionException, "Wrong attribute");
- return JSCompositeFilter::getCompositeFilter(m_context, arg);
+ CompositeFilterPtr compositeFilter = JSCompositeFilter::getCompositeFilter(m_context, arg);
+
+ FilterArrayPtr filters = FilterArrayPtr(new FilterArray());
+
+ const ScopedJSStringRef jsStrFilters(JSStringCreateWithUTF8CString(TIZEN_FILTER_CONVERTER_ATTRIBUTE_FILTERS));
+ JSObjectRef argObj = JSValueToObject(m_context, arg, NULL);
+ JSValueRef jsValueFilters = JSObjectGetProperty(m_context, argObj, jsStrFilters.get(), NULL);
+ filters = toFilterArray(jsValueFilters);
+ compositeFilter->setFilters(filters);
+
+ return compositeFilter;
}
JSValueRef FilterConverter::toJSValueRef(const AttributeFilterPtr& arg)
+++ /dev/null
-//
-// Tizen Web Device API
-// Copyright (c) 2012 Samsung Electronics Co., Ltd.
-//
-// Licensed under the Apache License, Version 2.0 (the License);
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-
-/**
- * @file JSAbstractFilterArray.cpp
- * @author Kisub Song (kisubs.song@samsung.com)
- * @version 0.1
- * @brief
- */
-
-#include <algorithm>
-#include <dpl/log/log.h>
-#include <CommonsJavaScript/ScopedJSStringRef.h>
-#include <JSTizenExceptionFactory.h>
-#include <JSTizenException.h>
-#include "FilterConverter.h"
-#include "JSAbstractFilterArray.h"
-
-#define FUNCTION_CONCAT "concat"
-#define FUNCTION_JOIN "join"
-#define FUNCTION_POP "pop"
-#define FUNCTION_PUSH "push"
-#define FUNCTION_REVERSE "reverse"
-#define FUNCTION_SHIFT "shift"
-#define FUNCTION_SLICE "slice"
-#define FUNCTION_SORT "sort"
-#define FUNCTION_SPLICE "splice"
-#define FUNCTION_TOSTRING "toString"
-#define FUNCTION_UNSHIFT "unshift"
-#define FUNCTION_VALUEOF "valueOf"
-#define ARRAY "Array"
-#define ATTRIBUTE_LENGTH "length"
-#define FUNCTION_CONSTRUCTOR "constructor"
-
-namespace DeviceAPI {\rnamespace Tizen {
-
-using namespace DeviceAPI::Common;
-using namespace DeviceAPI::Tizen;
-using namespace WrtDeviceApis::CommonsJavaScript;
-
-JSClassDefinition JSAbstractFilterArray::m_classInfo = {
- 0,
- kJSClassAttributeNone,
- ARRAY,
- 0,
- m_property,
- m_function,
- initialize,
- finalize,
- hasProperty,
- getProperty,
- setProperty,
- NULL, //deleteProperty,
- getPropertyNames,
- NULL, //callAsFunction,
- NULL, //callAsConstructor,
- NULL, //hasInstance,
- NULL, //convertToType,
-};
-
-JSStaticValue JSAbstractFilterArray::m_property[] = {
- { ATTRIBUTE_LENGTH, getLength, NULL, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete },
- { 0, 0, 0, 0 }
-};
-
-JSStaticFunction JSAbstractFilterArray::m_function[] = {
- { FUNCTION_CONCAT, concat, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete },
- { FUNCTION_JOIN, join, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete },
- { FUNCTION_POP, pop, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete },
- { FUNCTION_PUSH, push, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete },
- { FUNCTION_REVERSE, reverse, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete },
- { FUNCTION_SHIFT, shift, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete },
- { FUNCTION_SLICE, slice, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete },
- { FUNCTION_SORT, sort, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete },
- { FUNCTION_SPLICE, splice, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete },
- { FUNCTION_TOSTRING, toString, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete },
- { FUNCTION_UNSHIFT, unshift, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete },
- { FUNCTION_VALUEOF, valueOf, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete },
- { FUNCTION_CONSTRUCTOR, constructor, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete },
- { 0, 0, 0 }
-};
-
-JSClassRef JSAbstractFilterArray::m_jsClassRef = JSClassCreate(
- JSAbstractFilterArray::getClassInfo());
-
-JSValueRef JSAbstractFilterArray::getLength(JSContextRef context,
- JSObjectRef object,
- JSStringRef propertyName,
- JSValueRef* exception)
-{
- //LogDebug("enter");
- Try
- {
- JSAbstractFilterArrayPriv* priv =
- static_cast<JSAbstractFilterArrayPriv*>(JSObjectGetPrivate(object));
- if (!priv) {
- Throw(WrtDeviceApis::Commons::NullPointerException);
- }
- FilterArrayPtr filters = priv->getObject();
- if (filters) {
- FilterConverterFactory::ConverterType converter =
- FilterConverterFactory::getConverter(context);
- return converter->toJSValueRef(filters->size());
- }
- }
- Catch(WrtDeviceApis::Commons::Exception)
- {
- LogError("invalid conversion");
- }
- return JSValueMakeUndefined(context);
-}
-
-bool JSAbstractFilterArray::isObjectOfClass(JSContextRef context, JSValueRef value)
-{
- return JSValueIsObjectOfClass(context, value, getClassRef());
-}
-
-FilterArrayPtr JSAbstractFilterArray::getAbstractFilterArray(JSContextRef context, JSValueRef value)
-{
- if (!isObjectOfClass(context, value)) {
- Throw(WrtDeviceApis::Commons::InvalidArgumentException);
- }
- JSObjectRef object = JSValueToObject(context, value, NULL);
- if (!object) {
- Throw(WrtDeviceApis::Commons::InvalidArgumentException);
- }
- JSAbstractFilterArrayPriv *priv = static_cast<JSAbstractFilterArrayPriv*>(JSObjectGetPrivate(object));
- if (!priv) {
- Throw(WrtDeviceApis::Commons::NullPointerException);
- }
- return priv->getObject();
-}
-
-JSObjectRef JSAbstractFilterArray::createArray(JSContextRef context,
- const FilterArrayPtr &filters)
-{
- JSAbstractFilterArrayPriv *priv = new JSAbstractFilterArrayPriv(context, filters);
- return JSObjectMake(context, getClassRef(), priv);
-}
-
-const JSClassDefinition* JSAbstractFilterArray::getClassInfo()
-{
- return &(m_classInfo);
-}
-
-JSClassRef JSAbstractFilterArray::getClassRef()
-{
- if (!m_jsClassRef) {
- m_jsClassRef = JSClassCreate(&m_classInfo);
- }
- return m_jsClassRef;
-}
-
-void JSAbstractFilterArray::initialize(JSContextRef context,
- JSObjectRef object)
-{
- //LogDebug("enter");
-}
-
-void JSAbstractFilterArray::finalize(JSObjectRef object)
-{
- //LogDebug("enter");
- JSAbstractFilterArrayPriv* priv =
- static_cast<JSAbstractFilterArrayPriv*>(JSObjectGetPrivate(object));
- delete priv;
- JSObjectSetPrivate(object, NULL);
-}
-
-bool JSAbstractFilterArray::hasProperty(JSContextRef context,
- JSObjectRef object,
- JSStringRef propertyName)
-{
- //LogDebug("enter");
- FilterConverterFactory::ConverterType converter =
- FilterConverterFactory::getConverter(context);
- Try
- {
- size_t index = converter->toSizeT(propertyName);
- JSAbstractFilterArrayPriv* priv =
- static_cast<JSAbstractFilterArrayPriv*>(JSObjectGetPrivate(object));
- if (!priv) {
- Throw(WrtDeviceApis::Commons::NullPointerException);
- }
- FilterArrayPtr filters = priv->getObject();
- if (index < filters->size()) {
- return true;
- }
- }
- Catch(WrtDeviceApis::Commons::Exception)
- {
- //not reporting error is intended
- }
- return false;
-}
-
-JSValueRef JSAbstractFilterArray::getProperty(JSContextRef context,
- JSObjectRef object,
- JSStringRef propertyName,
- JSValueRef* exception)
-{
- //LogDebug("enter");
- FilterConverterFactory::ConverterType converter =
- FilterConverterFactory::getConverter(context);
- Try
- {
- size_t index = converter->toSizeT(propertyName);
- JSAbstractFilterArrayPriv* priv =
- static_cast<JSAbstractFilterArrayPriv*>(JSObjectGetPrivate(object));
- if (!priv) {
- Throw(WrtDeviceApis::Commons::NullPointerException);
- }
- FilterArrayPtr filters = priv->getObject();
- if (index < filters->size()) {
- FilterPtr result = filters->at(index);
- if (result) {
- return converter->toJSValueRef(result);
- }
- }
- }
- Catch(WrtDeviceApis::Commons::Exception)
- {
- LogError("invalid property");
- }
- return JSValueMakeUndefined(context);
-}
-
-bool JSAbstractFilterArray::setProperty(JSContextRef context,
- JSObjectRef object,
- JSStringRef propertyName,
- JSValueRef value,
- JSValueRef* exception)
-{
- //LogDebug("enter");
- FilterConverterFactory::ConverterType converter =
- FilterConverterFactory::getConverter(context);
- Try
- {
- size_t index = converter->toSizeT(propertyName);
- FilterPtr filter;
- if (!JSValueIsUndefined(context, value)) {
- filter = converter->toFilter(value);
- }
- JSAbstractFilterArrayPriv* priv =
- static_cast<JSAbstractFilterArrayPriv*>(JSObjectGetPrivate(object));
- if (!priv) {
- Throw(WrtDeviceApis::Commons::NullPointerException);
- }
- FilterArrayPtr filters = priv->getObject();
- if (!filters) {
- Throw(WrtDeviceApis::Commons::NullPointerException);
- }
- if (filters->size() <= index) {
- filters->resize(index + 1);
- }
- (*filters)[index] = filter;
- return true;
- }
- Catch(WrtDeviceApis::Commons::Exception)
- {
- LogError("error occured");
- JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
- }
- return false;
-}
-
-void JSAbstractFilterArray::getPropertyNames(JSContextRef context,
- JSObjectRef object,
- JSPropertyNameAccumulatorRef propertyNames)
-{
- FilterConverterFactory::ConverterType converter =
- FilterConverterFactory::getConverter(context);
- Try
- {
- JSAbstractFilterArrayPriv* priv =
- static_cast<JSAbstractFilterArrayPriv*>(JSObjectGetPrivate(object));
- if (!priv) {
- Throw(WrtDeviceApis::Commons::NullPointerException);
- }
- FilterArrayPtr filters = priv->getObject();
-
- int count = filters->size();
-
- for(int i=0; i < count; i++)
- {
- ScopedJSStringRef name(converter->toJSStringRef(converter->toString(i)));
- JSPropertyNameAccumulatorAddName(propertyNames, name.get());
- }
- }
- Catch(WrtDeviceApis::Commons::Exception)
- {
- LogError("invalid property");
- }
-}
-
-JSValueRef JSAbstractFilterArray::concat(JSContextRef context,
- JSObjectRef function,
- JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception)
-{
- //LogDebug("enter");
- Try
- {
- FilterArrayPtr filters = FilterArrayPtr(new FilterArray());
- JSAbstractFilterArrayPriv *newPrivateObject = new JSAbstractFilterArrayPriv(context, filters);
- JSValueRef result = JSObjectMake(context, getClassRef(), newPrivateObject);
-
- //copy current filters
- JSAbstractFilterArrayPriv* priv =
- static_cast<JSAbstractFilterArrayPriv*>(JSObjectGetPrivate(thisObject));
- FilterArrayPtr currentWebSites = priv->getObject();
- for (size_t i = 0; i < currentWebSites->size(); ++i) {
- filters->push_back(currentWebSites->at(i));
- }
-
- //copy submitted arrays
- FilterConverterFactory::ConverterType converter =
- FilterConverterFactory::getConverter(context);
- for (size_t i = 0; i < argumentCount; ++i) {
- if (!JSIsArrayValue(context, arguments[i])) {
- Throw(WrtDeviceApis::Commons::ConversionException);
- }
- // process array of strings
- JSObjectRef arrayObj = converter->toJSObjectRef(arguments[i]);
- unsigned int len = JSGetArrayLength(context, arrayObj);
- for (unsigned int e = 0; e < len; ++e) {
- JSValueRef att = JSGetArrayElement(context, arrayObj, e);
- filters->push_back(converter->toFilter(att));
- }
- }
- return result;
- }
- Catch(WrtDeviceApis::Commons::Exception)
- {
- LogError("error occured");
- }
- return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
-}
-
-JSValueRef JSAbstractFilterArray::join(JSContextRef context,
- JSObjectRef function,
- JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception)
-{
- //LogDebug("entered");
- Try
- {
- std::string result;
- std::string separator(",");
- FilterConverterFactory::ConverterType converter =
- FilterConverterFactory::getConverter(context);
- JSAbstractFilterArrayPriv* priv =
- static_cast<JSAbstractFilterArrayPriv*>(JSObjectGetPrivate(thisObject));
- FilterArrayPtr currentWebSites = priv->getObject();
- if (argumentCount > 0 && JSValueIsString(context, arguments[0])) {
- separator = converter->toString(arguments[0]);
- }
- for (size_t i = 0; i < currentWebSites->size(); ++i) {
- if (i != 0) {
- result += separator;
- }
- //FIXME : to be changed to support join
- //result += currentWebSites->at(i);
- }
- return converter->toJSValueRef(result);
- }
- Catch(WrtDeviceApis::Commons::Exception)
- {
- LogError("error occured");
- }
- return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
-}
-
-JSValueRef JSAbstractFilterArray::pop(JSContextRef context,
- JSObjectRef function,
- JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception)
-{
- //LogDebug("entered");
- Try
- {
- FilterConverterFactory::ConverterType converter =
- FilterConverterFactory::getConverter(context);
- JSAbstractFilterArrayPriv* priv =
- static_cast<JSAbstractFilterArrayPriv*>(JSObjectGetPrivate(thisObject));
- FilterArrayPtr currentWebSites = priv->getObject();
- if (currentWebSites->size() > 0) {
- FilterPtr result = currentWebSites->at(
- currentWebSites->size() - 1);
- currentWebSites->pop_back();
- return converter->toJSValueRef(result);
- }
- }
- Catch(WrtDeviceApis::Commons::Exception)
- {
- LogError("error occured");
- }
- return JSValueMakeUndefined(context);
-}
-
-JSValueRef JSAbstractFilterArray::push(JSContextRef context,
- JSObjectRef function,
- JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception)
-{
- //LogDebug("entered");
- Try
- {
- FilterConverterFactory::ConverterType converter =
- FilterConverterFactory::getConverter(context);
- JSAbstractFilterArrayPriv* priv =
- static_cast<JSAbstractFilterArrayPriv*>(JSObjectGetPrivate(thisObject));
- FilterArrayPtr currentWebSites = priv->getObject();
- for (size_t i = 0; i < argumentCount; ++i) {
- currentWebSites->push_back(converter->toFilter(arguments[i]));
- }
- return converter->toJSValueRef(currentWebSites->size());
- }
- Catch(WrtDeviceApis::Commons::Exception)
- {
- LogError("error occured");
- }
- return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
-}
-
-JSValueRef JSAbstractFilterArray::reverse(JSContextRef context,
- JSObjectRef function,
- JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception)
-{
- //LogDebug("entered");
- Try
- {
- FilterConverterFactory::ConverterType converter =
- FilterConverterFactory::getConverter(context);
- JSAbstractFilterArrayPriv* priv =
- static_cast<JSAbstractFilterArrayPriv*>(JSObjectGetPrivate(thisObject));
- FilterArrayPtr currentWebSites = priv->getObject();
- std::reverse(currentWebSites->begin(), currentWebSites->end());
- return thisObject;
- }
- Catch(WrtDeviceApis::Commons::Exception)
- {
- LogError("error occured");
- }
- return JSValueMakeUndefined(context);
-}
-
-JSValueRef JSAbstractFilterArray::shift(JSContextRef context,
- JSObjectRef function,
- JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception)
-{
- //LogDebug("entered");
- Try
- {
- FilterConverterFactory::ConverterType converter =
- FilterConverterFactory::getConverter(context);
- JSAbstractFilterArrayPriv* priv =
- static_cast<JSAbstractFilterArrayPriv*>(JSObjectGetPrivate(thisObject));
- FilterArrayPtr currentWebSites = priv->getObject();
- if (currentWebSites->size() > 0) {
- FilterPtr result = currentWebSites->at(0);
- currentWebSites->erase(currentWebSites->begin());
- return converter->toJSValueRef(result);
- }
- }
- Catch(WrtDeviceApis::Commons::Exception)
- {
- LogError("error occured");
- }
- return JSValueMakeUndefined(context);
-}
-
-JSValueRef JSAbstractFilterArray::slice(JSContextRef context,
- JSObjectRef function,
- JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception)
-{
- //LogDebug("enter");
- Try
- {
- if (argumentCount < 1) {
- return JSValueMakeUndefined(context);
- }
- FilterConverterFactory::ConverterType converter =
- FilterConverterFactory::getConverter(context);
- FilterArrayPtr filters = FilterArrayPtr(new FilterArray());
- JSAbstractFilterArrayPriv *newPrivateObject = new JSAbstractFilterArrayPriv(
- context,
- filters);
- JSValueRef result = JSObjectMake(context,
- getClassRef(), newPrivateObject);
-
- //copy current filters
- JSAbstractFilterArrayPriv* priv =
- static_cast<JSAbstractFilterArrayPriv*>(JSObjectGetPrivate(thisObject));
- FilterArrayPtr currentWebSites = priv->getObject();
- std::size_t first = converter->toSizeT(arguments[0]);
- std::size_t last = currentWebSites->size() - 1;
- if (argumentCount > 1) {
- last = converter->toSizeT(arguments[1]);
- if (last >= currentWebSites->size()) {
- last = currentWebSites->size() - 1;
- }
- }
- for (size_t i = first; i <= last; ++i) {
- filters->push_back(currentWebSites->at(i));
- }
-
- return result;
- }
- Catch(WrtDeviceApis::Commons::Exception)
- {
- LogError("error occured");
- }
- return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
-}
-
-JSValueRef JSAbstractFilterArray::sort(JSContextRef context,
- JSObjectRef function,
- JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception)
-{
- //LogDebug("entered");
- Try
- {
- FilterConverterFactory::ConverterType converter =
- FilterConverterFactory::getConverter(context);
- JSAbstractFilterArrayPriv* priv =
- static_cast<JSAbstractFilterArrayPriv*>(JSObjectGetPrivate(thisObject));
- FilterArrayPtr currentWebSites = priv->getObject();
- std::sort(currentWebSites->begin(), currentWebSites->end());
- return thisObject;
- }
- Catch(WrtDeviceApis::Commons::Exception)
- {
- LogError("error occured");
- }
- return JSValueMakeUndefined(context);
-}
-
-JSValueRef JSAbstractFilterArray::splice(JSContextRef context,
- JSObjectRef function,
- JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception)
-{
- //LogDebug("entered");
- return JSValueMakeUndefined(context);
-}
-
-JSValueRef JSAbstractFilterArray::toString(JSContextRef context,
- JSObjectRef function,
- JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception)
-{
- //LogDebug("entered");
- return join(context, function, thisObject, 0, arguments, exception);
-}
-
-JSValueRef JSAbstractFilterArray::unshift(JSContextRef context,
- JSObjectRef function,
- JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception)
-{
- //LogDebug("entered");
- return JSValueMakeUndefined(context);
-}
-
-JSValueRef JSAbstractFilterArray::valueOf(JSContextRef context,
- JSObjectRef function,
- JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception)
-{
- //LogDebug("entered");
- return JSValueMakeUndefined(context);
-}
-
-JSValueRef JSAbstractFilterArray::constructor(JSContextRef context,
- JSObjectRef function,
- JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception)
-{
- // To determine this object as array
- WrtDeviceApis::CommonsJavaScript::ScopedJSStringRef json(JSStringCreateWithUTF8CString("[]"));
- JSValueRef array = JSValueMakeFromJSONString(context, json.get());
- WrtDeviceApis::CommonsJavaScript::ScopedJSStringRef constructorStr(JSStringCreateWithUTF8CString("constructor"));
- JSObjectRef arrayObject = JSValueToObject(context, array, NULL);
- JSValueRef constructorValue = JSObjectGetProperty(context, arrayObject, constructorStr.get(), NULL);
- return constructorValue;
-}
-
-} // Tizen
-} // DeviceAPI
-
+++ /dev/null
-//
-// Tizen Web Device API
-// Copyright (c) 2012 Samsung Electronics Co., Ltd.
-//
-// Licensed under the Apache License, Version 2.0 (the License);
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-
-/**
- * @file JSAbstractFilterArray.h
- * @author Kisub Song (kisubs.song@samsung.com)
- * @version 0.1
- * @brief
- */
-
-#ifndef _TIZEN_TIZEN_JS_ABSTRACT_FILTER_ARRAY_H_
-#define _TIZEN_TIZEN_JS_ABSTRACT_FILTER_ARRAY_H_
-
-#include <JavaScriptCore/JavaScript.h>
-#include <CommonsJavaScript/PrivateObject.h>
-#include "IFilter.h"
-
-namespace DeviceAPI {\rnamespace Tizen {
-
-typedef WrtDeviceApis::CommonsJavaScript::PrivateObjectT< DeviceAPI::Tizen::FilterArrayPtr >::Type JSAbstractFilterArrayPriv;
-
-class JSAbstractFilterArray
-{
-public:
-
- static const JSClassDefinition* getClassInfo();
-
- static JSClassRef getClassRef();
-
- static JSObjectRef createArray(JSContextRef context,
- const DeviceAPI::Tizen::FilterArrayPtr &filterArray);
-
- static bool isObjectOfClass(JSContextRef context, JSValueRef value);
-
- static DeviceAPI::Tizen::FilterArrayPtr getAbstractFilterArray(JSContextRef context, JSValueRef value);
-
-private:
-
- /**
- * The callback invoked when an object is first created.
- */
- static void initialize(JSContextRef context,
- JSObjectRef object);
-
- /**
- * The callback invoked when an object is finalized.
- */
- static void finalize(JSObjectRef object);
-
- static JSValueRef getLength(JSContextRef context,
- JSObjectRef object,
- JSStringRef propertyName,
- JSValueRef* exception);
-
- static bool hasProperty(JSContextRef context,
- JSObjectRef object,
- JSStringRef propertyName);
-
- static JSValueRef getProperty(JSContextRef context,
- JSObjectRef object,
- JSStringRef propertyName,
- JSValueRef* exception);
-
- static bool setProperty(JSContextRef context,
- JSObjectRef object,
- JSStringRef propertyName,
- JSValueRef value,
- JSValueRef* exception);
-
- static void getPropertyNames(JSContextRef context,
- JSObjectRef object,
- JSPropertyNameAccumulatorRef propertyNames);
-
- static JSValueRef concat(JSContextRef context,
- JSObjectRef function,
- JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception);
- static JSValueRef join(JSContextRef context,
- JSObjectRef function,
- JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception);
- static JSValueRef pop(JSContextRef context,
- JSObjectRef function,
- JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception);
- static JSValueRef push(JSContextRef context,
- JSObjectRef function,
- JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception);
- static JSValueRef reverse(JSContextRef context,
- JSObjectRef function,
- JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception);
- static JSValueRef shift(JSContextRef context,
- JSObjectRef function,
- JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception);
- static JSValueRef slice(JSContextRef context,
- JSObjectRef function,
- JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception);
- static JSValueRef sort(JSContextRef context,
- JSObjectRef function,
- JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception);
- static JSValueRef splice(JSContextRef context,
- JSObjectRef function,
- JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception);
- static JSValueRef toString(JSContextRef context,
- JSObjectRef function,
- JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception);
- static JSValueRef unshift(JSContextRef context,
- JSObjectRef function,
- JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception);
- static JSValueRef valueOf(JSContextRef context,
- JSObjectRef function,
- JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception);
- static JSValueRef constructor(JSContextRef context,
- JSObjectRef function,
- JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception);
-
- static bool checkValue(const std::string &value);
-
- static JSClassRef m_jsClassRef;
- /**
- * This structure describes a statically declared function property.
- */
- static JSStaticFunction m_function[];
-
- /**
- * This structure contains properties and callbacks that define a type of object.
- */
- static JSClassDefinition m_classInfo;
-
- /**
- * This member variable contains the initialization values for the static properties of this class.
- * The values are given according to the data structure JSPropertySpec
- */
- static JSStaticValue m_property[];
-};
-
-} // Tizen
-} // DeviceAPI
-
-
-#endif // _TIZEN_TIZEN_JS_ABSTRACT_FILTER_ARRAY_H_
NULL, //DeleteProperty,
NULL, //getPropertyNames,
NULL, //CallAsFunction,
- constructor, //CallAsConstructor,
+ NULL, //CallAsConstructor,
NULL, //HasInstance,
NULL, //ConvertToType,
};
return jsObjectRef;
}
-void JSAttributeFilter::Initialize(JSContextRef context, JSObjectRef object)
-{
- if (!JSObjectGetPrivate(object))
- {
- AttributeFilterPtr filter(new AttributeFilter("", MATCH_NONE, AnyPtr(NULL)));
- JSAttributeFilterPriv *priv = new JSAttributeFilterPriv(context, AttributeFilterPtr(filter));
- if (!JSObjectSetPrivate(object, priv)) {
- delete priv;
- }
- }
-}
-
-void JSAttributeFilter::Finalize(JSObjectRef object)
-{
- JSAttributeFilterPriv *priv = static_cast<JSAttributeFilterPriv*>(JSObjectGetPrivate(object));
-
- if (priv != NULL)
- {
- delete (priv);
- }
-
- priv = NULL;
-}
-
-AttributeFilterPtr JSAttributeFilter::getPrivData(JSObjectRef object)
-{
- LogDebug("entered");
- JSAttributeFilterPriv *priv = static_cast<JSAttributeFilterPriv*>(JSObjectGetPrivate(object));
- if (!priv) {
- ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is null");
- }
- AttributeFilterPtr result = priv->getObject();
- if (!result) {
- ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is null");
- }
- return result;
-}
-
JSObjectRef JSAttributeFilter::constructor(JSContextRef context,
JSObjectRef constructor,
size_t argumentCount,
bool js2ndParamIsString = false;
bool js3rdParamIsValue = false;
-// AceSecurityStatus status = CONTACT_CHECK_ACCESS(CONTACT_FUNCTION_API_ADD);
-// TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
-
- JSAttributeFilterPriv *priv = static_cast<JSAttributeFilterPriv*>(JSObjectGetPrivate(constructor));
- if (!priv) {
- ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is null");
- }
- JSContextRef gContext = priv->getContext();
-
-// JSContextRef gContext = JSGlobalContextFactory::getInstance()->get();
-
BasicValidator validator = BasicValidatorFactory::getValidator(context, exception);
Try {
if (argumentCount < 1)
ThrowMsg(InvalidArgumentException, "Wrong arguments count.");
- if (!JSValueIsString(gContext, arguments[0]))
+ if (!JSValueIsString(context, arguments[0]))
ThrowMsg(InvalidArgumentException, "1st argument is not string.");
if (argumentCount >= 2)
{
- if (JSValueIsString(gContext, arguments[1]))
+ if (JSValueIsString(context, arguments[1]))
js2ndParamIsString = true;
if (!js2ndParamIsString &&
- !JSValueIsNull(gContext, arguments[1]) &&
- !JSValueIsUndefined(gContext, arguments[1]))
+ !JSValueIsNull(context, arguments[1]) &&
+ !JSValueIsUndefined(context, arguments[1]))
ThrowMsg(InvalidArgumentException, "2nd argument is not array.");
}
if (argumentCount >= 3)
{
- if (!JSValueIsNull(gContext, arguments[2]) && !JSValueIsUndefined(gContext, arguments[2]))
+ if (!JSValueIsNull(context, arguments[2]) && !JSValueIsUndefined(context, arguments[2]))
js3rdParamIsValue = true;
}
return NULL;
}
- FilterConverterFactory::ConverterType converter = FilterConverterFactory::getConverter(gContext);
+ FilterConverterFactory::ConverterType converter = FilterConverterFactory::getConverter(context);
std::string attributeName;
MatchFlag matchFlag;
JSObjectRef jsobject;
Try {
- jsobject = createJSObject(gContext, attributeFilter);
+ jsobject = createJSObject(context, attributeFilter);
} Catch(Exception) {
LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
*exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong arguments");
return jsobject;
}
+void JSAttributeFilter::Initialize(JSContextRef context, JSObjectRef object)
+{
+ if (!JSObjectGetPrivate(object))
+ {
+ AttributeFilterPtr filter(new AttributeFilter("", MATCH_NONE, AnyPtr(NULL)));
+ JSAttributeFilterPriv *priv = new JSAttributeFilterPriv(context, AttributeFilterPtr(filter));
+ if (!JSObjectSetPrivate(object, priv)) {
+ delete priv;
+ }
+ }
+}
+
+void JSAttributeFilter::Finalize(JSObjectRef object)
+{
+ JSAttributeFilterPriv *priv = static_cast<JSAttributeFilterPriv*>(JSObjectGetPrivate(object));
+
+ if (priv != NULL)
+ {
+ delete (priv);
+ }
+
+ priv = NULL;
+}
+
+AttributeFilterPtr JSAttributeFilter::getPrivData(JSObjectRef object)
+{
+ LogDebug("entered");
+ JSAttributeFilterPriv *priv = static_cast<JSAttributeFilterPriv*>(JSObjectGetPrivate(object));
+ if (!priv) {
+ ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is null");
+ }
+ AttributeFilterPtr result = priv->getObject();
+ if (!result) {
+ ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is null");
+ }
+ return result;
+}
+
JSValueRef JSAttributeFilter::getAttributeName(JSContextRef context,
JSObjectRef object,
JSStringRef propertyName,
static JSObjectRef createJSObject(JSContextRef context, DeviceAPI::Tizen::AttributeFilterPtr privateData);
+ static JSObjectRef constructor(JSContextRef context,
+ JSObjectRef constructor,
+ size_t argumentCount,
+ const JSValueRef arguments[],
+ JSValueRef* exception);
+
private:
/**
* The callback invoked when an object is first created.
static DeviceAPI::Tizen::AttributeFilterPtr getPrivData(JSObjectRef object);
- static JSObjectRef constructor(JSContextRef context,
- JSObjectRef constructor,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception);
-
static JSValueRef getAttributeName(JSContextRef context,
JSObjectRef object,
JSStringRef propertyName,
NULL, //DeleteProperty,
NULL, //getPropertyNames,
NULL, //CallAsFunction,
- constructor, //CallAsConstructor,
+ NULL, //CallAsConstructor,
NULL, //HasInstance,
NULL, //ConvertToType,
};
return jsObjectRef;
}
-void JSAttributeRangeFilter::Initialize(JSContextRef context, JSObjectRef object)
-{
- if (!JSObjectGetPrivate(object))
- {
- AttributeRangeFilterPtr filter(new AttributeRangeFilter("", AnyPtr(NULL), AnyPtr(NULL)));
- JSAttributeRangeFilterPriv *priv = new JSAttributeRangeFilterPriv(context, AttributeRangeFilterPtr(filter));
- if (!JSObjectSetPrivate(object, priv)) {
- delete priv;
- }
- }
-}
-
-void JSAttributeRangeFilter::Finalize(JSObjectRef object)
-{
- JSAttributeRangeFilterPriv *priv = static_cast<JSAttributeRangeFilterPriv*>(JSObjectGetPrivate(object));
-
- if (priv != NULL)
- {
- delete (priv);
- }
-
- priv = NULL;
-}
-
-AttributeRangeFilterPtr JSAttributeRangeFilter::getPrivData(JSObjectRef object)
-{
- LogDebug("entered");
- JSAttributeRangeFilterPriv *priv = static_cast<JSAttributeRangeFilterPriv*>(JSObjectGetPrivate(object));
- if (!priv) {
- ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is null");
- }
- AttributeRangeFilterPtr result = priv->getObject();
- if (!result) {
- ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is null");
- }
- return result;
-}
-
JSObjectRef JSAttributeRangeFilter::constructor(JSContextRef context,
JSObjectRef constructor,
size_t argumentCount,
bool js2ndParamIsValue = false;
bool js3rdParamIsValue = false;
-// AceSecurityStatus status = CONTACT_CHECK_ACCESS(CONTACT_FUNCTION_API_ADD);
-// TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
-
- JSAttributeRangeFilterPriv *priv = static_cast<JSAttributeRangeFilterPriv*>(JSObjectGetPrivate(constructor));
- if (!priv) {
- ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is null");
- }
- JSContextRef gContext = priv->getContext();
-
-// JSContextRef gContext = JSGlobalContextFactory::getInstance()->get();
-
- BasicValidator validator = BasicValidatorFactory::getValidator(gContext, exception);
+ BasicValidator validator = BasicValidatorFactory::getValidator(context, exception);
Try {
if (argumentCount < 1)
ThrowMsg(InvalidArgumentException, "Wrong arguments count.");
- if (!JSValueIsString(gContext, arguments[0]))
+ if (!JSValueIsString(context, arguments[0]))
ThrowMsg(InvalidArgumentException, "1st argument is not string.");
// 2nd and 3rd argument can be any type.
if (argumentCount >= 2)
{
- if(!JSValueIsUndefined(gContext, arguments[1]) && !JSValueIsNull(gContext, arguments[1]))
+ if(!JSValueIsUndefined(context, arguments[1]) && !JSValueIsNull(context, arguments[1]))
js2ndParamIsValue = true;
}
if (argumentCount >= 3)
{
- if(!JSValueIsUndefined(gContext, arguments[2]) && !JSValueIsNull(gContext, arguments[2]))
+ if(!JSValueIsUndefined(context, arguments[2]) && !JSValueIsNull(context, arguments[2]))
js3rdParamIsValue = true;
}
return NULL;
}
- FilterConverterFactory::ConverterType converter = FilterConverterFactory::getConverter(gContext);
+ FilterConverterFactory::ConverterType converter = FilterConverterFactory::getConverter(context);
std::string attributeName;
AnyPtr initialValue(NULL);
JSObjectRef jsobject;
Try {
- jsobject = createJSObject(gContext, attributeRangeFilter);
+ jsobject = createJSObject(context, attributeRangeFilter);
} Catch(Exception) {
LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
*exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong arguments");
return jsobject;
}
+void JSAttributeRangeFilter::Initialize(JSContextRef context, JSObjectRef object)
+{
+ if (!JSObjectGetPrivate(object))
+ {
+ AttributeRangeFilterPtr filter(new AttributeRangeFilter("", AnyPtr(NULL), AnyPtr(NULL)));
+ JSAttributeRangeFilterPriv *priv = new JSAttributeRangeFilterPriv(context, AttributeRangeFilterPtr(filter));
+ if (!JSObjectSetPrivate(object, priv)) {
+ delete priv;
+ }
+ }
+}
+
+void JSAttributeRangeFilter::Finalize(JSObjectRef object)
+{
+ JSAttributeRangeFilterPriv *priv = static_cast<JSAttributeRangeFilterPriv*>(JSObjectGetPrivate(object));
+
+ if (priv != NULL)
+ {
+ delete (priv);
+ }
+
+ priv = NULL;
+}
+
+AttributeRangeFilterPtr JSAttributeRangeFilter::getPrivData(JSObjectRef object)
+{
+ LogDebug("entered");
+ JSAttributeRangeFilterPriv *priv = static_cast<JSAttributeRangeFilterPriv*>(JSObjectGetPrivate(object));
+ if (!priv) {
+ ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is null");
+ }
+ AttributeRangeFilterPtr result = priv->getObject();
+ if (!result) {
+ ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is null");
+ }
+ return result;
+}
+
JSValueRef JSAttributeRangeFilter::getAttributeName(JSContextRef context,
JSObjectRef object,
JSStringRef propertyName,
static JSObjectRef createJSObject(JSContextRef context,
DeviceAPI::Tizen::AttributeRangeFilterPtr privateData);
+ static JSObjectRef constructor(JSContextRef context,
+ JSObjectRef constructor,
+ size_t argumentCount,
+ const JSValueRef arguments[],
+ JSValueRef* exception);
+
private:
/**
* The callback invoked when an object is first created.
static DeviceAPI::Tizen::AttributeRangeFilterPtr getPrivData(JSObjectRef object);
- static JSObjectRef constructor(JSContextRef context,
- JSObjectRef constructor,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception);
-
static JSValueRef getAttributeName(JSContextRef context,
JSObjectRef object,
JSStringRef propertyName,
#include <dpl/shared_ptr.h>
#include <CommonsJavaScript/Converter.h>
#include <CommonsJavaScript/Validator.h>
+#include <CommonsJavaScript/ScopedJSStringRef.h>
#include <JSTizenExceptionFactory.h>
#include <JSTizenException.h>
#include "CompositeFilter.h"
#include "FilterConverter.h"
-#include "JSAbstractFilterArray.h"
#include "JSCompositeFilter.h"
#define ATTRIBUTE_FILTER_CLASS_NAME "CompositeFilter"
m_functions,
Initialize,
Finalize,
- NULL, //hasProperty,
- NULL, //GetProperty,
- NULL, //SetProperty,
- NULL, //DeleteProperty,
- NULL, //getPropertyNames,
+ NULL,//hasProperty,
+ NULL,//getProperty,
+ setProperty,
+ NULL,//deleteProperty,
+ NULL,//getPropertyNames,
NULL, //CallAsFunction,
- constructor, //CallAsConstructor,
+ NULL, //CallAsConstructor,
NULL, //HasInstance,
NULL, //ConvertToType,
};
JSStaticValue JSCompositeFilter::m_property[] = {
{ ATTRIBUTE_FILTER_ATTR_TYPE, getType, setType, kJSPropertyAttributeNone },
- { ATTRIBUTE_FILTER_ATTR_FILTERS, getFilters, setFilters, kJSPropertyAttributeNone },
+ //{ ATTRIBUTE_FILTER_ATTR_FILTERS, getFilters, setFilters, kJSPropertyAttributeNone },
{ 0, 0, 0, 0 }
};
LogError("object creation error");
return NULL;
}
- return jsObjectRef;
-}
-void JSCompositeFilter::Initialize(JSContextRef context, JSObjectRef object)
-{
- if (!JSObjectGetPrivate(object))
- {
- CompositeFilterPtr filter(new CompositeFilter(UNION_FILTER, FilterArrayPtr(NULL)));
- JSCompositeFilterPriv *priv = new JSCompositeFilterPriv(context, CompositeFilterPtr(filter));
- if (!JSObjectSetPrivate(object, priv)) {
- delete priv;
- }
- }
-}
+ FilterConverterFactory::ConverterType converter = FilterConverterFactory::getConverter(context);
-void JSCompositeFilter::Finalize(JSObjectRef object)
-{
- JSCompositeFilterPriv *priv = static_cast<JSCompositeFilterPriv*>(JSObjectGetPrivate(object));
+ const ScopedJSStringRef jsStrFilters(JSStringCreateWithUTF8CString(ATTRIBUTE_FILTER_ATTR_FILTERS));
+ JSValueRef jsValueFilters = converter->toJSValueRef(privateData->getFilters());
- if (priv != NULL)
- {
- delete (priv);
- }
+ JSObjectSetProperty(context, jsObjectRef, jsStrFilters.get(), jsValueFilters, kJSPropertyAttributeNone, NULL);
- priv = NULL;
-}
-
-CompositeFilterPtr JSCompositeFilter::getPrivData(JSObjectRef object)
-{
- LogDebug("entered");
- JSCompositeFilterPriv *priv = static_cast<JSCompositeFilterPriv*>(JSObjectGetPrivate(object));
- if (!priv) {
- ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is null");
- }
- CompositeFilterPtr result = priv->getObject();
- if (!result) {
- ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is null");
- }
- return result;
+ return jsObjectRef;
}
JSObjectRef JSCompositeFilter::constructor(JSContextRef context,
bool js2ndParamIsObject = false;
-// AceSecurityStatus status = CONTACT_CHECK_ACCESS(CONTACT_FUNCTION_API_ADD);
-// TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
-
- JSCompositeFilterPriv *priv = static_cast<JSCompositeFilterPriv*>(JSObjectGetPrivate(constructor));
- if (!priv) {
- ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is null");
- }
- JSContextRef gContext = priv->getContext();
-
-// JSContextRef gContext = JSGlobalContextFactory::getInstance()->get();
-
- BasicValidator validator = BasicValidatorFactory::getValidator(gContext, exception);
+ BasicValidator validator = BasicValidatorFactory::getValidator(context, exception);
Try {
if (argumentCount < 1)
ThrowMsg(InvalidArgumentException, "Wrong arguments count.");
- if (!JSValueIsString(gContext, arguments[0]))
+ if (!JSValueIsString(context, arguments[0]))
ThrowMsg(InvalidArgumentException, "1st argument is not string.");
if (argumentCount >= 2)
{
- if (JSValueIsObject(gContext, arguments[1]))
+ if (JSValueIsObject(context, arguments[1]))
js2ndParamIsObject = true;
if (!js2ndParamIsObject &&
- !JSValueIsNull(gContext, arguments[1]) &&
- !JSValueIsUndefined(gContext, arguments[1]))
+ !JSValueIsNull(context, arguments[1]) &&
+ !JSValueIsUndefined(context, arguments[1]))
ThrowMsg(InvalidArgumentException, "2nd argument is not array.");
}
return NULL;
}
- FilterConverterFactory::ConverterType converter = FilterConverterFactory::getConverter(gContext);
+ FilterConverterFactory::ConverterType converter = FilterConverterFactory::getConverter(context);
FilterType type;
FilterArrayPtr filters(NULL);
JSObjectRef jsobject;
Try {
- jsobject = createJSObject(gContext, compositeFilter);
+ jsobject = createJSObject(context, compositeFilter);
} Catch(Exception) {
LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
*exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong arguments");
return jsobject;
}
-JSValueRef JSCompositeFilter::getType(JSContextRef context,
+void JSCompositeFilter::Initialize(JSContextRef context, JSObjectRef object)
+{
+ if (!JSObjectGetPrivate(object))
+ {
+ CompositeFilterPtr filter(new CompositeFilter(UNION_FILTER, FilterArrayPtr(NULL)));
+ JSCompositeFilterPriv *priv = new JSCompositeFilterPriv(context, CompositeFilterPtr(filter));
+ if (!JSObjectSetPrivate(object, priv)) {
+ delete priv;
+ }
+ }
+}
+
+void JSCompositeFilter::Finalize(JSObjectRef object)
+{
+ JSCompositeFilterPriv *priv = static_cast<JSCompositeFilterPriv*>(JSObjectGetPrivate(object));
+
+ if (priv != NULL)
+ {
+ delete (priv);
+ }
+
+ priv = NULL;
+}
+
+CompositeFilterPtr JSCompositeFilter::getPrivData(JSObjectRef object)
+{
+ LogDebug("entered");
+ JSCompositeFilterPriv *priv = static_cast<JSCompositeFilterPriv*>(JSObjectGetPrivate(object));
+ if (!priv) {
+ ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is null");
+ }
+ CompositeFilterPtr result = priv->getObject();
+ if (!result) {
+ ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is null");
+ }
+ return result;
+}
+
+bool JSCompositeFilter::hasProperty(JSContextRef context,
+ JSObjectRef object,
+ JSStringRef propertyName)
+{
+ LogDebug("entered");
+ Try
+ {
+ CompositeFilterPtr compositeFilter = getPrivData(object);
+
+ FilterConverterFactory::ConverterType converter =
+ FilterConverterFactory::getConverter(context);
+ std::string name = converter->toString(propertyName);
+
+ if(name == ATTRIBUTE_FILTER_ATTR_FILTERS ||
+ name == ATTRIBUTE_FILTER_ATTR_TYPE )
+ return true;
+ }
+ Catch(WrtDeviceApis::Commons::Exception)
+ {
+ LogWarning("trying to get incorrect value");
+ return false;
+ }
+
+ return false;
+}
+
+JSValueRef JSCompositeFilter::getProperty(JSContextRef context,
JSObjectRef object,
JSStringRef propertyName,
JSValueRef* exception)
LogDebug("entered");
Try
{
+ CompositeFilterPtr compositeFilter = getPrivData(object);
+
FilterConverterFactory::ConverterType converter =
FilterConverterFactory::getConverter(context);
- CompositeFilterPtr compositeFilter = getPrivData(object);
- return converter->toJSValueRef(compositeFilter->getFilterType());
+ std::string name = converter->toString(propertyName);
+ if(name == ATTRIBUTE_FILTER_ATTR_FILTERS)
+ return NULL;
}
Catch(WrtDeviceApis::Commons::Exception)
{
LogWarning("trying to get incorrect value");
}
+
return JSValueMakeUndefined(context);
}
-bool JSCompositeFilter::setType(JSContextRef context,
+bool JSCompositeFilter::setProperty(JSContextRef context,
JSObjectRef object,
JSStringRef propertyName,
JSValueRef value,
JSValueRef* exception)
{
+ LogDebug("entered");
Try
{
CompositeFilterPtr compositeFilter = getPrivData(object);
FilterConverterFactory::ConverterType converter =
FilterConverterFactory::getConverter(context);
- compositeFilter->setFilterType(converter->toCompositeFilterType(value));
- return true;
+ std::string name = converter->toString(propertyName);
+ if(name == ATTRIBUTE_FILTER_ATTR_FILTERS)
+ {
+ if(!JSIsArrayValue(context, value))
+ return true;
+
+ return false;
+// const ScopedJSStringRef jsStrFilters(
+// JSStringCreateWithUTF8CString(ATTRIBUTE_FILTER_ATTR_FILTERS));
+//
+// JSObjectSetProperty(context, object, jsStrFilters.get(),
+// value, kJSPropertyAttributeNone, NULL);
+//
+// return true;
+ }
+ }
+ Catch(WrtDeviceApis::Commons::Exception)
+ {
+ LogWarning("trying to set incorrect value");
+ }
+
+ return false;
+}
+
+bool JSCompositeFilter::deleteProperty(JSContextRef context,
+ JSObjectRef object,
+ JSStringRef propertyName,
+ JSValueRef* exception)
+{
+ LogDebug("entered");
+ Try
+ {
+ CompositeFilterPtr compositeFilter = getPrivData(object);
+ FilterConverterFactory::ConverterType converter =
+ FilterConverterFactory::getConverter(context);
+ std::string name = converter->toString(propertyName);
+ if(name == ATTRIBUTE_FILTER_ATTR_FILTERS)
+ return true;
}
Catch(WrtDeviceApis::Commons::Exception)
{
LogWarning("trying to set incorrect value");
}
- JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
return false;
}
-JSValueRef JSCompositeFilter::getFilters(JSContextRef context,
+void JSCompositeFilter::getPropertyNames(JSContextRef context,
+ JSObjectRef object,
+ JSPropertyNameAccumulatorRef propertyNames)
+{
+ LogDebug("entered");
+
+ const ScopedJSStringRef jsStrFilters(JSStringCreateWithUTF8CString(ATTRIBUTE_FILTER_ATTR_FILTERS));
+ JSPropertyNameAccumulatorAddName(propertyNames, jsStrFilters.get());
+}
+
+JSValueRef JSCompositeFilter::getType(JSContextRef context,
JSObjectRef object,
JSStringRef propertyName,
JSValueRef* exception)
FilterConverterFactory::ConverterType converter =
FilterConverterFactory::getConverter(context);
CompositeFilterPtr compositeFilter = getPrivData(object);
- return converter->toJSValueRef(compositeFilter->getFilters());
+ return converter->toJSValueRef(compositeFilter->getFilterType());
}
Catch(WrtDeviceApis::Commons::Exception)
{
return JSValueMakeUndefined(context);
}
-bool JSCompositeFilter::setFilters(JSContextRef context,
+bool JSCompositeFilter::setType(JSContextRef context,
JSObjectRef object,
JSStringRef propertyName,
JSValueRef value,
CompositeFilterPtr compositeFilter = getPrivData(object);
FilterConverterFactory::ConverterType converter =
FilterConverterFactory::getConverter(context);
- compositeFilter->setFilters(converter->toFilterArray(value));
+ compositeFilter->setFilterType(converter->toCompositeFilterType(value));
return true;
}
Catch(WrtDeviceApis::Commons::Exception)
return false;
}
+//JSValueRef JSCompositeFilter::getFilters(JSContextRef context,
+// JSObjectRef object,
+// JSStringRef propertyName,
+// JSValueRef* exception)
+//{
+// LogDebug("entered");
+// Try
+// {
+// FilterConverterFactory::ConverterType converter =
+// FilterConverterFactory::getConverter(context);
+// CompositeFilterPtr compositeFilter = getPrivData(object);
+// return converter->toJSValueRef(compositeFilter->getFilters());
+// }
+// Catch(WrtDeviceApis::Commons::Exception)
+// {
+// LogWarning("trying to get incorrect value");
+// }
+// return JSValueMakeUndefined(context);
+//}
+
+//bool JSCompositeFilter::setFilters(JSContextRef context,
+// JSObjectRef object,
+// JSStringRef propertyName,
+// JSValueRef value,
+// JSValueRef* exception)
+//{
+// Try
+// {
+// CompositeFilterPtr compositeFilter = getPrivData(object);
+// FilterConverterFactory::ConverterType converter =
+// FilterConverterFactory::getConverter(context);
+// compositeFilter->setFilters(converter->toFilterArray(value));
+// return true;
+// }
+// Catch(WrtDeviceApis::Commons::Exception)
+// {
+// LogWarning("trying to set incorrect value");
+// }
+//
+// JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
+// return false;
+//}
+//
} // Tizen
} // DeviceAPI
static JSObjectRef createJSObject(JSContextRef context, DeviceAPI::Tizen::CompositeFilterPtr privateData);
+ static JSObjectRef constructor(JSContextRef context,
+ JSObjectRef constructor,
+ size_t argumentCount,
+ const JSValueRef arguments[],
+ JSValueRef* exception);
+
private:
/**
* The callback invoked when an object is first created.
static DeviceAPI::Tizen::CompositeFilterPtr getPrivData(JSObjectRef object);
- static JSObjectRef constructor(JSContextRef context,
- JSObjectRef constructor,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception);
+ static bool hasProperty(JSContextRef context,
+ JSObjectRef object,
+ JSStringRef propertyName);
- static JSValueRef getType(JSContextRef context,
+ static JSValueRef getProperty(JSContextRef context,
JSObjectRef object,
JSStringRef propertyName,
JSValueRef* exception);
- static bool setType(JSContextRef context,
+ static bool setProperty(JSContextRef context,
JSObjectRef object,
JSStringRef propertyName,
JSValueRef value,
JSValueRef* exception);
- static JSValueRef getFilters(JSContextRef context,
+ static bool deleteProperty(JSContextRef context,
+ JSObjectRef object,
+ JSStringRef propertyName,
+ JSValueRef* exception);
+
+ static void getPropertyNames(JSContextRef context,
+ JSObjectRef object,
+ JSPropertyNameAccumulatorRef propertyNames);
+
+ static JSValueRef getType(JSContextRef context,
JSObjectRef object,
JSStringRef propertyName,
JSValueRef* exception);
- static bool setFilters(JSContextRef context,
+ static bool setType(JSContextRef context,
JSObjectRef object,
JSStringRef propertyName,
JSValueRef value,
JSValueRef* exception);
+
+// static JSValueRef getFilters(JSContextRef context,
+// JSObjectRef object,
+// JSStringRef propertyName,
+// JSValueRef* exception);
+
+// static bool setFilters(JSContextRef context,
+// JSObjectRef object,
+// JSStringRef propertyName,
+// JSValueRef value,
+// JSValueRef* exception);
};
} // Tizen
NULL, //DeleteProperty,
NULL, //getPropertyNames,
NULL, //CallAsFunction,
- constructor, //CallAsConstructor,
+ NULL, //CallAsConstructor,
NULL, //HasInstance,
NULL, //ConvertToType,
};
return jsObjectRef;
}
-void JSSimpleCoordinates::Initialize(JSContextRef context, JSObjectRef object)
-{
- if (!JSObjectGetPrivate(object))
- {
- SimpleCoordinatesPtr coord(new SimpleCoordinates(0.0, 0.0));
- JSSimpleCoordinatesPriv *priv = new JSSimpleCoordinatesPriv(context, SimpleCoordinatesPtr(coord));
- if (!JSObjectSetPrivate(object, priv)) {
- delete priv;
- }
- }
-}
-
-void JSSimpleCoordinates::Finalize(JSObjectRef object)
-{
- JSSimpleCoordinatesPriv *priv = static_cast<JSSimpleCoordinatesPriv*>(JSObjectGetPrivate(object));
-
- if (priv != NULL)
- {
- delete (priv);
- }
-
- priv = NULL;
-}
-
-SimpleCoordinatesPtr JSSimpleCoordinates::getPrivData(JSObjectRef object)
-{
- LogDebug("entered");
- JSSimpleCoordinatesPriv *priv = static_cast<JSSimpleCoordinatesPriv*>(JSObjectGetPrivate(object));
- if (!priv) {
- ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is null");
- }
- SimpleCoordinatesPtr result = priv->getObject();
- if (!result) {
- ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is null");
- }
- return result;
-}
-
JSObjectRef JSSimpleCoordinates::constructor(JSContextRef context,
JSObjectRef constructor,
size_t argumentCount,
{
LogDebug("entered");
-// AceSecurityStatus status = CONTACT_CHECK_ACCESS(CONTACT_FUNCTION_API_ADD);
-// TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
-
- JSSimpleCoordinatesPriv *priv = static_cast<JSSimpleCoordinatesPriv*>(JSObjectGetPrivate(constructor));
- if (!priv) {
- ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is null");
- }
- JSContextRef gContext = priv->getContext();
-
-// JSGlobalContextRef gContext = JSGlobalContextFactory::getInstance()->get();
-
- BasicValidator validator = BasicValidatorFactory::getValidator(gContext, exception);
+ BasicValidator validator = BasicValidatorFactory::getValidator(context, exception);
Try {
if (argumentCount < 2)
ThrowMsg(InvalidArgumentException, "Wrong arguments count.");
- if (!JSValueIsNumber(gContext, arguments[0]))
+ if (!JSValueIsNumber(context, arguments[0]))
ThrowMsg(InvalidArgumentException, "1st argument is not string.");
- if (!JSValueIsNumber(gContext, arguments[1]))
+ if (!JSValueIsNumber(context, arguments[1]))
ThrowMsg(InvalidArgumentException, "2nd argument is not string.");
} Catch(Exception ) {
return NULL;
}
- FilterConverterFactory::ConverterType converter = FilterConverterFactory::getConverter(gContext);
+ FilterConverterFactory::ConverterType converter = FilterConverterFactory::getConverter(context);
double latitude;
double longitude;
JSObjectRef jsobject;
Try {
- jsobject = createJSObject(gContext, simpleCoordinates);
+ jsobject = createJSObject(context, simpleCoordinates);
} Catch(Exception) {
LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
*exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong arguments");
return jsobject;
}
+void JSSimpleCoordinates::Initialize(JSContextRef context, JSObjectRef object)
+{
+ if (!JSObjectGetPrivate(object))
+ {
+ SimpleCoordinatesPtr coord(new SimpleCoordinates(0.0, 0.0));
+ JSSimpleCoordinatesPriv *priv = new JSSimpleCoordinatesPriv(context, SimpleCoordinatesPtr(coord));
+ if (!JSObjectSetPrivate(object, priv)) {
+ delete priv;
+ }
+ }
+}
+
+void JSSimpleCoordinates::Finalize(JSObjectRef object)
+{
+ JSSimpleCoordinatesPriv *priv = static_cast<JSSimpleCoordinatesPriv*>(JSObjectGetPrivate(object));
+
+ if (priv != NULL)
+ {
+ delete (priv);
+ }
+
+ priv = NULL;
+}
+
+SimpleCoordinatesPtr JSSimpleCoordinates::getPrivData(JSObjectRef object)
+{
+ LogDebug("entered");
+ JSSimpleCoordinatesPriv *priv = static_cast<JSSimpleCoordinatesPriv*>(JSObjectGetPrivate(object));
+ if (!priv) {
+ ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is null");
+ }
+ SimpleCoordinatesPtr result = priv->getObject();
+ if (!result) {
+ ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is null");
+ }
+ return result;
+}
+
JSValueRef JSSimpleCoordinates::getLatitude(JSContextRef context,
JSObjectRef object,
JSStringRef propertyName,
static JSObjectRef createJSObject(JSContextRef context, DeviceAPI::Tizen::SimpleCoordinatesPtr privateData);
+ static JSObjectRef constructor(JSContextRef context,
+ JSObjectRef constructor,
+ size_t argumentCount,
+ const JSValueRef arguments[],
+ JSValueRef* exception);
+
private:
/**
* The callback invoked when an object is first created.
static DeviceAPI::Tizen::SimpleCoordinatesPtr getPrivData(JSObjectRef object);
- static JSObjectRef constructor(JSContextRef context,
- JSObjectRef constructor,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception);
-
static JSValueRef getLatitude(JSContextRef context,
JSObjectRef object,
JSStringRef propertyName,
NULL, //DeleteProperty,
NULL, //getPropertyNames,
NULL, //CallAsFunction,
- constructor, //CallAsConstructor,
+ NULL, //CallAsConstructor,
NULL, //HasInstance,
NULL, //ConvertToType,
};
return jsObjectRef;
}
-void JSSortMode::Initialize(JSContextRef context, JSObjectRef object)
-{
- if (!JSObjectGetPrivate(object))
- {
- SortModePtr sortMode(new SortMode(""));
- JSSortModePriv *priv = new JSSortModePriv(context, SortModePtr(sortMode));
- if (!JSObjectSetPrivate(object, priv)) {
- delete priv;
- }
- }
-}
-
-void JSSortMode::Finalize(JSObjectRef object)
-{
- JSSortModePriv *priv = static_cast<JSSortModePriv*>(JSObjectGetPrivate(object));
-
- if (priv != NULL)
- {
- delete (priv);
- }
-
- priv = NULL;
-}
-
-SortModePtr JSSortMode::getPrivData(JSObjectRef object)
-{
- LogDebug("entered");
- JSSortModePriv *priv = static_cast<JSSortModePriv*>(JSObjectGetPrivate(object));
- if (!priv) {
- ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is null");
- }
- SortModePtr result = priv->getObject();
- if (!result) {
- ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is null");
- }
- return result;
-}
-
JSObjectRef JSSortMode::constructor(JSContextRef context,
JSObjectRef constructor,
size_t argumentCount,
bool js2ndParamIsString = false;
-// AceSecurityStatus status = CONTACT_CHECK_ACCESS(CONTACT_FUNCTION_API_ADD);
-// TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
-
- JSSortModePriv *priv = static_cast<JSSortModePriv*>(JSObjectGetPrivate(constructor));
- if (!priv) {
- ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is null");
- }
- JSContextRef gContext = priv->getContext();
-
-// JSContextRef gContext = JSGlobalContextFactory::getInstance()->get();
-
- BasicValidator validator = BasicValidatorFactory::getValidator(gContext, exception);
+ BasicValidator validator = BasicValidatorFactory::getValidator(context, exception);
Try {
if (argumentCount < 1)
ThrowMsg(InvalidArgumentException, "Wrong arguments count.");
- if (!JSValueIsString(gContext, arguments[0]))
+ if (!JSValueIsString(context, arguments[0]))
ThrowMsg(InvalidArgumentException, "1st argument is not string.");
if (argumentCount >= 2)
{
- if (JSValueIsString(gContext, arguments[1]))
+ if (JSValueIsString(context, arguments[1]))
js2ndParamIsString = true;
if (!js2ndParamIsString &&
- !JSValueIsNull(gContext, arguments[1]) &&
- !JSValueIsUndefined(gContext, arguments[1]))
+ !JSValueIsNull(context, arguments[1]) &&
+ !JSValueIsUndefined(context, arguments[1]))
ThrowMsg(InvalidArgumentException, "2nd argument is not string.");
}
return NULL;
}
- FilterConverterFactory::ConverterType converter = FilterConverterFactory::getConverter(gContext);
+ FilterConverterFactory::ConverterType converter = FilterConverterFactory::getConverter(context);
std::string attributeName;
SortOrder sortOrder;
JSObjectRef jsobject;
Try {
- jsobject = createJSObject(gContext, sortMode);
+ jsobject = createJSObject(context, sortMode);
} Catch(Exception) {
LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
*exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong arguments");
return jsobject;
}
+void JSSortMode::Initialize(JSContextRef context, JSObjectRef object)
+{
+ if (!JSObjectGetPrivate(object))
+ {
+ SortModePtr sortMode(new SortMode(""));
+ JSSortModePriv *priv = new JSSortModePriv(context, SortModePtr(sortMode));
+ if (!JSObjectSetPrivate(object, priv)) {
+ delete priv;
+ }
+ }
+}
+
+void JSSortMode::Finalize(JSObjectRef object)
+{
+ JSSortModePriv *priv = static_cast<JSSortModePriv*>(JSObjectGetPrivate(object));
+
+ if (priv != NULL)
+ {
+ delete (priv);
+ }
+
+ priv = NULL;
+}
+
+SortModePtr JSSortMode::getPrivData(JSObjectRef object)
+{
+ LogDebug("entered");
+ JSSortModePriv *priv = static_cast<JSSortModePriv*>(JSObjectGetPrivate(object));
+ if (!priv) {
+ ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is null");
+ }
+ SortModePtr result = priv->getObject();
+ if (!result) {
+ ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is null");
+ }
+ return result;
+}
+
JSValueRef JSSortMode::getAttributeName(JSContextRef context,
JSObjectRef object,
JSStringRef propertyName,
static JSObjectRef createJSObject(JSContextRef context, DeviceAPI::Tizen::SortModePtr privateData);
+ static JSObjectRef constructor(JSContextRef context,
+ JSObjectRef constructor,
+ size_t argumentCount,
+ const JSValueRef arguments[],
+ JSValueRef* exception);
+
private:
/**
* The callback invoked when an object is first created.
static DeviceAPI::Tizen::SortModePtr getPrivData(JSObjectRef object);
- static JSObjectRef constructor(JSContextRef context,
- JSObjectRef constructor,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception);
-
static JSValueRef getAttributeName(JSContextRef context,
JSObjectRef object,
JSStringRef propertyName,
#include "JSSortMode.h"
#include "JSSimpleCoordinates.h"
-#define WRT_JS_EXTENSION_OBJECT_TIZEN "tizen"
-
#define OBJECT_TIZEN "tizen"
namespace Options{
NULL
};
+class_definition_options_t TizenInterfaceOptions = {
+ JS_INTERFACE,
+ CREATE_INSTANCE,
+ NONE_NOTICE,
+ USE_OVERLAYED, //ignored
+ NULL, // JSWidget::acquireGlobalContext,
+ NULL,
+ NULL
+};
+
}
using namespace WrtDeviceApis;
OBJECT_TIZEN,
(js_class_template_getter)DeviceAPI::Tizen::JSTizen::getClassRef,
&Options::TizenOptions)
- PLUGIN_CLASS_MAP_ADD_CLASS(WRT_JS_EXTENSION_OBJECT_TIZEN,
+ PLUGIN_CLASS_MAP_ADD_INTERFACE(OBJECT_TIZEN,
"AttributeFilter",
(js_class_template_getter)DeviceAPI::Tizen::JSAttributeFilter::getClassRef,
- &Options::TizenOptions)
- PLUGIN_CLASS_MAP_ADD_CLASS(WRT_JS_EXTENSION_OBJECT_TIZEN,
+ (js_class_constructor_cb_t)DeviceAPI::Tizen::JSAttributeFilter::constructor,
+ &Options::TizenInterfaceOptions)
+ PLUGIN_CLASS_MAP_ADD_INTERFACE(OBJECT_TIZEN,
"AttributeRangeFilter",
(js_class_template_getter)DeviceAPI::Tizen::JSAttributeRangeFilter::getClassRef,
- &Options::TizenOptions)
- PLUGIN_CLASS_MAP_ADD_CLASS(WRT_JS_EXTENSION_OBJECT_TIZEN,
+ (js_class_constructor_cb_t)DeviceAPI::Tizen::JSAttributeRangeFilter::constructor,
+ &Options::TizenInterfaceOptions)
+ PLUGIN_CLASS_MAP_ADD_INTERFACE(OBJECT_TIZEN,
"CompositeFilter",
(js_class_template_getter)DeviceAPI::Tizen::JSCompositeFilter::getClassRef,
- &Options::TizenOptions)
- PLUGIN_CLASS_MAP_ADD_CLASS(WRT_JS_EXTENSION_OBJECT_TIZEN,
+ (js_class_constructor_cb_t)DeviceAPI::Tizen::JSCompositeFilter::constructor,
+ &Options::TizenInterfaceOptions)
+ PLUGIN_CLASS_MAP_ADD_INTERFACE(OBJECT_TIZEN,
"SortMode",
(js_class_template_getter)DeviceAPI::Tizen::JSSortMode::getClassRef,
- &Options::TizenOptions)
- PLUGIN_CLASS_MAP_ADD_CLASS(WRT_JS_EXTENSION_OBJECT_TIZEN,
+ (js_class_constructor_cb_t)DeviceAPI::Tizen::JSSortMode::constructor,
+ &Options::TizenInterfaceOptions)
+ PLUGIN_CLASS_MAP_ADD_INTERFACE(OBJECT_TIZEN,
"SimpleCoordinates",
(js_class_template_getter)DeviceAPI::Tizen::JSSimpleCoordinates::getClassRef,
- &Options::TizenOptions)
+ (js_class_constructor_cb_t)DeviceAPI::Tizen::JSSimpleCoordinates::constructor,
+ &Options::TizenInterfaceOptions)
PLUGIN_CLASS_MAP_END
#undef OBJECT_TIZEN