Name: wrt-plugins-tizen
Summary: JavaScript plugins for WebRuntime
-Version: 0.4.11
+Version: 0.4.12
Release: 0
Group: Development/Libraries
License: Apache License, Version 2.0
+++ /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
// 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"
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;
-
-}
}
}
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;
{ 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::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() {
if (!m_jsClassRef) {
m_jsClassRef = JSClassCreate(&m_classInfo);
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.
*/
#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,
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);
SET(DESTINATION_NAME ${datasync_dest})
SET(TARGET_IMPL_NAME ${datasync_impl})
-PKG_SEARCH_MODULE(sync-agent REQUIRED sync-agent)
+PKG_CHECK_MODULES(platform_pkgs_datasync REQUIRED sync-agent)
+
+INCLUDE_DIRECTORIES(
+ ${TOP}/Tizen
+ ${TOP}/TimeUtil
+ ${TOP}/Common
+ ${platform_pkgs_datasync_INCLUDE_DIRS}
+)
SET(CMAKE_INSTALL_RPATH
${CMAKE_INSTALL_RPATH}
IDataSyncManager.cpp
)
-INCLUDE_DIRECTORIES(
- ${TOP}/Tizen
- ${TOP}/TimeUtil
- ${TOP}/Common
- ${sync-agent_INCLUDE_DIRS}
-)
-
ADD_LIBRARY(${TARGET_IMPL_NAME} SHARED ${SRCS_IMPL})
TARGET_LINK_LIBRARIES(${TARGET_IMPL_NAME}
${LIBS_COMMON}
- ${sync-agent_LIBRARIES}
+ ${tizen_impl}
+ ${platform_pkgs_datasync_LIBRARIES}
)
SET(SRCS
TARGET_LINK_LIBRARIES(${TARGET_NAME}
${TARGET_IMPL_NAME}
- ${tizen_impl}
- ${timeutil_impl}
- ${LIBS_COMMON}
)
INSTALL(TARGETS ${TARGET_NAME} ${TARGET_IMPL_NAME} LIBRARY DESTINATION ${DESTINATION_LIB_PREFIX}/${DESTINATION_NAME})
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/config.xml DESTINATION ${DESTINATION_LIB_PREFIX}/${DESTINATION_NAME})
INSTALL(
- DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ DESTINATION ${DESTINATION_HEADER_PREFIX}/datasync
- FILES_MATCHING PATTERN "*.h" PATTERN "CMakeFiles" EXCLUDE
+ DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ DESTINATION ${DESTINATION_HEADER_PREFIX}/datasync
+ FILES_MATCHING PATTERN "*.h" PATTERN "CMakeFiles" EXCLUDE
)
{
IEmailPtr email = MessageFactory::convertToEmail(msg);
RecipientsPtr recipient = email->getBccRecipientsPtr();
- return JSRecipientArray::createArray(converter->toJSGlobalContext(object), recipient);
+ JSObjectRef arrayValue = JSCreateArrayObject(context, 0, NULL);
+ if (NULL == arrayValue)
+ {
+ LogError("Could not create js array object");
+ return JSValueMakeUndefined(context);
+ }
+ for(size_t i = 0; i < recipient->getRecipientSize(); i++)
+ {
+ JSSetArrayElement(context, arrayValue, i, converter->toJSValueRef(recipient->getRecipient(i)));
+ }
+ return arrayValue;
}
case SMS:
case MMS:
{
IEmailPtr email = MessageFactory::convertToEmail(msg);
RecipientsPtr recipient = email->getCcRecipientsPtr();
- return JSRecipientArray::createArray(converter->toJSGlobalContext(object), recipient);
+ JSObjectRef arrayValue = JSCreateArrayObject(context, 0, NULL);
+ if (NULL == arrayValue)
+ {
+ LogError("Could not create js array object");
+ return JSValueMakeUndefined(context);
+ }
+ for(size_t i = 0; i < recipient->getRecipientSize(); i++)
+ {
+ JSSetArrayElement(context, arrayValue, i, converter->toJSValueRef(recipient->getRecipient(i)));
+ }
+ return arrayValue;
}
case MMS:
case SMS:
ConverterMessageFactory::ConverterType converter = ConverterMessageFactory::getConverter(context);
IMessagePtr msg = converter->toIMessage(object);
RecipientsPtr recipient = msg->getToRecipientsPtr();
- return JSRecipientArray::createArray(converter->toJSGlobalContext(object), recipient);
+ JSObjectRef arrayValue = JSCreateArrayObject(context, 0, NULL);
+ if (NULL == arrayValue)
+ {
+ LogError("Could not create js array object");
+ return JSValueMakeUndefined(context);
+ }
+ for(size_t i = 0; i < recipient->getRecipientSize(); i++)
+ {
+ JSSetArrayElement(context, arrayValue, i, converter->toJSValueRef(recipient->getRecipient(i)));
+ }
+ return arrayValue;
}
Catch(WrtDeviceApis::Commons::ConversionException) {
LogError("Error on conversion");
const std::string MessageFilterValidatorFactory::ATTRIBUTE_TO = "to";
const std::string MessageFilterValidatorFactory::ATTRIBUTE_CC = "cc";
const std::string MessageFilterValidatorFactory::ATTRIBUTE_BCC = "bcc";
- const std::string MessageFilterValidatorFactory::ATTRIBUTE_BODY = "body";
+ const std::string MessageFilterValidatorFactory::ATTRIBUTE_BODY = "body.plainBody";
const std::string MessageFilterValidatorFactory::ATTRIBUTE_IS_READ = "isRead";
const std::string MessageFilterValidatorFactory::ATTRIBUTE_PRIORITY = "isHighPriority";
const std::string MessageFilterValidatorFactory::ATTRIBUTE_SUBJECT = "subject";
const std::string StorageChangesMessageFilterValidatorFactory::ATTRIBUTE_TO = "to";
const std::string StorageChangesMessageFilterValidatorFactory::ATTRIBUTE_CC = "cc";
const std::string StorageChangesMessageFilterValidatorFactory::ATTRIBUTE_BCC = "bcc";
- const std::string StorageChangesMessageFilterValidatorFactory::ATTRIBUTE_BODY = "body";
+ const std::string StorageChangesMessageFilterValidatorFactory::ATTRIBUTE_BODY = "body.plainBody";
const std::string StorageChangesMessageFilterValidatorFactory::ATTRIBUTE_IS_READ = "isRead";
const std::string StorageChangesMessageFilterValidatorFactory::ATTRIBUTE_HAS_ATTACHMENT = "hasAttachment";
const std::string StorageChangesMessageFilterValidatorFactory::ATTRIBUTE_PRIORITY = "isHighPriority";
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;
+ 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++);
- pTmp->addressList = NULL;
-
- pTmp->scheduledTime = (time_t)dbHandle.getColumnToInt(index++);
+ index++; // This field is reserved.
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);
--- /dev/null
+SET(TARGET_NAME ${securestorage_target})
+SET(DESTINATION_NAME ${securestorage_dest})
+
+PKG_CHECK_MODULES(platform_pkgs_securestorage REQUIRED secure-storage)
+
+INCLUDE_DIRECTORIES(
+ ${platform_pkgs_securestorage_INCLUDE_DIRS}
+)
+
+SET(SRCS
+ plugin_initializer.cpp
+ plugin_config.cpp
+ SecureStorageManager.cpp
+ JSSecureStorageManager.cpp
+)
+
+ADD_LIBRARY(${TARGET_NAME} SHARED ${SRCS})
+
+TARGET_LINK_LIBRARIES(${TARGET_NAME}
+ ${LIBS_COMMON}
+ ${platform_pkgs_securestorage_LIBRARIES}
+)
+
+INSTALL(TARGETS ${TARGET_NAME} LIBRARY DESTINATION ${DESTINATION_NAME})
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/config.xml DESTINATION ${DESTINATION_NAME})
--- /dev/null
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 <CommonsJavaScript/Converter.h>
+#include <CommonsJavaScript/Validator.h>
+#include <CommonsJavaScript/JSUtils.h>
+#include <CommonsJavaScript/JSCallbackManager.h>
+#include <CommonsJavaScript/Utils.h>
+#include <SecurityExceptions.h>
+#include <JSTizenExceptionFactory.h>
+#include <JSTizenException.h>
+#include "JSSecureStorageManager.h"
+#include "plugin_config.h"
+
+using namespace std;
+using namespace DPL;
+using namespace WrtDeviceApis;
+using namespace WrtDeviceApis::CommonsJavaScript;
+using namespace DeviceAPI::Common;
+
+namespace TizenApis {
+namespace Tizen1_0 {
+
+JSClassDefinition JSSecureStorageManager::m_classInfo =
+{
+ 0,
+ kJSClassAttributeNone,
+ "SecureStorageManager",
+ NULL,
+ NULL,
+ m_function,
+ initialize,
+ finalize,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ hasInstance,
+ NULL
+};
+
+
+JSStaticFunction JSSecureStorageManager::m_function[] =
+{
+ { "remove", JSSecureStorageManager::remove, kJSPropertyAttributeNone },
+ { "set", JSSecureStorageManager::set, kJSPropertyAttributeNone },
+ { "get", JSSecureStorageManager::get, kJSPropertyAttributeNone },
+ { "listKeys", JSSecureStorageManager::listKeys, kJSPropertyAttributeNone },
+ { "removeAll", JSSecureStorageManager::removeAll, kJSPropertyAttributeNone },
+ { 0, 0, 0 }
+};
+
+
+const JSClassRef JSSecureStorageManager::getClassRef()
+{
+ if (!m_jsClassRef) {
+ m_jsClassRef = JSClassCreate(&m_classInfo);
+ }
+ return m_jsClassRef;
+}
+
+const JSClassDefinition* JSSecureStorageManager::getClassInfo()
+{
+ return &m_classInfo;
+}
+
+JSClassRef JSSecureStorageManager::m_jsClassRef = JSClassCreate(JSSecureStorageManager::getClassInfo());
+
+void JSSecureStorageManager::initialize(JSContextRef context, JSObjectRef object)
+{
+ LogDebug("JSSecureStorageManager::initialize ");
+ JSSecureStorageManagerPriv* priv = static_cast<JSSecureStorageManagerPriv*>(JSObjectGetPrivate(object));
+
+ if (priv == NULL)
+ {
+ SecureStorageManagerPtr secureStorage(new SecureStorageManager());
+ priv = new JSSecureStorageManagerPriv( context, secureStorage);
+ if(!JSObjectSetPrivate(object, static_cast<void*>(priv)))
+ {
+ LogError("Object can't store private data.");
+ delete priv;
+ }
+ }
+ else
+ {
+ LogDebug("JSSecureStorageManager::already exist ");
+ }
+}
+
+void JSSecureStorageManager::finalize(JSObjectRef object)
+{
+ JSSecureStorageManagerPriv* priv = static_cast<JSSecureStorageManagerPriv*>(JSObjectGetPrivate(object));
+
+ LogDebug("JSSecureStorageManager::Finalrize");
+
+ if (priv != NULL)
+ {
+ JSObjectSetPrivate(object, NULL);
+ delete priv;
+ }
+}
+
+bool JSSecureStorageManager::hasInstance(JSContextRef context, JSObjectRef constructor,
+ JSValueRef possibleInstance, JSValueRef* exception)
+{
+ return JSValueIsObjectOfClass(context, possibleInstance, getClassRef());
+}
+
+
+JSValueRef JSSecureStorageManager::listKeys(JSContextRef context, JSObjectRef object,
+ JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
+ JSValueRef* exception)
+{
+ JSSecureStorageManagerPriv* priv = static_cast<JSSecureStorageManagerPriv*>(JSObjectGetPrivate(thisObject));
+
+ try
+ {
+ if (priv == NULL)
+ {
+ LogError("priv null");
+ Throw(WrtDeviceApis::Commons::ConversionException);
+ }
+
+
+ // to do : need to update TizenPolicy.xml
+ // AceSecurityStatus status = SECURE_STORAGE_CHECK_ACCESS(SECURE_STORAGE_FUNC_READ);
+ // TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+
+ SecureStorageManagerPtr secureStorage(priv->getObject());
+ Converter converter(priv->getContext());
+ std::vector<std::string> keys = secureStorage->listKeys();
+ return converter.toJSValueRef(keys);
+ }
+ catch (const WrtDeviceApis::Commons::Exception& ex)
+ {
+ LogDebug("Error message" << ex.GetMessage());
+ switch(ex.getCode())
+ {
+ case WrtDeviceApis::Commons::ExceptionCodes::NotFoundException:
+ return JSTizenExceptionFactory::postException(context, exception,
+ JSTizenException::NOT_FOUND_ERROR, "not found error");
+ case WrtDeviceApis::Commons::ExceptionCodes::InvalidArgumentException:
+ return JSTizenExceptionFactory::postException(context, exception,
+ JSTizenException::INVALID_VALUES_ERROR, "invalid parameter error");
+ case WrtDeviceApis::Commons::ExceptionCodes::ConversionException:
+ return JSTizenExceptionFactory::postException(context, exception,
+ JSTizenException::TYPE_MISMATCH_ERROR, "type mismatch error");
+ case WrtDeviceApis::Commons::ExceptionCodes::SecurityException:
+ return JSTizenExceptionFactory::postException(context, exception,
+ JSTizenException::PERMISSION_DENIED_ERROR, "permission denied error");
+ case WrtDeviceApis::Commons::ExceptionCodes::Exception:
+ default:
+ return JSTizenExceptionFactory::postException(context, exception,
+ JSTizenException::UNKNOWN_ERROR, "Unkown error");
+ }
+ }
+ return JSValueMakeUndefined(context);
+
+}
+
+
+JSValueRef JSSecureStorageManager::set(JSContextRef context, JSObjectRef object,
+ JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
+ JSValueRef* exception)
+{
+ JSSecureStorageManagerPriv* priv = static_cast<JSSecureStorageManagerPriv*>(JSObjectGetPrivate(thisObject));
+ JSValueRef reserveArguments[2];
+ size_t index = 0;
+
+
+ try
+ {
+ if (priv == NULL)
+ {
+ LogError("priv null");
+
+ Throw(WrtDeviceApis::Commons::ConversionException);
+ }
+
+ // to do : need to update TizenPolicy.xml
+ // AceSecurityStatus status = SECURE_STORAGE_CHECK_ACCESS(SECURE_STORAGE_FUNC_WRITE);
+ // TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+
+
+ for (index = 0; index < 2; index++)
+ {
+ if (index < argumentCount)
+ reserveArguments[index] = arguments[index];
+ else
+ reserveArguments[index] = JSValueMakeUndefined(context);
+ }
+
+ SecureStorageManagerPtr secureStorage(priv->getObject());
+ Converter converter(priv->getContext());
+ std::string key = converter.toString(reserveArguments[0]);
+ std::string value = converter.toString(reserveArguments[1]);
+ secureStorage->set(key, value);
+
+ }
+ catch (const WrtDeviceApis::Commons::Exception& ex)
+ {
+ LogDebug("Error message" << ex.GetMessage());
+ switch(ex.getCode())
+ {
+ case WrtDeviceApis::Commons::ExceptionCodes::NotFoundException:
+ return JSTizenExceptionFactory::postException(context, exception,
+ JSTizenException::NOT_FOUND_ERROR, "not found error");
+ case WrtDeviceApis::Commons::ExceptionCodes::InvalidArgumentException:
+ return JSTizenExceptionFactory::postException(context, exception,
+ JSTizenException::INVALID_VALUES_ERROR, "invalid parameter error");
+ case WrtDeviceApis::Commons::ExceptionCodes::ConversionException:
+ return JSTizenExceptionFactory::postException(context, exception,
+ JSTizenException::TYPE_MISMATCH_ERROR, "type mismatch error");
+ case WrtDeviceApis::Commons::ExceptionCodes::SecurityException:
+ return JSTizenExceptionFactory::postException(context, exception,
+ JSTizenException::PERMISSION_DENIED_ERROR, "permission denied error");
+ case WrtDeviceApis::Commons::ExceptionCodes::Exception:
+ default:
+ return JSTizenExceptionFactory::postException(context, exception,
+ JSTizenException::UNKNOWN_ERROR, "Unkown error");
+ }
+ }
+ return JSValueMakeUndefined(context);
+}
+
+JSValueRef JSSecureStorageManager::get(JSContextRef context, JSObjectRef object,
+ JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
+ JSValueRef* exception)
+{
+ JSSecureStorageManagerPriv* priv = static_cast<JSSecureStorageManagerPriv*>(JSObjectGetPrivate(thisObject));
+ JSValueRef reserveArguments;
+
+ try
+ {
+ if (priv == NULL)
+ {
+ LogError("priv null");
+ Throw(WrtDeviceApis::Commons::ConversionException);
+ }
+
+ // to do : need to update TizenPolicy.xml
+ // AceSecurityStatus status = SECURE_STORAGE_CHECK_ACCESS(SECURE_STORAGE_FUNC_READ);
+ // TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+
+ if (argumentCount > 0)
+ reserveArguments = arguments[0];
+ else
+ reserveArguments = JSValueMakeUndefined(context);
+
+ SecureStorageManagerPtr secureStorage(priv->getObject());
+ Converter converter(priv->getContext());
+ std::string key = converter.toString(reserveArguments);
+ std::string value = secureStorage->get(key);
+ return converter.toJSValueRef(value);
+ }
+ catch (const WrtDeviceApis::Commons::Exception& ex)
+ {
+ LogDebug("Error message" << ex.GetMessage());
+ switch(ex.getCode())
+ {
+ case WrtDeviceApis::Commons::ExceptionCodes::NotFoundException:
+ return JSTizenExceptionFactory::postException(context, exception,
+ JSTizenException::NOT_FOUND_ERROR, "not found error");
+ case WrtDeviceApis::Commons::ExceptionCodes::InvalidArgumentException:
+ return JSTizenExceptionFactory::postException(context, exception,
+ JSTizenException::INVALID_VALUES_ERROR, "invalid parameter error");
+ case WrtDeviceApis::Commons::ExceptionCodes::ConversionException:
+ return JSTizenExceptionFactory::postException(context, exception,
+ JSTizenException::TYPE_MISMATCH_ERROR, "type mismatch error");
+ case WrtDeviceApis::Commons::ExceptionCodes::SecurityException:
+ return JSTizenExceptionFactory::postException(context, exception,
+ JSTizenException::PERMISSION_DENIED_ERROR, "permission denied error");
+ case WrtDeviceApis::Commons::ExceptionCodes::Exception:
+ default:
+ return JSTizenExceptionFactory::postException(context, exception,
+ JSTizenException::UNKNOWN_ERROR, "Unkown error");
+ }
+ }
+ return JSValueMakeUndefined(context);
+
+}
+
+JSValueRef JSSecureStorageManager::remove(JSContextRef context, JSObjectRef object,
+ JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
+ JSValueRef* exception)
+{
+ JSSecureStorageManagerPriv* priv = static_cast<JSSecureStorageManagerPriv*>(JSObjectGetPrivate(thisObject));
+ JSValueRef reserveArguments;
+
+ try
+ {
+ if (priv == NULL)
+ {
+ LogError("priv null");
+ Throw(WrtDeviceApis::Commons::ConversionException);
+ }
+
+ // to do : need to update TizenPolicy.xml
+ // AceSecurityStatus status = SECURE_STORAGE_CHECK_ACCESS(SECURE_STORAGE_FUNC_WRITE);
+ // TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+
+ if (argumentCount > 0)
+ reserveArguments = arguments[0];
+ else
+ reserveArguments = JSValueMakeUndefined(context);
+
+ SecureStorageManagerPtr secureStorage(priv->getObject());
+ Converter converter(priv->getContext());
+ std::string key = converter.toString(reserveArguments);
+ secureStorage->remove(key);
+ }
+ catch (const WrtDeviceApis::Commons::Exception& ex)
+ {
+ LogDebug("Error message" << ex.GetMessage());
+ switch(ex.getCode())
+ {
+ case WrtDeviceApis::Commons::ExceptionCodes::NotFoundException:
+ return JSTizenExceptionFactory::postException(context, exception,
+ JSTizenException::NOT_FOUND_ERROR, "not found error");
+ case WrtDeviceApis::Commons::ExceptionCodes::InvalidArgumentException:
+ return JSTizenExceptionFactory::postException(context, exception,
+ JSTizenException::INVALID_VALUES_ERROR, "invalid parameter error");
+ case WrtDeviceApis::Commons::ExceptionCodes::ConversionException:
+ return JSTizenExceptionFactory::postException(context, exception,
+ JSTizenException::TYPE_MISMATCH_ERROR, "type mismatch error");
+ case WrtDeviceApis::Commons::ExceptionCodes::SecurityException:
+ return JSTizenExceptionFactory::postException(context, exception,
+ JSTizenException::PERMISSION_DENIED_ERROR, "permission denied error");
+ case WrtDeviceApis::Commons::ExceptionCodes::Exception:
+ default:
+ return JSTizenExceptionFactory::postException(context, exception,
+ JSTizenException::UNKNOWN_ERROR, "Unkown error");
+ }
+ }
+ return JSValueMakeUndefined(context);
+
+}
+
+JSValueRef JSSecureStorageManager::removeAll(JSContextRef context, JSObjectRef object,
+ JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
+ JSValueRef* exception)
+{
+ JSSecureStorageManagerPriv* priv = static_cast<JSSecureStorageManagerPriv*>(JSObjectGetPrivate(thisObject));
+
+ try
+ {
+ if (priv == NULL)
+ {
+ LogError("priv null");
+ Throw(WrtDeviceApis::Commons::ConversionException);
+ }
+
+ // to do : need to update TizenPolicy.xml
+ // AceSecurityStatus status = SECURE_STORAGE_CHECK_ACCESS(SECURE_STORAGE_FUNC_WRITE);
+ // TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+
+ SecureStorageManagerPtr secureStorage(priv->getObject());
+ Converter converter(priv->getContext());
+ secureStorage->removeAll();
+
+ }
+ catch (const WrtDeviceApis::Commons::Exception& ex)
+ {
+ LogDebug("Error message" << ex.GetMessage());
+ switch(ex.getCode())
+ {
+ case WrtDeviceApis::Commons::ExceptionCodes::NotFoundException:
+ return JSTizenExceptionFactory::postException(context, exception,
+ JSTizenException::NOT_FOUND_ERROR, "not found error");
+ case WrtDeviceApis::Commons::ExceptionCodes::InvalidArgumentException:
+ return JSTizenExceptionFactory::postException(context, exception,
+ JSTizenException::INVALID_VALUES_ERROR, "invalid parameter error");
+ case WrtDeviceApis::Commons::ExceptionCodes::ConversionException:
+ return JSTizenExceptionFactory::postException(context, exception,
+ JSTizenException::TYPE_MISMATCH_ERROR, "type mismatch error");
+ case WrtDeviceApis::Commons::ExceptionCodes::SecurityException:
+ return JSTizenExceptionFactory::postException(context, exception,
+ JSTizenException::PERMISSION_DENIED_ERROR, "permission denied error");
+ case WrtDeviceApis::Commons::ExceptionCodes::Exception:
+ default:
+ return JSTizenExceptionFactory::postException(context, exception,
+ JSTizenException::UNKNOWN_ERROR, "Unkown error");
+ }
+ }
+ return JSValueMakeUndefined(context);
+
+}
+
+}
+}
+
--- /dev/null
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 TIZENAPIS_TIZEN_JS_SECURE_STORAGE_MANAGER_H_
+#define TIZENAPIS_TIZEN_JS_SECURE_STORAGE_MANAGER_H_
+
+#include <JavaScriptCore/JavaScript.h>
+#include "SecureStorageManager.h"
+#include <CommonsJavaScript/PrivateObject.h>
+
+using namespace WrtDeviceApis::CommonsJavaScript;
+using namespace WrtDeviceApis;
+using namespace WrtDeviceApis::Commons;
+
+
+namespace TizenApis {
+namespace Tizen1_0 {
+
+
+typedef PrivateObjectT<SecureStorageManagerPtr>::Type JSSecureStorageManagerPriv;
+
+class JSSecureStorageManager {
+public:
+ static const JSClassDefinition* getClassInfo();
+ static const JSClassRef getClassRef();
+private:
+ static void initialize(JSContextRef context, JSObjectRef object);
+ static void finalize(JSObjectRef object);
+ static bool hasInstance(JSContextRef context, JSObjectRef constructor,
+ JSValueRef possibleInstance, JSValueRef* exception);
+
+ static JSValueRef listKeys(JSContextRef context, JSObjectRef object,
+ JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
+ JSValueRef* exception);
+ static JSValueRef set(JSContextRef context, JSObjectRef object,
+ JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
+ JSValueRef* exception);
+ static JSValueRef get(JSContextRef context, JSObjectRef object,
+ JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
+ JSValueRef* exception);
+ static JSValueRef remove(JSContextRef context, JSObjectRef object,
+ JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
+ JSValueRef* exception);
+ static JSValueRef removeAll(JSContextRef context, JSObjectRef object,
+ JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
+ JSValueRef* exception);
+
+ static JSClassDefinition m_classInfo;
+ static JSStaticFunction m_function[];
+ static JSClassRef m_jsClassRef;
+};
+
+}
+}
+
+#endif
+
--- /dev/null
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 "SecureStorageManager.h"
+#include <ss_manager.h>
+#include <cassert>
+#include <exception>
+#include <Commons/Exception.h>
+#include <CommonsJavaScript/JSUtils.h>
+#include <dpl/scoped_array.h>
+
+using namespace DPL;
+using namespace WrtDeviceApis::Commons;
+
+namespace TizenApis {
+namespace Tizen1_0{
+
+std::string SecureStorageManager::m_filePath = "securedata.txt";
+int SecureStorageManager::m_maxLength = 256;
+
+SecureStorageManager::SecureStorageManager()
+{
+ LogDebug("OK");
+
+ try
+ {
+ loadSecurePairData();
+ }
+ catch (const WrtDeviceApis::Commons::Exception& ex)
+ {
+ LogError("Exception: " << ex.GetMessage());
+ LogDebug("there is no file");
+ }
+
+ LogDebug("initial map size : " << m_securePairData.size());
+}
+
+SecureStorageManager::~SecureStorageManager()
+{
+ LogDebug("OK");
+}
+
+std::string SecureStorageManager::get(std::string key)
+{
+ LogDebug("OK");
+
+ std::map<std::string,std::string>::iterator it = m_securePairData.find(key);
+
+ if (it == m_securePairData.end())
+ {
+ ThrowMsg(WrtDeviceApis::Commons::NotFoundException, "not found key");
+ }
+
+ return m_securePairData[key];
+}
+
+std::vector<std::string> SecureStorageManager::listKeys()
+{
+ std::vector<std::string> vector;
+ std::map<std::string,std::string>::iterator it;
+
+ LogDebug("OK");
+
+ for (it = m_securePairData.begin(); it != m_securePairData.end(); ++it)
+ {
+ vector.push_back((*it).first);
+ }
+
+ return vector;
+}
+void SecureStorageManager::set(std::string key, std::string value)
+{
+ m_securePairData[key] = value;
+
+ LogDebug("Save current data");
+ saveSecurePairData();
+}
+
+void SecureStorageManager::remove(std::string key)
+{
+ LogDebug("OK");
+
+ std::map<std::string,std::string>::iterator it = m_securePairData.find(key);
+
+ if (it == m_securePairData.end())
+ {
+ ThrowMsg(WrtDeviceApis::Commons::NotFoundException, "not found key");
+ }
+ m_securePairData.erase(it);
+ LogDebug("Save current data");
+ saveSecurePairData();
+}
+
+void SecureStorageManager::removeAll()
+{
+ LogDebug("OK");
+
+ ssm_flag flag = SSM_FLAG_SECRET_OPERATION;
+
+ m_securePairData.clear();
+ ssm_delete_file(m_filePath.c_str(), flag, NULL);
+}
+
+void SecureStorageManager::saveSecurePairData()
+{
+ LogDebug("OK");
+
+ std::map<std::string,std::string>::iterator it;
+ size_t dataSize = 0;
+ size_t index = 0;
+ size_t num = 0;
+ size_t mapSize = m_securePairData.size();
+ int ret = -1;
+
+ for (it = m_securePairData.begin(); it != m_securePairData.end(); ++it)
+ {
+ dataSize += (*it).first.size();
+ dataSize += (*it).second.size();
+ }
+
+ dataSize += sizeof(size_t) * 2 * m_securePairData.size();
+ dataSize += sizeof(size_t) * 2;
+
+ DPL::ScopedArray<char> saveBuf(new char[dataSize]);
+
+ memcpy(&saveBuf[index], (char*)&mapSize, sizeof(size_t));
+ index += sizeof(size_t);
+
+ memcpy(&saveBuf[index], (char*)&dataSize, sizeof(size_t));
+ index += sizeof(size_t);
+
+ for (it = m_securePairData.begin(); it != m_securePairData.end(); ++it)
+ {
+ num = (*it).first.size();
+ memcpy(&saveBuf[index], (char*)&num, sizeof(size_t));
+ index += sizeof(size_t);
+
+ memcpy(&saveBuf[index], (char*)(*it).first.c_str(), (*it).first.size());
+ index += (*it).first.size();
+
+ num = (*it).second.size();
+ memcpy(&saveBuf[index], (char*)&num, sizeof(size_t));
+ index += sizeof(size_t);
+ memcpy(&saveBuf[index], (char*)(*it).second.c_str(), (*it).second.size());
+ index += (*it).second.size();
+ }
+
+ ssm_flag flag = SSM_FLAG_SECRET_OPERATION;
+
+ ret = ssm_write_buffer(saveBuf.Get(), dataSize, m_filePath.c_str(), flag, NULL);
+
+ if (ret < 0)
+ {
+ ThrowMsg(WrtDeviceApis::Commons::PlatformException, "ssm write buf error");
+ }
+ LogDebug("save result : " << ret);
+}
+
+std::string SecureStorageManager::readStringFromMemory(const char *saveBuf, size_t ¤t, size_t dataSize)
+{
+ std::string value = "";
+ size_t num = 0;
+ char tempbuf[m_maxLength];
+
+ if (current + sizeof(size_t) > dataSize)
+ {
+ ThrowMsg(WrtDeviceApis::Commons::PlatformException, "get size error ");
+ }
+
+ memcpy(&num, &saveBuf[current], sizeof(size_t));
+ memset(tempbuf, 0, sizeof(tempbuf));
+ current += sizeof(size_t);
+
+ if (current + num > dataSize)
+ {
+ ThrowMsg(WrtDeviceApis::Commons::PlatformException, "get size error ");
+ }
+
+ memcpy(tempbuf, &saveBuf[current], num);
+ current += num;
+ value = tempbuf;
+
+ return value;
+}
+
+
+void SecureStorageManager::loadSecurePairData()
+{
+ LogDebug("OK");
+
+ int ret = -1;
+ size_t num = 0;
+ size_t dataSize = 0;
+ size_t i = 0;
+ size_t readlen = 0;
+ char* retbuf = NULL;
+ ssm_file_info_t sfi;
+ ssm_flag flag = SSM_FLAG_SECRET_OPERATION;
+ size_t index = 0;
+
+ m_securePairData.clear();
+ ret = ssm_getinfo(m_filePath.c_str(), &sfi, flag, NULL);
+
+ if (ret < 0)
+ {
+ ThrowMsg(WrtDeviceApis::Commons::PlatformException, "get info error");
+ }
+
+ if (sfi.originSize == 0)
+ {
+ ThrowMsg(WrtDeviceApis::Commons::PlatformException, "originSize error");
+ }
+
+ DPL::ScopedArray<char> saveBuf(new char[sfi.originSize]);
+ retbuf = saveBuf.Get();
+
+ memset(retbuf, 0x00, sizeof(char) * sfi.originSize);
+ ret = ssm_read(m_filePath.c_str(), retbuf, sfi.originSize, &readlen, flag, NULL);
+
+ if (ret < 0)
+ {
+ ThrowMsg(WrtDeviceApis::Commons::PlatformException, "read buf error");
+ }
+
+ LogDebug("read result : " << ret << ", length:" << readlen);
+
+ memcpy(&num, &saveBuf[index], sizeof(size_t));
+ index += sizeof(size_t);
+
+ memcpy(&dataSize, &saveBuf[index], sizeof(size_t));
+ index += sizeof(size_t);
+
+ LogDebug("dataSize" << dataSize << "-" << num);
+
+ for (i = 0; i < num; i++)
+ {
+ std::string key = readStringFromMemory(retbuf, index, dataSize);
+ std::string value = readStringFromMemory(retbuf, index, dataSize);
+
+ if (key.size() == 0 || value.size() == 0)
+ {
+ ThrowMsg(WrtDeviceApis::Commons::PlatformException, "read buf error");
+ }
+ m_securePairData[key] = value;
+ LogDebug("contents:" << key << "-" << m_securePairData[key]);
+ }
+}
+
+
+}
+}
+
--- /dev/null
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 TIZENAPIS_TIZEN_SECURE_STORAGE_MANAGER_H_
+#define TIZENAPIS_TIZEN_SECURE_STORAGE_MANAGER_H_
+
+#include <dpl/shared_ptr.h>
+#include <map>
+#include <string>
+#include <vector>
+
+namespace TizenApis {
+namespace Tizen1_0 {
+
+class SecureStorageManager;
+typedef DPL::SharedPtr<SecureStorageManager> SecureStorageManagerPtr;
+
+
+class SecureStorageManager
+{
+public:
+ std::string get(std::string key);
+ std::vector<std::string> listKeys();
+ void set(std::string key, std::string value);
+ void remove(std::string key);
+ void removeAll();
+ SecureStorageManager();
+ ~SecureStorageManager();
+private:
+ static std::string m_filePath;
+ static int m_maxLength;
+ std::map<std::string, std::string> m_securePairData;
+ void saveSecurePairData();
+ void loadSecurePairData();
+ std::string readStringFromMemory(const char *saveBuf, size_t ¤t, size_t dataSize);
+};
+}
+}
+#endif
--- /dev/null
+<?xml version="1.0" ?>
+<!DOCTYPE plugin-properties SYSTEM "/usr/etc/tizen-apis/config.dtd">
+<plugin-properties>
+ <library-name>libwrt-plugins-tizen-securestorage.so</library-name>
+ <feature-install-uri>securestorage.install.uri</feature-install-uri>
+ <feature-key-cn>SAMSUNG plugin group</feature-key-cn>
+ <feature-root-cn>SAMSUNG certificate authority</feature-root-cn>
+ <feature-root-fingerprint>AAAABBBBCCCCDDDEEEE0000</feature-root-fingerprint>
+ <api-feature>
+ <name>http://tizen.org/privilege/securestorage.read</name>
+ <device-capability>securestorage.read</device-capability>
+ </api-feature>
+ <api-feature>
+ <name>http://tizen.org/privilege/securestorage.write</name>
+ <device-capability>securestorage.write</device-capability>
+ </api-feature>
+</plugin-properties>
+
--- /dev/null
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 <map>
+#include <utility>
+#include <Commons/FunctionDefinition.h>
+#include <Commons/FunctionDeclaration.h>
+#include <Commons/Exception.h>
+#include "plugin_config.h"
+
+#define SECURE_STORAGE_FEATURE_API_READ "http://tizen.org/privilege/securestorage.read"
+#define SECURE_STORAGE_FEATURE_API_WRITE "http://tizen.org/privilege/securestorage.write"
+
+#define SECURE_STORAGE_DEVICE_CAP_READ "securestorage.read"
+#define SECURE_STORAGE_DEVICE_CAP_WRITE "securestorage.write"
+
+namespace TizenApis {
+namespace Tizen1_0 {
+
+const char* SECURE_STORAGE_FUNC_READ = "SecureStroageReadFunc";
+const char* SECURE_STORAGE_FUNC_WRITE = "SecureStroageWriteFunc";
+const char* SECURE_STORAGE_FUNC_READWRITE = "SecureStroageReadWriteFunc";
+
+static WrtDeviceApis::Commons::FunctionMapping createSecureStorageFunctions();
+
+static WrtDeviceApis::Commons::FunctionMapping SecureStorageFunctions =
+ createSecureStorageFunctions();
+
+DEFINE_FUNCTION_GETTER(SecureStorage, SecureStorageFunctions);
+
+static WrtDeviceApis::Commons::FunctionMapping createSecureStorageFunctions()
+{
+ using namespace WrtDeviceApis::Commons;
+
+ ACE_CREATE_DEVICE_CAP(DEVICE_CAP_SECURE_STORAGE_READ, SECURE_STORAGE_DEVICE_CAP_READ);
+ ACE_CREATE_DEVICE_CAP(DEVICE_CAP_SECURE_STORAGE_WRITE, SECURE_STORAGE_DEVICE_CAP_WRITE);
+
+
+ ACE_CREATE_DEVICE_CAPS_LIST(EMPTY_DEVICE_LIST);
+
+ ACE_CREATE_DEVICE_CAPS_LIST(DEVICE_LIST_SECURE_STORAGE_READ);
+ ACE_ADD_DEVICE_CAP(DEVICE_LIST_SECURE_STORAGE_READ, DEVICE_CAP_SECURE_STORAGE_READ);
+
+ ACE_CREATE_DEVICE_CAPS_LIST(DEVICE_LIST_SECURE_STORAGE_WRITE);
+ ACE_ADD_DEVICE_CAP(DEVICE_LIST_SECURE_STORAGE_WRITE, DEVICE_CAP_SECURE_STORAGE_WRITE);
+
+
+ ACE_CREATE_DEVICE_CAPS_LIST(DEVICE_LIST_SECURE_STORAGE_READWRITE);
+ ACE_ADD_DEVICE_CAP(DEVICE_LIST_SECURE_STORAGE_READWRITE, DEVICE_CAP_SECURE_STORAGE_READ);
+ ACE_ADD_DEVICE_CAP(DEVICE_LIST_SECURE_STORAGE_READWRITE, DEVICE_CAP_SECURE_STORAGE_WRITE);
+
+
+ ACE_CREATE_FEATURE(FEATURE_READ, SECURE_STORAGE_FEATURE_API_READ);
+ ACE_CREATE_FEATURE(FEATURE_WRITE, SECURE_STORAGE_FEATURE_API_WRITE);
+
+ ACE_CREATE_FEATURE_LIST(SECURE_STORAGE_FEATURES_SECURE_READWRITE);
+ ACE_ADD_API_FEATURE(SECURE_STORAGE_FEATURES_SECURE_READWRITE, FEATURE_READ);
+ ACE_ADD_API_FEATURE(SECURE_STORAGE_FEATURES_SECURE_READWRITE, FEATURE_WRITE);
+
+ ACE_CREATE_FEATURE_LIST(SECURE_STORAGE_FEATURES_READ);
+ ACE_ADD_API_FEATURE(SECURE_STORAGE_FEATURES_READ, FEATURE_READ);
+
+ ACE_CREATE_FEATURE_LIST(SECURE_STORAGE_FEATURES_WRITE);
+ ACE_ADD_API_FEATURE(SECURE_STORAGE_FEATURES_WRITE, FEATURE_WRITE);
+
+
+ FunctionMapping SecureStorageFunctions;
+
+ AceFunction secureStorageRead = ACE_CREATE_FUNCTION(
+ FUNCTION_SECURE_STORAGE_READ_FUNCTIONS,
+ SECURE_STORAGE_FUNC_READ,
+ SECURE_STORAGE_FEATURES_READ,
+ DEVICE_LIST_SECURE_STORAGE_READ);
+
+ SecureStorageFunctions.insert(std::make_pair(
+ SECURE_STORAGE_FUNC_READ,
+ secureStorageRead));
+
+ AceFunction secureStorageWrite = ACE_CREATE_FUNCTION(
+ FUNCTION_SECURE_STORAGE_WRITE_FUNCTIONS,
+ SECURE_STORAGE_FUNC_WRITE,
+ SECURE_STORAGE_FEATURES_WRITE,
+ DEVICE_LIST_SECURE_STORAGE_WRITE);
+
+ SecureStorageFunctions.insert(std::make_pair(
+ SECURE_STORAGE_FUNC_WRITE,
+ secureStorageWrite));
+
+ AceFunction secureStorageReadWrite = ACE_CREATE_FUNCTION(
+ FUNCTION_SECURE_STORAGE_READWRITE_FUNCTIONS,
+ SECURE_STORAGE_FUNC_READWRITE,
+ SECURE_STORAGE_FEATURES_SECURE_READWRITE,
+ DEVICE_LIST_SECURE_STORAGE_READWRITE);
+
+ SecureStorageFunctions.insert(std::make_pair(
+ SECURE_STORAGE_FUNC_READWRITE,
+ secureStorageReadWrite));
+
+ return SecureStorageFunctions;
+}
+}
+}
+
+#undef SECURE_STORAGE_FEATURE_API
+#undef SECURE_STORAGE_FEATURE_API_WRITE
+#undef SECURE_STORAGE_FEATURE_API_READ
+#undef SECURE_STORAGE_DEVICE_CAP_WRITE
+#undef SECURE_STORAGE_DEVICE_CAP_READ
+
--- /dev/null
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 TIZENAPIS_TIZEN_JS_SECURE_STORAGE_PLUGIN_CONFIG_H_
+#define TIZENAPIS_TIZEN_JS_SECURE_STORAGE_PLUGIN_CONFIG_H_
+
+#include <Commons/FunctionDeclaration.h>
+
+namespace TizenApis {
+namespace Tizen1_0 {
+
+extern const char* SECURE_STORAGE_FUNC_READ;
+extern const char* SECURE_STORAGE_FUNC_WRITE;
+
+
+WrtDeviceApis::Commons::AceFunction getSecureStorageFunctionData(const std::string & functionId);
+
+#define SECURE_STORAGE_CHECK_ACCESS(functionName) \
+ aceCheckAccess<AceFunctionGetter, DefaultArgsVerifier<> >( \
+ getSecureStorageFunctionData, \
+ functionName)
+}
+}
+
+#endif
--- /dev/null
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 <dpl/log/log.h>
+#include <Commons/plugin_initializer_def.h>
+#include <Commons/WrtAccess/WrtAccess.h>
+
+
+#include "JSSecureStorageManager.h"
+
+using namespace WrtDeviceApis;
+using namespace WrtDeviceApis::Commons;
+
+void on_widget_start_callback(int widgetId)
+{
+ LogDebug("[Tizen\\Bluetooth ] on_widget_start_callback ("<<widgetId<<")");
+ Try
+ {
+ WrtAccessSingleton::Instance().initialize(widgetId);
+ }
+ Catch(Commons::Exception)
+ {
+ LogError("WrtAccess initialization failed");
+ }
+}
+
+void on_widget_stop_callback(int widgetId)
+{
+ LogDebug("[Tizen\\Bluetooth] on_widget_stop_callback ("<<widgetId<<")");
+ Try
+ {
+ WrtAccessSingleton::Instance().deinitialize(widgetId);
+ }
+ Catch(Commons::Exception)
+ {
+ LogError("WrtAccess deinitialization failed");
+ }
+}
+
+PLUGIN_ON_WIDGET_START(on_widget_start_callback)
+PLUGIN_ON_WIDGET_STOP(on_widget_stop_callback)
+
+#define SECURE_STORAGE "securestorage"
+
+PLUGIN_CLASS_MAP_BEGIN
+PLUGIN_CLASS_MAP_ADD_CLASS(WRT_JS_EXTENSION_OBJECT_TIZEN, SECURE_STORAGE,
+ (js_class_template_getter)TizenApis::Tizen1_0::JSSecureStorageManager::getClassRef,NULL)
+PLUGIN_CLASS_MAP_END
+