From: Dongjin Choi Date: Tue, 2 Jul 2013 12:55:13 +0000 (+0900) Subject: Update change log and spec for wrt-plugins-tizen_0.4.49 X-Git-Tag: submit/tizen_2.2/20130714.154935~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f46a0aaefa5ab1ae57ecba1e6900024c903712d7;p=framework%2Fweb%2Fwrt-plugins-tizen.git Update change log and spec for wrt-plugins-tizen_0.4.49 [model] REDWOOD [binary_type] PDA [customer] OPEN [Issue] N/A [Problem] createOpId bug fix [Cause] createOpId bug fix [Solution] createOpId bug fix [Issue#] N/A [Problem] Filter returns the Date value as UTC [Cause] Filter create tm value from time_t value [Solution] Add JSValueToDateTm function and use it [Issue#] N/A [Problem] TCT fail, intensive test [Cause] internal error [Solution] fix code [Issue#] N_SE-43481 [Problem] Lockup occures when turn on bluetooth on Emulator [Cause] reponse delay ocuures on Emulator [Solution] Don't call Core API if BT is not supported [WebSetting] Rollback testset.xml and createPackage.xml to exclude websetting tc. [Systeminfo] Fix get capabilities info [Systeminfo] Change Sim enum value(Sync rsa code) [Issue] N/A [Problem] appcontrol launch fail on RSA binary [Cause] appcontrol launch fail. [Solution] handle exception event. [Issue#] N/A [Problem] N/A [Cause] comparison between signed and unsigned integer expressions [Solution] use sit_t instead of int. [Issue#] N/A [Problem] WebAPIErrorFactory has risk [Cause] assert codes were not removed [Solution] removed assert codes [Issue#] N/A [Problem] Some codes have useless header [Cause] assert head [Solution] removed assert heads [Issue] N/A [Problem] If object is finalized before completing async function, it makes crash [Cause] It calls async function with this pointer. If the this is finalized and callback is called, it can access the pointer that is free. [Solution] It will protect thisobject until completing async function [SCMRequest] N/A [Systeminfo] Remove build warning [team] WebAPI [request] N/A [horizontal_expansion] N/A --- diff --git a/packaging/wrt-plugins-tizen.spec b/packaging/wrt-plugins-tizen.spec index 61634d2..531a664 100755 --- a/packaging/wrt-plugins-tizen.spec +++ b/packaging/wrt-plugins-tizen.spec @@ -1,7 +1,7 @@ Name: wrt-plugins-tizen Summary: JavaScript plugins for WebRuntime -Version: 0.4.48 -Release: 1 +Version: 0.4.49 +Release: 0 Group: Development/Libraries License: Apache License, Version 2.0 Source0: %{name}-%{version}.tar.gz diff --git a/src/Bluetooth/BluetoothAdapter.cpp b/src/Bluetooth/BluetoothAdapter.cpp index 5897731..a62d9e3 100644 --- a/src/Bluetooth/BluetoothAdapter.cpp +++ b/src/Bluetooth/BluetoothAdapter.cpp @@ -99,7 +99,8 @@ void BluetoothAdapter::onNameChangedCB(char *name, void *userData) LoggerW("userData is NULL"); return; } - + + LoggerD("changed name: " << std::string(name)); // call onnamechanged in ChangeListener if(object->mChangeListener != NULL) { LoggerD("call onnamechanged in ChangeListener"); @@ -1225,7 +1226,9 @@ void BluetoothAdapter::createBonding(std::string &address, MultiCallbackUserData if(mUserDataList[CREATE_BONDING] == NULL) { TIME_TRACER_ITEM_BEGIN("createBonding::bt_device_set_bond_created_cb", 1); - bt_device_set_bond_created_cb(onBondCreatedCB, this); + if(bt_device_set_bond_created_cb(onBondCreatedCB, this) != BT_ERROR_NONE) { + LoggerW("bt_device_set_bond_created_cb() failed"); + } TIME_TRACER_ITEM_END("createBonding::bt_device_set_bond_created_cb", 1); mCreateBondingAddress = address; mUserDataList[CREATE_BONDING] = userData; @@ -1285,7 +1288,9 @@ void BluetoothAdapter::destroyBonding(std::string &address, MultiCallbackUserDat if(mUserDataList[DESTROY_BONDING] == NULL) { TIME_TRACER_ITEM_BEGIN("destroyBonding::bt_device_set_bond_destroyed_cb", 1); - bt_device_set_bond_destroyed_cb(onBondDestroyedCB, this); + if(bt_device_set_bond_destroyed_cb(onBondDestroyedCB, this) != BT_ERROR_NONE) { + LoggerW("bt_device_set_bond_destroyed_cb() failed"); + } TIME_TRACER_ITEM_END("destroyBonding::bt_device_set_bond_destroyed_cb", 1); mDestroyBondingAddress = address; mUserDataList[DESTROY_BONDING] = userData; diff --git a/src/Bluetooth/CMakeLists.txt b/src/Bluetooth/CMakeLists.txt index cb1e21f..c4bb7f7 100644 --- a/src/Bluetooth/CMakeLists.txt +++ b/src/Bluetooth/CMakeLists.txt @@ -4,6 +4,7 @@ SET(TARGET_IMPL_NAME ${bluetooth_impl}) IF(ENABLE_OPTIONAL_BT) PKG_SEARCH_MODULE(bluetooth REQUIRED capi-network-bluetooth) +PKG_SEARCH_MODULE(system-info REQUIRED capi-system-info) SET(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_RPATH} diff --git a/src/Bluetooth/JSBluetoothAdapter.cpp b/src/Bluetooth/JSBluetoothAdapter.cpp index b47aa52..91810e5 100644 --- a/src/Bluetooth/JSBluetoothAdapter.cpp +++ b/src/Bluetooth/JSBluetoothAdapter.cpp @@ -26,6 +26,7 @@ #include "BluetoothAdapter.h" #include "JSBluetoothHealthProfileHandler.h" +#include #include #include @@ -189,6 +190,8 @@ JSValueRef JSBluetoothAdapter::setPowered(JSContextRef context, const JSValueRef arguments[], JSValueRef* exception) { + LoggerD("Enter"); + TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 1); // Access Check @@ -198,6 +201,20 @@ JSValueRef JSBluetoothAdapter::setPowered(JSContextRef context, TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); try { + // Check whether BT is supported or not + bool supported = false; + if(system_info_get_value_bool(SYSTEM_INFO_KEY_BLUETOOTH_SUPPORTED, &supported) != SYSTEM_INFO_ERROR_NONE) { + LoggerW("Can't check BT is supported or not"); + } + + if(supported == false) { + LoggerW("BT is not supported"); + throw DeviceAPI::Common::NotSupportedException("Bluetooth is not supported"); + } + else { + LoggerD("BT is supported"); + } + // Validate arguments ArgumentValidator validator(context, argumentCount, arguments); bool state = validator.toBool(0); // state diff --git a/src/Common/JSUtil.cpp b/src/Common/JSUtil.cpp index 9a637c6..a038ce6 100644 --- a/src/Common/JSUtil.cpp +++ b/src/Common/JSUtil.cpp @@ -27,10 +27,10 @@ namespace DeviceAPI { namespace Common{ JSValueRef JSUtil::getProperty(JSContextRef ctx , JSObjectRef object, const char *name, JSValueRef *exception){ - JSValueRef value; - JSStringRef propertyName = JSStringCreateWithUTF8CString(name); + JSValueRef value; + JSStringRef propertyName = JSStringCreateWithUTF8CString(name); JSValueRef localException = NULL; - value = JSObjectGetProperty(ctx, object, propertyName, &localException); + value = JSObjectGetProperty(ctx, object, propertyName, &localException); JSStringRelease(propertyName); if( localException != NULL ){ @@ -39,14 +39,14 @@ JSValueRef JSUtil::getProperty(JSContextRef ctx , JSObjectRef object, const char else throw TypeMismatchException(ctx,localException); } - return value; + return value; } void JSUtil::setProperty(JSContextRef ctx , JSObjectRef object, const char *name, JSValueRef value, JSPropertyAttributes attributes, JSValueRef *exception){ - JSStringRef propertyName = JSStringCreateWithUTF8CString(name); + JSStringRef propertyName = JSStringCreateWithUTF8CString(name); JSValueRef localException = NULL; - JSObjectSetProperty(ctx, object, propertyName, value,attributes, &localException); - JSStringRelease(propertyName); + JSObjectSetProperty(ctx, object, propertyName, value,attributes, &localException); + JSStringRelease(propertyName); if( localException != NULL ){ if( exception != NULL ) *exception = localException; @@ -154,6 +154,9 @@ bool JSUtil::JSValueToBoolean(JSContextRef ctx, JSValueRef value){ } time_t JSUtil::JSValueToTimeT(JSContextRef ctx, JSValueRef value){ + if(!JSValueIsDateObject(ctx, value)) + throw TypeMismatchException("Value is not Date Object"); + JSObjectRef timeobj = NULL; timeobj = JSUtil::JSValueToObject(ctx, value); JSValueRef exception = NULL; @@ -173,6 +176,28 @@ time_t JSUtil::JSValueToTimeT(JSContextRef ctx, JSValueRef value){ return second; } +tm JSUtil::JSValueToDateTm(JSContextRef ctx, JSValueRef value){ + tm result = {0}; + + time_t second = JSUtil::JSValueToTimeT(ctx, value); + + if(localtime_r(&second, &result) == NULL) + throw TypeMismatchException("Value is not Date Object"); + + return result; +} + +tm JSUtil::JSValueToDateTmUTC(JSContextRef ctx, JSValueRef value){ + tm result = {0}; + + time_t second = JSUtil::JSValueToTimeT(ctx, value); + + if(gmtime_r(&second, &result) == NULL) + throw TypeMismatchException("Value is not Date Object"); + + return result; +} + JSObjectRef JSUtil::JSValueToObject(JSContextRef ctx, JSValueRef value){ JSValueRef exception = NULL; JSObjectRef obj = ::JSValueToObject(ctx, value,&exception); @@ -293,6 +318,25 @@ vector JSUtil::JSArrayToBoolVector(JSContextRef ctx, JSValueRef value){ return JSArrayToType_(ctx, value, JSUtil::JSValueToBoolean); } +bool JSUtil::JSValueIsDateObject(JSContextRef ctx, JSValueRef jsValue) { + JSValueRef exception = NULL; + + JSObjectRef globalObj = JSContextGetGlobalObject(ctx); + + JSValueRef jsDate = getProperty(ctx, globalObj, "Date", &exception); + if(exception) + return false; + + JSObjectRef jsDateObj = ::JSValueToObject(ctx, jsDate, &exception); + if(exception) + return false; + + bool result = JSValueIsInstanceOfConstructor(ctx, jsValue, jsDateObj, &exception); + if(exception) + return false; + + return result; +} } } diff --git a/src/Common/JSUtil.h b/src/Common/JSUtil.h index 534d090..59d7bb7 100644 --- a/src/Common/JSUtil.h +++ b/src/Common/JSUtil.h @@ -22,7 +22,7 @@ #include #include #include "PlatformException.h" -#include +#include namespace DeviceAPI { @@ -211,6 +211,34 @@ public: static time_t JSValueToTimeT(JSContextRef ctx, JSValueRef value); /** + * @brief Converts a JavaScript value to tm and returns the resulting tm. + * + * @remarks TypeMismatchException is thrown when the value was not Date type. + * + * @param[in] ctx The execution context to use. + * @param[in] value The JSValue to convert. + * + * @return The result of conversion + * + * @exception TypeMismatchException + */ + static std::tm JSValueToDateTm(JSContextRef ctx, JSValueRef value); + + /** + * @brief Converts a JavaScript value to tm as UTC time and returns the resulting tm. + * + * @remarks TypeMismatchException is thrown when the value was not Date type. + * + * @param[in] ctx The execution context to use. + * @param[in] value The JSValue to convert. + * + * @return The result of conversion + * + * @exception TypeMismatchException + */ + static std::tm JSValueToDateTmUTC(JSContextRef ctx, JSValueRef value); + + /** * @brief Converts a JavaScript value to object and returns the resulting object. * * @remarks TypeMismatchException is thrown when the value was not Object type. @@ -523,6 +551,8 @@ public: return jsResult; }; +private: + static bool JSValueIsDateObject(JSContextRef ctx, JSValueRef jsValue); }; }} diff --git a/src/Common/JSWebAPIErrorFactory.cpp b/src/Common/JSWebAPIErrorFactory.cpp index 568e31b..e6d0270 100644 --- a/src/Common/JSWebAPIErrorFactory.cpp +++ b/src/Common/JSWebAPIErrorFactory.cpp @@ -16,8 +16,9 @@ // #include "JSWebAPIErrorFactory.h" + #include -#include + #include "JSStringRefWrapper.h" #include "JSWebAPIException.h" #include "JSWebAPIError.h" @@ -180,7 +181,11 @@ JSObjectRef JSWebAPIErrorFactory::postException(JSContextRef context, const std::string& name, const std::string& message) { - Assert(exception && "Exception object can't be NULL."); + if(exception == NULL) + { + LoggerE("exception ptr is NULL."); + return NULL; + } JSObjectRef exceptionObj = createErrorObject(context, name, message, true); @@ -193,8 +198,6 @@ JSObjectRef JSWebAPIErrorFactory::postException(JSContextRef context, JSValueRef* exception, const BasePlatformException& error) { - Assert(exception && "Exception object can't be NULL."); - return postException(context, exception, error.getName(), error.getMessage()); } @@ -244,15 +247,6 @@ JSObjectRef JSWebAPIErrorFactory::createECMAErrorObject(JSContextRef context, const std::string& name, const std::string& message) { - Assert( (name == ECMA_ERROR_NAME_STR || - name == ECMA_EVAL_ERROR_NAME_STR || - name == ECMA_RANGE_ERROR_NAME_STR || - name == ECMA_REFERENCE_ERROR_NAME_STR || - name == ECMA_SYNTAX_ERROR_NAME_STR || - name == ECMA_TYPE_ERROR_NAME_STR || - name == ECMA_URI_ERROR_NAME_STR ) && - "Name MUST be one of NativeError objects."); - std::string jsCodeStr; jsCodeStr = "new " + name + "("; if(!message.empty()) diff --git a/src/Common/StandaloneConsole/StandaloneConsole.cpp b/src/Common/StandaloneConsole/StandaloneConsole.cpp index 937dc07..3aba307 100755 --- a/src/Common/StandaloneConsole/StandaloneConsole.cpp +++ b/src/Common/StandaloneConsole/StandaloneConsole.cpp @@ -293,7 +293,7 @@ JSContextRef StandaloneConsole::getGlobalContext(){ JSValueRef StandaloneConsole::RunLineEx(const char* line, JSValueRef *exception){ JSStringRef jsScript = JSStringCreateWithUTF8CString(line); int size = strlen(line); - if( size != JSStringGetLength(jsScript) ){ + if( size != static_cast (JSStringGetLength(jsScript))){ cout <<"error - fail to converting JSStringRef"<getAbstractContact(); - contact->copy(insertedContact); + contact->copy(insertedContact); event->setResult(true); event->setExceptionCode(ExceptionCodes::None); } @@ -272,151 +272,121 @@ void AddressBook::AddressBookAddBatch(const EventAddressBookAddBatchPtr &event) contacts_list_h contacts_list = NULL; ContactArrayPtr contacts(NULL); - Try - { - if(!event->getContactsIsSet()) - ThrowMsg(InvalidArgumentException, "Contacts were not set."); + if(!event->getContactsIsSet()) + ThrowMsg(InvalidArgumentException, "Contacts were not set."); - contacts = event->getContacts(); - if(!contacts) - ThrowMsg(InvalidArgumentException, "No contacts."); + contacts = event->getContacts(); + if(!contacts) + ThrowMsg(InvalidArgumentException, "No contacts."); - } - Catch(InvalidArgumentException) + errorCode = contacts_list_create(&contacts_list); + if(errorCode != CONTACTS_ERROR_NONE) { - ContactQueueManagerSingleton::Instance().decreaseQueueList(); - bool isEmpty = ContactQueueManagerSingleton::Instance().empty(); - if(!isEmpty){ - ContactQueueManagerSingleton::Instance().pop(); - } - - LoggerE("Invalid arguments for adding contacts : " << _rethrown_exception.GetMessage()); - event->setResult(false); - event->setExceptionCode(ExceptionCodes::InvalidArgumentException); - return; + ThrowMsg(PlatformException, "Fail to create contacts_list_h"); } - Try + for(ContactArray::iterator i = contacts->begin(); i != contacts->end(); i++) { - errorCode = contacts_list_create(&contacts_list); - if(errorCode != CONTACTS_ERROR_NONE) - { - ThrowMsg(PlatformException, "Fail to create contacts_list_h"); - } + contacts_record_h contacts_record = NULL; + ContactPtr contact = *i; + ContactObjectA2PConverterPtr contactObjConverter(NULL); - for(ContactArray::iterator i = contacts->begin(); i != contacts->end(); i++) + Try { - contacts_record_h contacts_record = NULL; - ContactPtr contact = *i; - ContactObjectA2PConverterPtr contactObjConverter(NULL); - - Try + DPL::SharedPtr newContactT = + DPL::StaticPointerCast(contact); + contacts_record = newContactT->getPlatformContactObject(); + if(contacts_record == NULL) { - DPL::SharedPtr newContactT = - DPL::StaticPointerCast(contact); - contacts_record = newContactT->getPlatformContactObject(); - if(contacts_record == NULL) + errorCode = contacts_record_create(_contacts_contact._uri, &contacts_record); + if(errorCode != CONTACTS_ERROR_NONE) { - errorCode = contacts_record_create(_contacts_contact._uri, &contacts_record); - if(errorCode != CONTACTS_ERROR_NONE) - { - ThrowMsg(PlatformException, "Error during creating contact record : " << errorCode); - } + ThrowMsg(PlatformException, "Error during creating contact record : " << errorCode); } + } - contactObjConverter = ContactObjectA2PConverterPtr( - new ContactObjectA2PConverter(contact, false, contacts_record) ); - contacts_record = contactObjConverter->getPlatformContact(); - - if(contacts_record == NULL) - { - ThrowMsg(PlatformException, "Error during converting contact object"); - } + contactObjConverter = ContactObjectA2PConverterPtr( + new ContactObjectA2PConverter(contact, false, contacts_record) ); + contacts_record = contactObjConverter->getPlatformContact(); - if(m_isUnifiedAddressBook) - errorCode = contacts_record_set_int(contacts_record, _contacts_contact.address_book_id, 0); - else - errorCode = contacts_record_set_int(contacts_record, _contacts_contact.address_book_id, m_id); - if(errorCode != CONTACTS_ERROR_NONE) - { - ThrowMsg(PlatformException, "Error during add address book : " << errorCode); - } + if(contacts_record == NULL) + { + ThrowMsg(PlatformException, "Error during converting contact object"); + } - errorCode = contacts_list_add(contacts_list, contacts_record); - if(errorCode != CONTACTS_ERROR_NONE) - { - ThrowMsg(PlatformException, "Error during add to list : " << errorCode); - } + if(m_isUnifiedAddressBook) + errorCode = contacts_record_set_int(contacts_record, _contacts_contact.address_book_id, 0); + else + errorCode = contacts_record_set_int(contacts_record, _contacts_contact.address_book_id, m_id); + if(errorCode != CONTACTS_ERROR_NONE) + { + ThrowMsg(PlatformException, "Error during add address book : " << errorCode); } - Catch(Exception) + + errorCode = contacts_list_add(contacts_list, contacts_record); + if(errorCode != CONTACTS_ERROR_NONE) { - ThrowMsg(NotFoundException, "Error during converting contact object"); -// LoggerE("Error during converting contact object : " << _rethrown_exception.GetMessage()); -// continue; + ThrowMsg(PlatformException, "Error during add to list : " << errorCode); } } - - KeySharePtrPair *keyPair = new KeySharePtrPair(); - keyPair->key = m_eventMapAcc; - keyPair->addressBook = this; - errorCode = contacts_db_insert_records_async(contacts_list, contactsAddBatchResultCallback, (void*)keyPair); - if(errorCode != CONTACTS_ERROR_NONE) + Catch(InvalidArgumentException) { - delete keyPair; - ThrowMsg(PlatformException, "Error during contacts_db_insert_records_async"); - } + if(contacts_list != NULL) + contacts_list_destroy(contacts_list, true); - errorCode = contacts_list_destroy(contacts_list, true); - contacts_list = NULL; - if(errorCode != CONTACTS_ERROR_NONE) - { - delete keyPair; - ThrowMsg(PlatformException, "Error during contacts_list_destroy"); + ThrowMsg(InvalidArgumentException, "Error during converting contact object"); +// LoggerE("Error during converting contact object : " << _rethrown_exception.GetMessage()); +// continue; } + Catch(PlatformException) + { + if(contacts_list != NULL) + contacts_list_destroy(contacts_list, true); - pair keyEventPair(m_eventMapAcc, event); - m_addBatchEventMap.insert(keyEventPair); - - m_eventMapAcc++; + ThrowMsg(PlatformException, "Error during converting contact object"); +// LoggerE("Error during converting contact object : " << _rethrown_exception.GetMessage()); +// continue; + } + Catch(Exception) + { + if(contacts_list != NULL) + contacts_list_destroy(contacts_list, true); -// event->switchToManualAnswer(); - } - Catch (NotFoundException) - { - ContactQueueManagerSingleton::Instance().decreaseQueueList(); - bool isEmpty = ContactQueueManagerSingleton::Instance().empty(); - if(!isEmpty){ - ContactQueueManagerSingleton::Instance().pop(); + ThrowMsg(Exception, "Error during converting contact object"); +// LoggerE("Error during converting contact object : " << _rethrown_exception.GetMessage()); +// continue; } - LoggerE("Contact doesn't exist : " << _rethrown_exception.GetMessage()); - event->setResult(false); - event->setExceptionCode(ExceptionCodes::NotFoundException); } - Catch (PlatformException) + + KeySharePtrPair *keyPair = new KeySharePtrPair(); + keyPair->key = m_eventMapAcc; + keyPair->addressBook = this; + errorCode = contacts_db_insert_records_async(contacts_list, contactsAddBatchResultCallback, (void*)keyPair); + if(errorCode != CONTACTS_ERROR_NONE) { - ContactQueueManagerSingleton::Instance().decreaseQueueList(); - bool isEmpty = ContactQueueManagerSingleton::Instance().empty(); - if(!isEmpty){ - ContactQueueManagerSingleton::Instance().pop(); - } - LoggerE("Error during adding contacts : " << _rethrown_exception.GetMessage()); - event->setResult(false); - event->setExceptionCode(ExceptionCodes::PlatformException); + delete keyPair; + if(contacts_list != NULL) + contacts_list_destroy(contacts_list, true); + + ThrowMsg(PlatformException, "Error during contacts_db_insert_records_async"); } - Catch (Exception) + + errorCode = contacts_list_destroy(contacts_list, true); + contacts_list = NULL; + if(errorCode != CONTACTS_ERROR_NONE) { - ContactQueueManagerSingleton::Instance().decreaseQueueList(); - bool isEmpty = ContactQueueManagerSingleton::Instance().empty(); - if(!isEmpty){ - ContactQueueManagerSingleton::Instance().pop(); - } - LoggerE("Error during adding contacts : " << _rethrown_exception.GetMessage()); - event->setResult(false); - event->setExceptionCode(ExceptionCodes::PlatformException); + delete keyPair; + if(contacts_list != NULL) + contacts_list_destroy(contacts_list, true); + + ThrowMsg(PlatformException, "Error during contacts_list_destroy"); } - if(contacts_list != NULL) - contacts_list_destroy(contacts_list, true); + pair keyEventPair(m_eventMapAcc, event); + m_addBatchEventMap.insert(keyEventPair); + + m_eventMapAcc++; + } void AddressBook::OnRequestReceived(const EventAddressBookAddBatchPtr &event) @@ -434,6 +404,24 @@ void AddressBook::OnRequestReceived(const EventAddressBookAddBatchPtr &event) ContactQueueManagerSingleton::Instance().increaseQueueList(); event->switchToManualAnswer(); } + Catch (NotFoundException) + { + LoggerE("NotFoundException during adding contacts : " << _rethrown_exception.GetMessage()); + event->setResult(false); + event->setExceptionCode(ExceptionCodes::NotFoundException); + } + Catch (PlatformException) + { + LoggerE("PlatformException during adding contacts : " << _rethrown_exception.GetMessage()); + event->setResult(false); + event->setExceptionCode(ExceptionCodes::PlatformException); + } + Catch(InvalidArgumentException) + { + LoggerE("InvalidArgumentException during adding contacts : " << _rethrown_exception.GetMessage()); + event->setResult(false); + event->setExceptionCode(ExceptionCodes::InvalidArgumentException); + } Catch (Exception) { LoggerE("Error during adding contacts : " << _rethrown_exception.GetMessage()); @@ -513,21 +501,18 @@ void AddressBook::OnRequestReceived(const EventAddressBookUpdatePtr &event) LoggerE("Contact doesn't exist : " << _rethrown_exception.GetMessage()); event->setResult(false); event->setExceptionCode(ExceptionCodes::NotFoundException); - return; } Catch (PlatformException) { LoggerE("Error during adding contact : " << _rethrown_exception.GetMessage()); event->setResult(false); event->setExceptionCode(ExceptionCodes::PlatformException); - return; } Catch (Exception) { LoggerE("Error during adding contact : " << _rethrown_exception.GetMessage()); event->setResult(false); event->setExceptionCode(ExceptionCodes::PlatformException); - return; } //m_latestVersion = get_contact_version(); @@ -542,148 +527,125 @@ void AddressBook::AddressBookUpdateBatch(const EventAddressBookUpdateBatchPtr &e contacts_list_h contacts_list = NULL; ContactArrayPtr contacts(NULL); - Try - { - if(!event->getContactsIsSet()) - ThrowMsg(InvalidArgumentException, "Contacts were not set."); + if(!event->getContactsIsSet()) + ThrowMsg(InvalidArgumentException, "Contacts were not set."); - contacts = event->getContacts(); - if(!contacts) - ThrowMsg(InvalidArgumentException, "No contacts."); + contacts = event->getContacts(); + if(!contacts) + ThrowMsg(InvalidArgumentException, "No contacts."); - } - Catch(InvalidArgumentException) + errorCode = contacts_list_create(&contacts_list); + if(errorCode != CONTACTS_ERROR_NONE) { - ContactQueueManagerSingleton::Instance().decreaseQueueList(); - bool isEmpty = ContactQueueManagerSingleton::Instance().empty(); - if(!isEmpty){ - ContactQueueManagerSingleton::Instance().pop(); - } - LoggerE("Invalid arguments for updating contacts : " << _rethrown_exception.GetMessage()); - event->setResult(false); - event->setExceptionCode(ExceptionCodes::InvalidArgumentException); - return; + if(contacts_list != NULL) + contacts_list_destroy(contacts_list, false); + + ThrowMsg(PlatformException, "Fail to create contacts_list_h"); } - Try + for(ContactArray::iterator i = contacts->begin(); i != contacts->end(); i++) { - errorCode = contacts_list_create(&contacts_list); - if(errorCode != CONTACTS_ERROR_NONE) - { - ThrowMsg(PlatformException, "Fail to create contacts_list_h"); - } + contacts_record_h contacts_record = NULL; + ContactPtr contact = *i; + ContactObjectA2PConverterPtr contactObjConverter(NULL); - for(ContactArray::iterator i = contacts->begin(); i != contacts->end(); i++) + Try { - contacts_record_h contacts_record = NULL; - ContactPtr contact = *i; - ContactObjectA2PConverterPtr contactObjConverter(NULL); + if(!contact) + ThrowMsg(InvalidArgumentException, "No contact."); - Try - { - if(!contact) - ThrowMsg(InvalidArgumentException, "No contact."); + if(contact->getIdIsSet() == false) + ThrowMsg(InvalidArgumentException, "Invalid Contact"); - if(contact->getIdIsSet() == false) - ThrowMsg(InvalidArgumentException, "Invalid Contact"); + if(!m_isUnifiedAddressBook && ( !contact->getAddressBookIdIsSet() || contact->getAddressBookId() != getId())) + ThrowMsg(InvalidArgumentException, "Wrong address book"); - if(!m_isUnifiedAddressBook && ( !contact->getAddressBookIdIsSet() || contact->getAddressBookId() != getId())) - ThrowMsg(InvalidArgumentException, "Wrong address book"); + DPL::SharedPtr newContactT = DPL::StaticPointerCast(contact); + contacts_record = newContactT->getPlatformContactObject(); + if(contacts_record == NULL) + { + int contactIdInt = ContactUtility::strToInt(contact->getId()); + errorCode = contacts_db_get_record(_contacts_contact._uri, contactIdInt, &contacts_record); + if(errorCode != CONTACTS_ERROR_NONE || contacts_record == NULL) + ThrowMsg(NotFoundException, "No contact"); + } + contactObjConverter = ContactObjectA2PConverterPtr( + new ContactObjectA2PConverter(contact, false, contacts_record) ); + contacts_record = contactObjConverter->getPlatformContact(); - DPL::SharedPtr newContactT = - DPL::StaticPointerCast(contact); - contacts_record = newContactT->getPlatformContactObject(); - if(contacts_record == NULL) - { - int contactIdInt = ContactUtility::strToInt(contact->getId()); - errorCode = contacts_db_get_record(_contacts_contact._uri, contactIdInt, &contacts_record); - if(errorCode != CONTACTS_ERROR_NONE || contacts_record == NULL) - ThrowMsg(NotFoundException, "No contact"); - } - contactObjConverter = ContactObjectA2PConverterPtr( - new ContactObjectA2PConverter(contact, false, contacts_record) ); - contacts_record = contactObjConverter->getPlatformContact(); + if(contacts_record == NULL) + ThrowMsg(PlatformException, "Error during converting contact object"); - if(contacts_record == NULL) - { - ThrowMsg(PlatformException, "Error during converting contact object"); - } + errorCode = contacts_list_add(contacts_list, contacts_record); + if(errorCode != CONTACTS_ERROR_NONE) + ThrowMsg(PlatformException, "Error during add to list"); + } + Catch(NotFoundException) + { + if(contacts_list != NULL) + contacts_list_destroy(contacts_list, false); - errorCode = contacts_list_add(contacts_list, contacts_record); - if(errorCode != CONTACTS_ERROR_NONE) - { - ThrowMsg(PlatformException, "Error during add to list"); - } - } - Catch(Exception) - { - ThrowMsg(NotFoundException, "Error during converting contact object"); + ThrowMsg(NotFoundException, "Error during converting contact object"); // LoggerE("Error during converting contact object : " << _rethrown_exception.GetMessage()); // continue; - } } - - KeySharePtrPair *keyPair = new KeySharePtrPair(); - keyPair->key = m_eventMapAcc; - keyPair->addressBook = this; - errorCode = contacts_db_update_records_async(contacts_list, contactsUpdateBatchResultCallback, (void*)keyPair); - if(errorCode != CONTACTS_ERROR_NONE) + Catch(InvalidArgumentException) { - delete keyPair; - ThrowMsg(PlatformException, "Error during contacts_db_update_records_async"); - } + if(contacts_list != NULL) + contacts_list_destroy(contacts_list, false); - errorCode = contacts_list_destroy(contacts_list, true); - contacts_list = NULL; - if(errorCode != CONTACTS_ERROR_NONE) - { - delete keyPair; - ThrowMsg(PlatformException, "Error during contacts_list_destroy"); + ThrowMsg(InvalidArgumentException, "Error during converting contact object"); +// LoggerE("Error during converting contact object : " << _rethrown_exception.GetMessage()); +// continue; } + Catch(PlatformException) + { + if(contacts_list != NULL) + contacts_list_destroy(contacts_list, false); - pair keyEventPair(m_eventMapAcc, event); - m_updateBatchEventMap.insert(keyEventPair); - - m_eventMapAcc++; + ThrowMsg(PlatformException, "Error during converting contact object"); +// LoggerE("Error during converting contact object : " << _rethrown_exception.GetMessage()); +// continue; + } + Catch(Exception) + { + if(contacts_list != NULL) + contacts_list_destroy(contacts_list, false); -// event->switchToManualAnswer(); - } - Catch (NotFoundException) - { - ContactQueueManagerSingleton::Instance().decreaseQueueList(); - bool isEmpty = ContactQueueManagerSingleton::Instance().empty(); - if(!isEmpty){ - ContactQueueManagerSingleton::Instance().pop(); + ThrowMsg(Exception, "Error during converting contact object"); +// LoggerE("Error during converting contact object : " << _rethrown_exception.GetMessage()); +// continue; } - LoggerE("Contact doesn't exist : " << _rethrown_exception.GetMessage()); - event->setResult(false); - event->setExceptionCode(ExceptionCodes::NotFoundException); } - Catch (PlatformException) + + KeySharePtrPair *keyPair = new KeySharePtrPair(); + keyPair->key = m_eventMapAcc; + keyPair->addressBook = this; + errorCode = contacts_db_update_records_async(contacts_list, contactsUpdateBatchResultCallback, (void*)keyPair); + if(errorCode != CONTACTS_ERROR_NONE) { - ContactQueueManagerSingleton::Instance().decreaseQueueList(); - bool isEmpty = ContactQueueManagerSingleton::Instance().empty(); - if(!isEmpty){ - ContactQueueManagerSingleton::Instance().pop(); - } - LoggerE("Error during adding contacts : " << _rethrown_exception.GetMessage()); - event->setResult(false); - event->setExceptionCode(ExceptionCodes::PlatformException); + delete keyPair; + if(contacts_list != NULL) + contacts_list_destroy(contacts_list, false); + + ThrowMsg(PlatformException, "Error during contacts_db_update_records_async"); } - Catch (Exception) + + errorCode = contacts_list_destroy(contacts_list, true); + contacts_list = NULL; + if(errorCode != CONTACTS_ERROR_NONE) { - ContactQueueManagerSingleton::Instance().decreaseQueueList(); - bool isEmpty = ContactQueueManagerSingleton::Instance().empty(); - if(!isEmpty){ - ContactQueueManagerSingleton::Instance().pop(); - } - LoggerE("Error during adding contacts : " << _rethrown_exception.GetMessage()); - event->setResult(false); - event->setExceptionCode(ExceptionCodes::PlatformException); + delete keyPair; + if(contacts_list != NULL) + contacts_list_destroy(contacts_list, false); + + ThrowMsg(PlatformException, "Error during contacts_list_destroy"); } - if(contacts_list != NULL) - contacts_list_destroy(contacts_list, false); + pair keyEventPair(m_eventMapAcc, event); + m_updateBatchEventMap.insert(keyEventPair); + + m_eventMapAcc++; } void AddressBook::OnRequestReceived(const EventAddressBookUpdateBatchPtr &event) @@ -701,9 +663,27 @@ void AddressBook::OnRequestReceived(const EventAddressBookUpdateBatchPtr &event) ContactQueueManagerSingleton::Instance().increaseQueueList(); event->switchToManualAnswer(); } + Catch (NotFoundException) + { + LoggerE("NotFoundException during updating contacts : " << _rethrown_exception.GetMessage()); + event->setResult(false); + event->setExceptionCode(ExceptionCodes::NotFoundException); + } + Catch (PlatformException) + { + LoggerE("PlatformException during updating contacts : " << _rethrown_exception.GetMessage()); + event->setResult(false); + event->setExceptionCode(ExceptionCodes::PlatformException); + } + Catch(InvalidArgumentException) + { + LoggerE("InvalidArgumentException during updating contacts : " << _rethrown_exception.GetMessage()); + event->setResult(false); + event->setExceptionCode(ExceptionCodes::InvalidArgumentException); + } Catch (Exception) { - LoggerE("Error during updating contacts : " << _rethrown_exception.GetMessage()); + LoggerE("Exception during updating contacts : " << _rethrown_exception.GetMessage()); event->setResult(false); event->setExceptionCode(ExceptionCodes::PlatformException); } @@ -787,211 +767,160 @@ void AddressBook::AddressBookRemoveBatch(const EventAddressBookRemoveBatchPtr &e int errorCode = 0; StringArrayPtr contactIds(NULL); - Try - { - if(!event->getContactIdsIsSet()) - ThrowMsg(InvalidArgumentException, "Contact IDs were not set."); + if(!event->getContactIdsIsSet()) + ThrowMsg(InvalidArgumentException, "Contact IDs were not set."); - contactIds = event->getContactIds(); - if(!contactIds) - ThrowMsg(InvalidArgumentException, "Invalid contacts"); + contactIds = event->getContactIds(); + if(!contactIds) + ThrowMsg(InvalidArgumentException, "Invalid contacts"); - } - Catch(InvalidArgumentException) + int *ids = new int[contactIds->size()]; +// int *tmpIds = new int[contactIds->size()]; + int count = 0; + + if(errorCode != CONTACTS_ERROR_NONE) { - ContactQueueManagerSingleton::Instance().decreaseQueueList(); - bool isEmpty = ContactQueueManagerSingleton::Instance().empty(); - if(!isEmpty){ - ContactQueueManagerSingleton::Instance().pop(); - } - LoggerE("Invalid arguments for removing contacts : " << _rethrown_exception.GetMessage()); - event->setResult(false); - event->setExceptionCode(ExceptionCodes::InvalidArgumentException); - return; + ThrowMsg(PlatformException, "Fail to create contacts_list_h"); } - Try + for(StringArray::iterator i = contactIds->begin(); i != contactIds->end(); i++) { - int *ids = new int[contactIds->size()]; -// int *tmpIds = new int[contactIds->size()]; - int count = 0; + string contactIdStr = *i; - if(errorCode != CONTACTS_ERROR_NONE) + Try { - ThrowMsg(PlatformException, "Fail to create contacts_list_h"); - } + int contactId; - for(StringArray::iterator i = contactIds->begin(); i != contactIds->end(); i++) - { - string contactIdStr = *i; + if(!ContactUtility::checkStrIsUInt(contactIdStr)) + ThrowMsg(InvalidArgumentException, "Wrong" ); - Try - { - int contactId; + contactId = ContactUtility::strToInt(contactIdStr); - if(!ContactUtility::checkStrIsUInt(contactIdStr)) - ThrowMsg(InvalidArgumentException, "Wrong" ); + if(!m_isUnifiedAddressBook) + { + contacts_record_h contacts_record = NULL; + errorCode = contacts_db_get_record(_contacts_simple_contact._uri, contactId, &contacts_record); + if(errorCode != CONTACTS_ERROR_NONE || contacts_record == NULL) + ThrowMsg(PlatformException, "No contact"); - contactId = ContactUtility::strToInt(contactIdStr); + int addressBookId = 0; + errorCode = contacts_record_get_int(contacts_record, _contacts_simple_contact.address_book_id, &addressBookId); + if(errorCode != CONTACTS_ERROR_NONE) + ThrowMsg(PlatformException, "Error while getting address book id"); - if(!m_isUnifiedAddressBook) - { - contacts_record_h contacts_record = NULL; - errorCode = contacts_db_get_record(_contacts_simple_contact._uri, contactId, &contacts_record); - if(errorCode != CONTACTS_ERROR_NONE || contacts_record == NULL) - ThrowMsg(PlatformException, "No contact"); - - int addressBookId = 0; - errorCode = contacts_record_get_int(contacts_record, _contacts_simple_contact.address_book_id, &addressBookId); - if(errorCode != CONTACTS_ERROR_NONE) - ThrowMsg(PlatformException, "Error while getting address book id"); - - if(addressBookId != m_id) - ThrowMsg(PlatformException, "Contact is not a member of this address book."); - } + if(addressBookId != m_id) + ThrowMsg(PlatformException, "Contact is not a member of this address book."); + } - ids[count] = contactId; + ids[count] = contactId; // tmpIds[count] = contactId; - count++; - } - Catch(Exception) - { - ThrowMsg(NotFoundException, "Error during converting contact object"); + count++; + } + Catch(Exception) + { + ThrowMsg(NotFoundException, "Error during converting contact object"); // LoggerE("Error during converting contact object : " << _rethrown_exception.GetMessage()); // continue; - } } + } /* - contacts_filter_h filter = NULL; - contacts_query_h query = NULL; - - errorCode = contacts_query_create(_contacts_simple_contact._uri, &query); - if(errorCode != CONTACTS_ERROR_NONE) - ThrowMsg(PlatformException, "contacts_query_create error : " << errorCode << " (" << __FUNCTION__ << ")"); + contacts_filter_h filter = NULL; + contacts_query_h query = NULL; - errorCode = contacts_filter_create( _contacts_simple_contact._uri, &filter ); - if(errorCode != CONTACTS_ERROR_NONE) - ThrowMsg(PlatformException, "contacts_query_create error : " << errorCode << " (" << __FUNCTION__ << ")"); + errorCode = contacts_query_create(_contacts_simple_contact._uri, &query); + if(errorCode != CONTACTS_ERROR_NONE) + ThrowMsg(PlatformException, "contacts_query_create error : " << errorCode << " (" << __FUNCTION__ << ")"); - for(int i = 0; i < contactIds->size(); i++) - { - errorCode = contacts_filter_add_int(filter, _contacts_simple_contact.id, CONTACTS_MATCH_EQUAL, tmpIds[i]); - if(i == (contactIds->size() - 1)) - break; + errorCode = contacts_filter_create( _contacts_simple_contact._uri, &filter ); + if(errorCode != CONTACTS_ERROR_NONE) + ThrowMsg(PlatformException, "contacts_query_create error : " << errorCode << " (" << __FUNCTION__ << ")"); - errorCode = contacts_filter_add_operator(filter, CONTACTS_FILTER_OPERATOR_OR); - if(errorCode != CONTACTS_ERROR_NONE) - ThrowMsg(PlatformException, "contacts_filter_add_operator error : " << errorCode << " (" << __FUNCTION__ << ")"); - } + for(int i = 0; i < contactIds->size(); i++) + { + errorCode = contacts_filter_add_int(filter, _contacts_simple_contact.id, CONTACTS_MATCH_EQUAL, tmpIds[i]); + if(i == (contactIds->size() - 1)) + break; - errorCode = contacts_query_set_filter(query, filter); + errorCode = contacts_filter_add_operator(filter, CONTACTS_FILTER_OPERATOR_OR); if(errorCode != CONTACTS_ERROR_NONE) - ThrowMsg(PlatformException, "contacts_query_set_filter error : " << errorCode << " (" << __FUNCTION__ << ")"); + ThrowMsg(PlatformException, "contacts_filter_add_operator error : " << errorCode << " (" << __FUNCTION__ << ")"); + } - int record_count = 0; - errorCode = contacts_db_get_count_with_query(query, &record_count); - if(errorCode != CONTACTS_ERROR_NONE) - ThrowMsg(PlatformException, "contacts_db_get_count_with_query error : " << errorCode << " (" << __FUNCTION__ << ")"); + errorCode = contacts_query_set_filter(query, filter); + if(errorCode != CONTACTS_ERROR_NONE) + ThrowMsg(PlatformException, "contacts_query_set_filter error : " << errorCode << " (" << __FUNCTION__ << ")"); + + int record_count = 0; + errorCode = contacts_db_get_count_with_query(query, &record_count); + if(errorCode != CONTACTS_ERROR_NONE) + ThrowMsg(PlatformException, "contacts_db_get_count_with_query error : " << errorCode << " (" << __FUNCTION__ << ")"); - if(filter != NULL) - contacts_filter_destroy(filter); - if(query != NULL) - contacts_query_destroy(query); + if(filter != NULL) + contacts_filter_destroy(filter); + if(query != NULL) + contacts_query_destroy(query); - if(contactIds->size() != (unsigned int)record_count) - ThrowMsg(InvalidArgumentException, "Ids' db count : " << record_count << " (" << __FUNCTION__ << ")"); + if(contactIds->size() != (unsigned int)record_count) + ThrowMsg(InvalidArgumentException, "Ids' db count : " << record_count << " (" << __FUNCTION__ << ")"); */ - KeySharePtrPair *keyPair = new KeySharePtrPair(); - keyPair->key = m_eventMapAcc; - keyPair->addressBook = this; - errorCode = contacts_db_delete_records_async(_contacts_contact._uri, ids, count, contactsRemoveBatchResultCallback, (void*)keyPair); - if(ids != NULL) - { - delete [] ids; - } + KeySharePtrPair *keyPair = new KeySharePtrPair(); + keyPair->key = m_eventMapAcc; + keyPair->addressBook = this; + errorCode = contacts_db_delete_records_async(_contacts_contact._uri, ids, count, contactsRemoveBatchResultCallback, (void*)keyPair); + if(ids != NULL) + { + delete [] ids; + } /* - if(tmpIds != NULL) - { - delete [] tmpIds; - } + if(tmpIds != NULL) + { + delete [] tmpIds; + } */ - if(errorCode != CONTACTS_ERROR_NONE) - { - delete keyPair; - ThrowMsg(PlatformException, "Error during add to list"); - } + if(errorCode != CONTACTS_ERROR_NONE) + { + delete keyPair; + ThrowMsg(PlatformException, "Error during add to list"); + } + + pair keyEventPair(m_eventMapAcc, event); + m_removeBatchEventMap.insert(keyEventPair); - pair keyEventPair(m_eventMapAcc, event); - m_removeBatchEventMap.insert(keyEventPair); + m_eventMapAcc++; +} - m_eventMapAcc++; +void AddressBook::OnRequestReceived(const EventAddressBookRemoveBatchPtr &event) +{ + LoggerD("entered"); -// event->switchToManualAnswer(); - } - Catch (InvalidArgumentException) + Try { - ContactQueueManagerSingleton::Instance().decreaseQueueList(); bool isEmpty = ContactQueueManagerSingleton::Instance().empty(); - if(!isEmpty){ - ContactQueueManagerSingleton::Instance().pop(); + if(isEmpty){ + AddressBookRemoveBatch(event); + }else{ + ContactQueueManagerSingleton::Instance().push(ContactQueueManager::DELETEBATCH, this, event); } - LoggerE("Invalid contact id : " << _rethrown_exception.GetMessage()); - event->setResult(false); - event->setExceptionCode(ExceptionCodes::InvalidArgumentException); - return; + ContactQueueManagerSingleton::Instance().increaseQueueList(); + event->switchToManualAnswer(); } Catch (NotFoundException) { - ContactQueueManagerSingleton::Instance().decreaseQueueList(); - bool isEmpty = ContactQueueManagerSingleton::Instance().empty(); - if(!isEmpty){ - ContactQueueManagerSingleton::Instance().pop(); - } LoggerE("Contact doesn't exist : " << _rethrown_exception.GetMessage()); event->setResult(false); event->setExceptionCode(ExceptionCodes::NotFoundException); - return; } Catch (PlatformException) { - ContactQueueManagerSingleton::Instance().decreaseQueueList(); - bool isEmpty = ContactQueueManagerSingleton::Instance().empty(); - if(!isEmpty){ - ContactQueueManagerSingleton::Instance().pop(); - } LoggerE("Error during deleting contacts : " << _rethrown_exception.GetMessage()); event->setResult(false); event->setExceptionCode(ExceptionCodes::PlatformException); - return; } - Catch (Exception) + Catch(InvalidArgumentException) { - ContactQueueManagerSingleton::Instance().decreaseQueueList(); - bool isEmpty = ContactQueueManagerSingleton::Instance().empty(); - if(!isEmpty){ - ContactQueueManagerSingleton::Instance().pop(); - } - LoggerE("Error during deleting contacts : " << _rethrown_exception.GetMessage()); + LoggerE("Invalid contact id : " << _rethrown_exception.GetMessage()); event->setResult(false); - event->setExceptionCode(ExceptionCodes::PlatformException); - return; - } -} - -void AddressBook::OnRequestReceived(const EventAddressBookRemoveBatchPtr &event) -{ - LoggerD("entered"); - - Try - { - bool isEmpty = ContactQueueManagerSingleton::Instance().empty(); - if(isEmpty){ - AddressBookRemoveBatch(event); - }else{ - ContactQueueManagerSingleton::Instance().push(ContactQueueManager::DELETEBATCH, this, event); - } - ContactQueueManagerSingleton::Instance().increaseQueueList(); - event->switchToManualAnswer(); + event->setExceptionCode(ExceptionCodes::InvalidArgumentException); } Catch (Exception) { diff --git a/src/Contact/ContactAddress.cpp b/src/Contact/ContactAddress.cpp index 1e1228d..9295185 100755 --- a/src/Contact/ContactAddress.cpp +++ b/src/Contact/ContactAddress.cpp @@ -304,6 +304,9 @@ void ContactAddress::clear() m_postalCode = ""; m_postalCodeIsSet = false; + m_label = ""; + m_labelIsSet = false; + m_isDefault = false; m_types = ContactAddressTypeArrayPtr(new ContactAddressTypeArray()); @@ -333,6 +336,9 @@ ContactAddressPtr ContactAddress::clone() const result->m_isDefault = m_isDefault; + result->m_label = m_label; + result->m_labelIsSet = m_labelIsSet; + result->m_types = ContactAddressTypeArrayPtr(new ContactAddressTypeArray()); ContactAddressTypeArray::iterator typeIter; for(typeIter = m_types->begin(); typeIter != m_types->end(); typeIter++) @@ -344,6 +350,22 @@ ContactAddressPtr ContactAddress::clone() const return result; } +std::string ContactAddress::getLabel() const +{ + return m_label; +} + +void ContactAddress::setLabel(const std::string &value) +{ + m_label = value; + m_labelIsSet = true; +} + +bool ContactAddress::getLabelIsSet() const +{ + return m_labelIsSet; +} + void ContactAddress::setTypesJSArray(bool value, JSObjectRef initValue) { is_typesSetJSArray = value; diff --git a/src/Contact/ContactAddress.h b/src/Contact/ContactAddress.h index d0c52ae..1657b1a 100755 --- a/src/Contact/ContactAddress.h +++ b/src/Contact/ContactAddress.h @@ -99,6 +99,10 @@ public: void clear(); ContactAddressPtr clone() const; + std::string getLabel() const; + void setLabel(const std::string &value); + bool getLabelIsSet() const; + void setTypesJSArray(bool value, JSObjectRef initValue); JSValueRef getTypesJSArray(); JSObjectRef getTypesJSObj(); @@ -131,6 +135,9 @@ private: ContactAddressTypeArrayPtr m_types; + std::string m_label; + bool m_labelIsSet; + bool is_typesSetJSArray; JSValueRef m_typesJsValue; JSObjectRef m_typesObj; diff --git a/src/Contact/ContactConverter.cpp b/src/Contact/ContactConverter.cpp index 7535cc5..0e306de 100755 --- a/src/Contact/ContactConverter.cpp +++ b/src/Contact/ContactConverter.cpp @@ -49,7 +49,6 @@ #define CONTACT_ATTRIBUTE_ADDITIONAL_INFORMATION "additionalInformation" #define CONTACT_ATTRIBUTE_ADDRESSES "addresses" #define CONTACT_ATTRIBUTE_ANNIVERSARIES "anniversaries" -//#define CONTACT_ATTRIBUTE_ATTRIBUTES_OF_INTEREST "attributesOfInterest" #define CONTACT_ATTRIBUTE_BIRTHDAY "birthday" #define CONTACT_ATTRIBUTE_CITY "city" #define CONTACT_ATTRIBUTE_CONTACT_ID "contactId" @@ -79,6 +78,7 @@ #define CONTACT_ATTRIBUTE_ORGANIZATIONS "organizations" #define CONTACT_ATTRIBUTE_PHONE_NUMBERS "phoneNumbers" #define CONTACT_ATTRIBUTE_PHONETIC_FIRST_NAME "phoneticFirstName" +#define CONTACT_ATTRIBUTE_PHONETIC_MIDDLE_NAME "phoneticMiddleName" #define CONTACT_ATTRIBUTE_PHONETIC_LAST_NAME "phoneticLastName" #define CONTACT_ATTRIBUTE_PHOTO_URI "photoURI" #define CONTACT_ATTRIBUTE_POSITION "position" @@ -93,14 +93,21 @@ #define CONTACT_ATTRIBUTE_TITLE "title" #define CONTACT_ATTRIBUTE_TYPE "type" #define CONTACT_ATTRIBUTE_TYPES "types" +#define CONTACT_ATTRIBUTE_LABEL "label" #define CONTACT_ATTRIBUTE_URL "url" #define CONTACT_ATTRIBUTE_URLS "urls" +#define CONTACT_ATTRIBUTE_ASSISTANT_NAME "assistant" +#define CONTACT_ATTRIBUTE_LOCATION "location" +#define CONTACT_ATTRIBUTE_DESCRIPTION "description" +#define CONTACT_ATTRIBUTE_PHONETIC_NAME "phoneticName" + #define STR_CONTACT_EMPTY_STRING "" #define STR_CONTACT_EMAIL_TYPE_WORK "WORK" #define STR_CONTACT_EMAIL_TYPE_PREF "PREF" #define STR_CONTACT_EMAIL_TYPE_HOME "HOME" +#define STR_CONTACT_EMAIL_TYPE_MOBILE "MOBILE" #define STR_CONTACT_PHONE_NUMBER_TYPE_WORK "WORK" #define STR_CONTACT_PHONE_NUMBER_TYPE_PREF "PREF" @@ -116,14 +123,22 @@ #define STR_CONTACT_PHONE_NUMBER_TYPE_ISDN "ISDN" #define STR_CONTACT_PHONE_NUMBER_TYPE_VIDEO "VIDEO" #define STR_CONTACT_PHONE_NUMBER_TYPE_PCS "PCS" +#define STR_CONTACT_PHONE_NUMBER_TYPE_ASSISTANT "ASSISTANT" #define STR_CONTACT_ADDRESS_TYPE_WORK "WORK" #define STR_CONTACT_ADDRESS_TYPE_PREF "PREF" #define STR_CONTACT_ADDRESS_TYPE_HOME "HOME" +#define STR_CONTACT_ADDRESS_TYPE_DOM "DOM" +#define STR_CONTACT_ADDRESS_TYPE_INTL "INTL" +#define STR_CONTACT_ADDRESS_TYPE_POSTAL "POSTAL" +#define STR_CONTACT_ADDRESS_TYPE_PARCEL "PARCEL" #define STR_WEBSITE_TYPE_HOMEPAGE "HOMEPAGE" #define STR_WEBSITE_TYPE_BLOG "BLOG" +#define STR_ORGANIZATION_TYPE_WORK "WORK" +#define STR_ORGANIZATION_TYPE_OTHER "OTHER" + namespace DeviceAPI { namespace Contact { @@ -458,7 +473,7 @@ ContactArrayPtr ContactConverter::toContactArray(const JSValueRef &jsValue) ContactPtr tmpContactObj = toContact(element); duplicate = false; - for(int j=0; jsize(); j++){ + for(unsigned int j=0; jsize(); j++){ if(result->at(j) == tmpContactObj) duplicate = true; } @@ -624,6 +639,7 @@ ContactNamePtr ContactConverter::toContactNameFromInit(const JSValueRef &jsValue const ScopedJSStringRef lastNameStr(JSStringCreateWithUTF8CString(CONTACT_ATTRIBUTE_LAST_NAME)); const ScopedJSStringRef nicknamesStr(JSStringCreateWithUTF8CString(CONTACT_ATTRIBUTE_NICKNAMES)); const ScopedJSStringRef phoneticFirstNameStr(JSStringCreateWithUTF8CString(CONTACT_ATTRIBUTE_PHONETIC_FIRST_NAME)); + const ScopedJSStringRef phoneticMiddleNameStr(JSStringCreateWithUTF8CString(CONTACT_ATTRIBUTE_PHONETIC_MIDDLE_NAME)); const ScopedJSStringRef phoneticLastNameStr(JSStringCreateWithUTF8CString(CONTACT_ATTRIBUTE_PHONETIC_LAST_NAME)); JSObjectRef jsObject = toJSObjectRef(jsValue); @@ -635,6 +651,7 @@ ContactNamePtr ContactConverter::toContactNameFromInit(const JSValueRef &jsValue JSValueRef lastNameData = JSObjectGetProperty(m_context, jsObject, lastNameStr.get(), NULL); JSValueRef nicknamesData = JSObjectGetProperty(m_context, jsObject, nicknamesStr.get(), NULL); JSValueRef phoneticFirstNameData = JSObjectGetProperty(m_context, jsObject, phoneticFirstNameStr.get(), NULL); + JSValueRef phoneticMiddleNameData = JSObjectGetProperty(m_context, jsObject, phoneticMiddleNameStr.get(), NULL); JSValueRef phoneticLastNameData = JSObjectGetProperty(m_context, jsObject, phoneticLastNameStr.get(), NULL); std::string prefix; @@ -644,6 +661,7 @@ ContactNamePtr ContactConverter::toContactNameFromInit(const JSValueRef &jsValue std::string lastName; StringArrayPtr nicknames; std::string phoneticFirstName; + std::string phoneticMiddleName; std::string phoneticLastName; ContactNamePtr result = ContactNamePtr(new ContactName()); @@ -698,6 +716,13 @@ ContactNamePtr ContactConverter::toContactNameFromInit(const JSValueRef &jsValue result->setPhoneticFirstName(phoneticFirstName); } + if (!validator.isNullOrUndefined(phoneticMiddleNameData)) { + if(!JSValueIsString(m_context, phoneticMiddleNameData)) + ThrowMsg(WrtDeviceApis::Commons::ConversionException, "phoneticMiddleName is not string"); + phoneticMiddleName = toString(phoneticMiddleNameData); + result->setPhoneticMiddleName(phoneticMiddleName); + } + if (!validator.isNullOrUndefined(phoneticLastNameData)) { if(!JSValueIsString(m_context, phoneticLastNameData)) ThrowMsg(WrtDeviceApis::Commons::ConversionException, "phoneticLastName is not string"); @@ -749,6 +774,12 @@ ContactOrganizationPtr ContactConverter::toContactOrganizationFromInit(const JSV const ScopedJSStringRef titleStr(JSStringCreateWithUTF8CString(CONTACT_ATTRIBUTE_TITLE)); const ScopedJSStringRef roleStr(JSStringCreateWithUTF8CString(CONTACT_ATTRIBUTE_ROLE)); const ScopedJSStringRef logoURIStr(JSStringCreateWithUTF8CString(CONTACT_ATTRIBUTE_LOGO_URI)); + const ScopedJSStringRef assistantStr(JSStringCreateWithUTF8CString(CONTACT_ATTRIBUTE_ASSISTANT_NAME)); + const ScopedJSStringRef locationStr(JSStringCreateWithUTF8CString(CONTACT_ATTRIBUTE_LOCATION)); + const ScopedJSStringRef descriptionStr(JSStringCreateWithUTF8CString(CONTACT_ATTRIBUTE_DESCRIPTION)); + const ScopedJSStringRef phoneticNameStr(JSStringCreateWithUTF8CString(CONTACT_ATTRIBUTE_PHONETIC_NAME)); + const ScopedJSStringRef typeStr(JSStringCreateWithUTF8CString(CONTACT_ATTRIBUTE_TYPE)); + const ScopedJSStringRef labelStr(JSStringCreateWithUTF8CString(CONTACT_ATTRIBUTE_LABEL)); JSObjectRef jsObject = toJSObjectRef(jsValue); @@ -757,12 +788,24 @@ ContactOrganizationPtr ContactConverter::toContactOrganizationFromInit(const JSV JSValueRef titleData = JSObjectGetProperty(m_context, jsObject, titleStr.get(), NULL); JSValueRef roleData = JSObjectGetProperty(m_context, jsObject, roleStr.get(), NULL); JSValueRef logoURIData = JSObjectGetProperty(m_context, jsObject, logoURIStr.get(), NULL); + JSValueRef assistantData = JSObjectGetProperty(m_context, jsObject, assistantStr.get(), NULL); + JSValueRef locationData = JSObjectGetProperty(m_context, jsObject, locationStr.get(), NULL); + JSValueRef descriptionData = JSObjectGetProperty(m_context, jsObject, descriptionStr.get(), NULL); + JSValueRef phoneticNameData = JSObjectGetProperty(m_context, jsObject, phoneticNameStr.get(), NULL); + JSValueRef typeData = JSObjectGetProperty(m_context, jsObject, typeStr.get(), NULL); + JSValueRef labelData = JSObjectGetProperty(m_context, jsObject, labelStr.get(), NULL); std::string name; std::string department; std::string title; std::string role; std::string logoURI; + std::string assistant; + std::string location; + std::string description; + std::string phoneticName; + ContactOrganizationType type; + std::string label; ContactOrganizationPtr result(new ContactOrganization()); if (!result) { @@ -804,6 +847,48 @@ ContactOrganizationPtr ContactConverter::toContactOrganizationFromInit(const JSV result->setLogoURI(logoURI); } + if (!validator.isNullOrUndefined(assistantData)) { + if(!JSValueIsString(m_context, assistantData)) + ThrowMsg(WrtDeviceApis::Commons::ConversionException, "assistant is not string"); + assistant = toString(assistantData); + result->setAssistant(assistant); + } + + if (!validator.isNullOrUndefined(locationData)) { + if(!JSValueIsString(m_context, locationData)) + ThrowMsg(WrtDeviceApis::Commons::ConversionException, "location is not string"); + location = toString(locationData); + result->setLocation(location); + } + + if (!validator.isNullOrUndefined(descriptionData)) { + if(!JSValueIsString(m_context, descriptionData)) + ThrowMsg(WrtDeviceApis::Commons::ConversionException, "description is not string"); + description = toString(descriptionData); + result->setDescription(description); + } + + if (!validator.isNullOrUndefined(phoneticNameData)) { + if(!JSValueIsString(m_context, phoneticNameData)) + ThrowMsg(WrtDeviceApis::Commons::ConversionException, "phoneticName is not string"); + phoneticName = toString(phoneticNameData); + result->setPhoneticName(phoneticName); + } + + if (!validator.isNullOrUndefined(typeData)) { + if(!JSValueIsString(m_context, typeData)) + ThrowMsg(WrtDeviceApis::Commons::ConversionException, "type is not string"); + type = toContactOrganizationType(typeData); + result->setType(type); + } + + if (!validator.isNullOrUndefined(labelData)) { + if(!JSValueIsString(m_context, labelData)) + ThrowMsg(WrtDeviceApis::Commons::ConversionException, "label is not string"); + label = toString(labelData); + result->setLabel(label); + } + return result; } @@ -981,6 +1066,7 @@ ContactAddressPtr ContactConverter::toContactAddressFromInit(const JSValueRef &j const ScopedJSStringRef postalCodeStr(JSStringCreateWithUTF8CString(CONTACT_ATTRIBUTE_POSTAL_CODE)); const ScopedJSStringRef isDefaultStr(JSStringCreateWithUTF8CString(CONTACT_ATTRIBUTE_IS_DEFAULT)); const ScopedJSStringRef typesStr(JSStringCreateWithUTF8CString(CONTACT_ATTRIBUTE_TYPES)); + const ScopedJSStringRef labelStr(JSStringCreateWithUTF8CString(CONTACT_ATTRIBUTE_LABEL)); JSObjectRef jsObject = toJSObjectRef(jsValue); @@ -992,6 +1078,7 @@ ContactAddressPtr ContactConverter::toContactAddressFromInit(const JSValueRef &j JSValueRef postalCodeData = JSObjectGetProperty(m_context, jsObject, postalCodeStr.get(), NULL); JSValueRef isDefaultData = JSObjectGetProperty(m_context, jsObject, isDefaultStr.get(), NULL); JSValueRef typesData = JSObjectGetProperty(m_context, jsObject, typesStr.get(), NULL); + JSValueRef labelData = JSObjectGetProperty(m_context, jsObject, labelStr.get(), NULL); std::string country; std::string region; @@ -1001,6 +1088,7 @@ ContactAddressPtr ContactConverter::toContactAddressFromInit(const JSValueRef &j std::string postalCode; bool isDefault; ContactAddressTypeArrayPtr types; + std::string label; ContactAddressPtr result(new ContactAddress()); if (!result) { @@ -1063,6 +1151,13 @@ ContactAddressPtr ContactConverter::toContactAddressFromInit(const JSValueRef &j result->setTypes(typeArray); } + if (!validator.isNullOrUndefined(labelData)) { + if(!JSValueIsString(m_context, labelData)) + ThrowMsg(WrtDeviceApis::Commons::ConversionException, "labelData is not string"); + label = toString(labelData); + result->setLabel(label); + } + return result; } @@ -1237,6 +1332,44 @@ JSValueRef ContactConverter::toJSValueRef(ContactWebSiteType arg) return toJSValueRef(toContactWebSiteTypeStr(arg)); } +ContactOrganizationType ContactConverter::toContactOrganizationType(const std::string &arg) +{ + std::string argUpper; + std::transform(arg.begin(), arg.end(), std::back_inserter(argUpper), ::toupper); + + if (argUpper == STR_ORGANIZATION_TYPE_WORK) { + return ORGANIZATION_TYPE_WORK; + } else if (argUpper == STR_ORGANIZATION_TYPE_OTHER) { + return ORGANIZATION_TYPE_OTHER; + } + + return ORGANIZATION_TYPE_WORK; +} + +std::string ContactConverter::toContactOrganizationTypeStr(ContactOrganizationType arg) +{ + if (arg == ORGANIZATION_TYPE_WORK) { + return STR_ORGANIZATION_TYPE_WORK; + } else if (arg == ORGANIZATION_TYPE_OTHER) { + return STR_ORGANIZATION_TYPE_OTHER; + } + + return STR_ORGANIZATION_TYPE_WORK; +} + +ContactOrganizationType ContactConverter::toContactOrganizationType(const JSValueRef &value) +{ + if(!JSValueIsString(m_context, value)) + ThrowMsg(WrtDeviceApis::Commons::ConversionException, "ContactWebSiteType is not string."); + + return toContactOrganizationType(toString(value)); +} + +JSValueRef ContactConverter::toJSValueRef(ContactOrganizationType arg) +{ + return toJSValueRef(toContactOrganizationTypeStr(arg)); +} + ContactAddressType ContactConverter::toContactAddressType(const std::string &arg) { std::string argUpper; @@ -1248,6 +1381,14 @@ ContactAddressType ContactConverter::toContactAddressType(const std::string &arg return CONTACT_ADDRESS_TYPE_PREF; } else if (argUpper == STR_CONTACT_ADDRESS_TYPE_HOME) { return CONTACT_ADDRESS_TYPE_HOME; + } else if (argUpper == STR_CONTACT_ADDRESS_TYPE_DOM) { + return CONTACT_ADDRESS_TYPE_DOM; + } else if (argUpper == STR_CONTACT_ADDRESS_TYPE_INTL) { + return CONTACT_ADDRESS_TYPE_INTL; + } else if (argUpper == STR_CONTACT_ADDRESS_TYPE_POSTAL) { + return CONTACT_ADDRESS_TYPE_POSTAL; + } else if (argUpper == STR_CONTACT_ADDRESS_TYPE_PARCEL) { + return CONTACT_ADDRESS_TYPE_PARCEL; } //ThrowMsg(WrtDeviceApis::Commons::ConversionException, "Invalid ContactAddressType : " << arg); @@ -1262,6 +1403,14 @@ std::string ContactConverter::toContactAddressTypeStr(ContactAddressType arg) return STR_CONTACT_ADDRESS_TYPE_PREF; } else if (arg == CONTACT_ADDRESS_TYPE_HOME) { return STR_CONTACT_ADDRESS_TYPE_HOME; + } else if (arg == CONTACT_ADDRESS_TYPE_DOM) { + return STR_CONTACT_ADDRESS_TYPE_DOM; + } else if (arg == CONTACT_ADDRESS_TYPE_INTL) { + return STR_CONTACT_ADDRESS_TYPE_INTL; + } else if (arg == CONTACT_ADDRESS_TYPE_POSTAL) { + return STR_CONTACT_ADDRESS_TYPE_POSTAL; + } else if (arg == CONTACT_ADDRESS_TYPE_PARCEL) { + return STR_CONTACT_ADDRESS_TYPE_PARCEL; } //ThrowMsg(WrtDeviceApis::Commons::ConversionException, "Invalid ContactAddressType : " << arg); @@ -1353,6 +1502,8 @@ ContactPhoneNumberType ContactConverter::toContactPhoneNumberType(const std::str return CONTACT_PHONE_NUMBER_TYPE_VIDEO; } else if (argUpper == STR_CONTACT_PHONE_NUMBER_TYPE_PCS) { return CONTACT_PHONE_NUMBER_TYPE_PCS; + } else if (argUpper == STR_CONTACT_PHONE_NUMBER_TYPE_ASSISTANT) { + return CONTACT_PHONE_NUMBER_TYPE_ASSISTANT; } //ThrowMsg(WrtDeviceApis::Commons::ConversionException, "Invalid ContactPhoneNumverType : " << arg); @@ -1389,6 +1540,8 @@ std::string ContactConverter::toContactPhoneNumberTypeStr(ContactPhoneNumberType return STR_CONTACT_PHONE_NUMBER_TYPE_VIDEO; } else if (arg == CONTACT_PHONE_NUMBER_TYPE_PCS) { return STR_CONTACT_PHONE_NUMBER_TYPE_PCS; + } else if (arg == CONTACT_PHONE_NUMBER_TYPE_ASSISTANT) { + return STR_CONTACT_PHONE_NUMBER_TYPE_ASSISTANT; } //ThrowMsg(WrtDeviceApis::Commons::ConversionException, "Invalid ContactPhoneNumberType : " << arg); @@ -1433,11 +1586,20 @@ ContactPhoneNumberTypeArrayPtr ContactConverter::toContactPhoneNumberTypeArray(c if(!JSIsArrayValue(m_context, jsValue) || JSValueIsNull(m_context, jsValue)) return result; + bool duplicate = false; + JSObjectRef jsObject = toJSObjectRef(jsValue); for (std::size_t i = 0; i < JSGetArrayLength(m_context, jsObject); ++i) { JSValueRef element = JSGetArrayElement(m_context, jsObject, i); Try { - result->push_back(toContactPhoneNumberType(element)); + ContactPhoneNumberType tempType = toContactPhoneNumberType(element); + duplicate = false; + for(unsigned int j=0; jsize(); j++){ + if(result->at(j) == tempType) + duplicate = true; + } + if(!duplicate) + result->push_back(toContactPhoneNumberType(element)); } Catch (Exception) { // nothing } @@ -1456,6 +1618,8 @@ ContactEmailAddressType ContactConverter::toContactEmailAddressType(const std::s return CONTACT_EMAIL_TYPE_PREF; } else if (argUpper == STR_CONTACT_EMAIL_TYPE_HOME) { return CONTACT_EMAIL_TYPE_HOME; + } else if (argUpper == STR_CONTACT_EMAIL_TYPE_MOBILE) { + return CONTACT_EMAIL_TYPE_MOBILE; } //ThrowMsg(WrtDeviceApis::Commons::ConversionException, "Invalid ContactEmailAddressType : " << arg); @@ -1470,6 +1634,8 @@ std::string ContactConverter::toContactEmailAddressTypeStr(ContactEmailAddressTy return STR_CONTACT_EMAIL_TYPE_PREF; } else if (arg == CONTACT_EMAIL_TYPE_HOME) { return STR_CONTACT_EMAIL_TYPE_HOME; + } else if (arg == CONTACT_EMAIL_TYPE_MOBILE) { + return STR_CONTACT_EMAIL_TYPE_MOBILE; } //ThrowMsg(WrtDeviceApis::Commons::ConversionException, "Invalid ContactEmailAddressType : " << arg); @@ -1514,11 +1680,21 @@ ContactEmailAddressTypeArrayPtr ContactConverter::toContactEmailAddressTypeArray if(!JSIsArrayValue(m_context, jsValue) || JSValueIsNull(m_context, jsValue)) return result; + bool duplicate = false; + JSObjectRef jsObject = toJSObjectRef(jsValue); for (std::size_t i = 0; i < JSGetArrayLength(m_context, jsObject); ++i) { JSValueRef element = JSGetArrayElement(m_context, jsObject, i); Try { - result->push_back(toContactEmailAddressType(element)); + ContactEmailAddressType tempType = toContactEmailAddressType(element); + duplicate = false; + for(unsigned int j=0; jsize(); j++){ + if(result->at(j) == tempType) + duplicate = true; + } + if(!duplicate) + result->push_back(toContactEmailAddressType(element)); + } Catch (Exception) { // nothing } @@ -1580,6 +1756,7 @@ bool ContactConverter::initializeAllowedProperties() m_allowedContactNameInit.push_back(CONTACT_ATTRIBUTE_LAST_NAME); m_allowedContactNameInit.push_back(CONTACT_ATTRIBUTE_NICKNAMES); m_allowedContactNameInit.push_back(CONTACT_ATTRIBUTE_PHONETIC_FIRST_NAME); + m_allowedContactNameInit.push_back(CONTACT_ATTRIBUTE_PHONETIC_MIDDLE_NAME); m_allowedContactNameInit.push_back(CONTACT_ATTRIBUTE_PHONETIC_LAST_NAME); m_allowedContactNameInit.push_back(CONTACT_ATTRIBUTE_DISPLAY_NAME); @@ -1589,6 +1766,12 @@ bool ContactConverter::initializeAllowedProperties() m_allowedContactOrganizationInit.push_back(CONTACT_ATTRIBUTE_TITLE); m_allowedContactOrganizationInit.push_back(CONTACT_ATTRIBUTE_ROLE); m_allowedContactOrganizationInit.push_back(CONTACT_ATTRIBUTE_LOGO_URI); + m_allowedContactOrganizationInit.push_back(CONTACT_ATTRIBUTE_ASSISTANT_NAME); + m_allowedContactOrganizationInit.push_back(CONTACT_ATTRIBUTE_LOCATION); + m_allowedContactOrganizationInit.push_back(CONTACT_ATTRIBUTE_DESCRIPTION); + m_allowedContactOrganizationInit.push_back(CONTACT_ATTRIBUTE_PHONETIC_NAME); + m_allowedContactOrganizationInit.push_back(CONTACT_ATTRIBUTE_LABEL); + m_allowedContactOrganizationInit.push_back(CONTACT_ATTRIBUTE_TYPE); m_allowedContactAddressInit.push_back(CONTACT_ATTRIBUTE_COUNTRY); m_allowedContactAddressInit.push_back(CONTACT_ATTRIBUTE_REGION); @@ -1597,6 +1780,7 @@ bool ContactConverter::initializeAllowedProperties() m_allowedContactAddressInit.push_back(CONTACT_ATTRIBUTE_ADDITIONAL_INFORMATION); m_allowedContactAddressInit.push_back(CONTACT_ATTRIBUTE_POSTAL_CODE); m_allowedContactAddressInit.push_back(CONTACT_ATTRIBUTE_TYPES); + m_allowedContactAddressInit.push_back(CONTACT_ATTRIBUTE_LABEL); return true; } diff --git a/src/Contact/ContactConverter.h b/src/Contact/ContactConverter.h index 284e3e7..2a9811e 100755 --- a/src/Contact/ContactConverter.h +++ b/src/Contact/ContactConverter.h @@ -132,6 +132,12 @@ public: ContactWebSiteType toContactWebSiteType(const JSValueRef &value); JSValueRef toJSValueRef(ContactWebSiteType arg); + // ContactOrganizationType + ContactOrganizationType toContactOrganizationType(const std::string &arg); + std::string toContactOrganizationTypeStr(ContactOrganizationType arg); + ContactOrganizationType toContactOrganizationType(const JSValueRef &value); + JSValueRef toJSValueRef(ContactOrganizationType arg); + // ContactAddressType ContactAddressType toContactAddressType(const std::string &arg); std::string toContactAddressTypeStr(ContactAddressType arg); diff --git a/src/Contact/ContactEmailAddress.cpp b/src/Contact/ContactEmailAddress.cpp index e968e7d..e92ae17 100755 --- a/src/Contact/ContactEmailAddress.cpp +++ b/src/Contact/ContactEmailAddress.cpp @@ -109,6 +109,9 @@ void ContactEmailAddress::clear() m_email = ""; m_emailIsSet = false; + m_label = ""; + m_labelIsSet = false; + m_isDefault = false; m_types = ContactEmailAddressTypeArrayPtr(new ContactEmailAddressTypeArray()); @@ -123,6 +126,9 @@ ContactEmailAddressPtr ContactEmailAddress::clone() const result->m_isDefault = m_isDefault; + result->m_label = m_label; + result->m_labelIsSet = m_labelIsSet; + result->m_types = ContactEmailAddressTypeArrayPtr(new ContactEmailAddressTypeArray()); ContactEmailAddressTypeArray::iterator typeIter; for(typeIter = m_types->begin(); typeIter != m_types->end(); typeIter++) @@ -131,6 +137,22 @@ ContactEmailAddressPtr ContactEmailAddress::clone() const return result; } +std::string ContactEmailAddress::getLabel() const +{ + return m_label; +} + +void ContactEmailAddress::setLabel(const std::string &value) +{ + m_label = value; + m_labelIsSet = true; +} + +bool ContactEmailAddress::getLabelIsSet() const +{ + return m_labelIsSet; +} + void ContactEmailAddress::setTypesJSArray(bool value, JSObjectRef initValue) { is_typesSetJSArray = value; diff --git a/src/Contact/ContactEmailAddress.h b/src/Contact/ContactEmailAddress.h index ff3855d..f645ee7 100755 --- a/src/Contact/ContactEmailAddress.h +++ b/src/Contact/ContactEmailAddress.h @@ -67,6 +67,10 @@ public: void clear(); ContactEmailAddressPtr clone() const; + std::string getLabel() const; + void setLabel(const std::string &value); + bool getLabelIsSet() const; + void setTypesJSArray(bool value, JSObjectRef initValue); JSValueRef getTypesJSArray(); JSObjectRef getTypesJSObj(); @@ -84,6 +88,9 @@ private: ContactEmailAddressTypeArrayPtr m_types; + std::string m_label; + bool m_labelIsSet; + bool is_typesSetJSArray; JSValueRef m_typesJsValue; JSObjectRef m_typesObj; diff --git a/src/Contact/ContactFilterConverter.cpp b/src/Contact/ContactFilterConverter.cpp old mode 100644 new mode 100755 index 95757e9..1cc2ee9 --- a/src/Contact/ContactFilterConverter.cpp +++ b/src/Contact/ContactFilterConverter.cpp @@ -45,6 +45,7 @@ static PropertyStructArray propertiesContact = { "name.lastName", PrimitiveType_String }, { "name.nicknames", PrimitiveType_String }, { "name.phoneticFirstName", PrimitiveType_String }, + { "name.phoneticMiddleName", PrimitiveType_String }, { "name.phoneticLastName", PrimitiveType_String }, { "name.displayName", PrimitiveType_String }, { "addresses.country", PrimitiveType_String }, @@ -70,6 +71,11 @@ static PropertyStructArray propertiesContact = { "organizations.title", PrimitiveType_String }, { "organizations.role", PrimitiveType_String }, { "organizations.logoURI", PrimitiveType_String }, + { "organizations.assistant", PrimitiveType_String }, + { "organizations.location", PrimitiveType_String }, + { "organizations.description", PrimitiveType_String }, + { "organizations.phoneticName", PrimitiveType_String }, + { "organizations.type", PrimitiveType_String }, { "notes", PrimitiveType_String }, { "urls.url", PrimitiveType_String }, { "urls.type", PrimitiveType_String }, diff --git a/src/Contact/ContactFilterValidator.cpp b/src/Contact/ContactFilterValidator.cpp index 8b1325c..fc1f622 100755 --- a/src/Contact/ContactFilterValidator.cpp +++ b/src/Contact/ContactFilterValidator.cpp @@ -43,6 +43,7 @@ static PropertyStructArray properties = {"name.lastName", PrimitiveType_String}, {"name.nicknames", PrimitiveType_String}, {"name.phoneticFirstName", PrimitiveType_String}, + {"name.phoneticMiddleName", PrimitiveType_String}, {"name.phoneticLastName", PrimitiveType_String}, {"name.displayName", PrimitiveType_String}, {"addresses.country", PrimitiveType_String}, @@ -68,6 +69,11 @@ static PropertyStructArray properties = {"organizations.title", PrimitiveType_String}, {"organizations.role", PrimitiveType_String}, {"organizations.logoURI", PrimitiveType_String}, + {"organizations.assistant", PrimitiveType_String }, + {"organizations.location", PrimitiveType_String }, + {"organizations.description", PrimitiveType_String }, + {"organizations.phoneticName", PrimitiveType_String }, + {"organizations.type", PrimitiveType_String }, {"notes", PrimitiveType_String}, {"urls.url", PrimitiveType_String}, {"urls.type", PrimitiveType_String}, diff --git a/src/Contact/ContactManager.cpp b/src/Contact/ContactManager.cpp index 476b86c..a3f402b 100755 --- a/src/Contact/ContactManager.cpp +++ b/src/Contact/ContactManager.cpp @@ -324,128 +324,84 @@ void ContactManager::managerUpdateBatch(const EventContactManagerUpdateBatchPtr contacts_list_h contacts_list = NULL; PersonArrayPtr persons(NULL); - Try - { - if(!event->getPersonsIsSet()) - ThrowMsg(InvalidArgumentException, "Persons were not set."); + if(!event->getPersonsIsSet()) + ThrowMsg(InvalidArgumentException, "Persons were not set."); - persons = event->getPersons(); - if(!persons) - ThrowMsg(InvalidArgumentException, "No persons."); + persons = event->getPersons(); + if(!persons) + ThrowMsg(InvalidArgumentException, "No persons."); - } - Catch(InvalidArgumentException) - { - ContactQueueManagerSingleton::Instance().decreaseQueueList(); - bool isEmpty = ContactQueueManagerSingleton::Instance().empty(); - if(!isEmpty){ - ContactQueueManagerSingleton::Instance().pop(); - } - LoggerE("Invalid arguments for updating persons : " << _rethrown_exception.GetMessage()); - event->setResult(false); - event->setExceptionCode(ExceptionCodes::InvalidArgumentException); - return; + errorCode = contacts_list_create(&contacts_list); + if(errorCode != CONTACTS_ERROR_NONE){ + if(contacts_list != NULL) + contacts_list_destroy(contacts_list, false); + ThrowMsg(PlatformException, "Fail to create contacts_list_h"); } - Try + for(PersonArray::iterator i = persons->begin(); i != persons->end(); i++) { - errorCode = contacts_list_create(&contacts_list); - if(errorCode != CONTACTS_ERROR_NONE) - { - ThrowMsg(PlatformException, "Fail to create contacts_list_h"); - } + contacts_record_h contacts_record = NULL; + PersonPtr person = *i; - for(PersonArray::iterator i = persons->begin(); i != persons->end(); i++) + Try { - contacts_record_h contacts_record = NULL; - PersonPtr person = *i; - - Try + int personIdInt = ContactUtility::strToInt(person->getId()); + errorCode = contacts_db_get_record(_contacts_person._uri, personIdInt, &contacts_record); + if(errorCode != CONTACTS_ERROR_NONE) { - int personIdInt = ContactUtility::strToInt(person->getId()); - errorCode = contacts_db_get_record(_contacts_person._uri, personIdInt, &contacts_record); - if(errorCode != CONTACTS_ERROR_NONE) - { - ThrowMsg(NotFoundException, "No person"); - } - - ContactsSvcObjectConverter::convertToPlatform(person, contacts_record); - - errorCode = contacts_list_add(contacts_list, contacts_record); - if(errorCode != CONTACTS_ERROR_NONE) - { - ThrowMsg(PlatformException, "Error during add to list"); - } + ThrowMsg(NotFoundException, "No person"); } - Catch(Exception) + + ContactsSvcObjectConverter::convertToPlatform(person, contacts_record); + + errorCode = contacts_list_add(contacts_list, contacts_record); + if(errorCode != CONTACTS_ERROR_NONE) { - ThrowMsg(NotFoundException, "Error during converting contact object"); -// LoggerE("Error during converting person object : " << _rethrown_exception.GetMessage()); -// continue; + ThrowMsg(PlatformException, "Error during add to list"); } } - - KeySharePtrPair *keyPair = new KeySharePtrPair(); - keyPair->key = m_eventMapAcc; - keyPair->contactManager = this; - errorCode = contacts_db_update_records_async(contacts_list, personsUpdateBatchResultCallback, (void*)keyPair); - if(errorCode != CONTACTS_ERROR_NONE) + Catch(NotFoundException) { - delete keyPair; - ThrowMsg(PlatformException, "Error during contacts_db_update_records_async"); + if(contacts_list != NULL) + contacts_list_destroy(contacts_list, false); + ThrowMsg(NotFoundException, "Error during converting contact object"); +// LoggerE("Error during converting person object : " << _rethrown_exception.GetMessage()); +// continue; } - - errorCode = contacts_list_destroy(contacts_list, true); - contacts_list = NULL; - if(errorCode != CONTACTS_ERROR_NONE) + Catch(PlatformException) { - delete keyPair; - ThrowMsg(PlatformException, "Error during contacts_list_destroy"); - } - - pair keyEventPair(m_eventMapAcc, event); - m_updateBatchEventMap.insert(keyEventPair); - - m_eventMapAcc++; - -// event->switchToManualAnswer(); - } - Catch (NotFoundException) - { - ContactQueueManagerSingleton::Instance().decreaseQueueList(); - bool isEmpty = ContactQueueManagerSingleton::Instance().empty(); - if(!isEmpty){ - ContactQueueManagerSingleton::Instance().pop(); + if(contacts_list != NULL) + contacts_list_destroy(contacts_list, false); + ThrowMsg(NotFoundException, "Error during converting contact object"); +// LoggerE("Error during converting person object : " << _rethrown_exception.GetMessage()); +// continue; } - LoggerE("Person doesn't exist : " << _rethrown_exception.GetMessage()); - event->setResult(false); - event->setExceptionCode(ExceptionCodes::NotFoundException); } - Catch (PlatformException) + + KeySharePtrPair *keyPair = new KeySharePtrPair(); + keyPair->key = m_eventMapAcc; + keyPair->contactManager = this; + errorCode = contacts_db_update_records_async(contacts_list, personsUpdateBatchResultCallback, (void*)keyPair); + if(errorCode != CONTACTS_ERROR_NONE) { - ContactQueueManagerSingleton::Instance().decreaseQueueList(); - bool isEmpty = ContactQueueManagerSingleton::Instance().empty(); - if(!isEmpty){ - ContactQueueManagerSingleton::Instance().pop(); - } - LoggerE("Error during updating persons : " << _rethrown_exception.GetMessage()); - event->setResult(false); - event->setExceptionCode(ExceptionCodes::PlatformException); + delete keyPair; + if(contacts_list != NULL) + contacts_list_destroy(contacts_list, false); + ThrowMsg(PlatformException, "Error during contacts_db_update_records_async"); } - Catch (Exception) + + errorCode = contacts_list_destroy(contacts_list, true); + contacts_list = NULL; + if(errorCode != CONTACTS_ERROR_NONE) { - ContactQueueManagerSingleton::Instance().decreaseQueueList(); - bool isEmpty = ContactQueueManagerSingleton::Instance().empty(); - if(!isEmpty){ - ContactQueueManagerSingleton::Instance().pop(); - } - LoggerE("Error during updating persons : " << _rethrown_exception.GetMessage()); - event->setResult(false); - event->setExceptionCode(ExceptionCodes::PlatformException); + delete keyPair; + ThrowMsg(PlatformException, "Error during contacts_list_destroy"); } - if(contacts_list != NULL) - contacts_list_destroy(contacts_list, false); + pair keyEventPair(m_eventMapAcc, event); + m_updateBatchEventMap.insert(keyEventPair); + + m_eventMapAcc++; } void ContactManager::OnRequestReceived(const EventContactManagerUpdateBatchPtr &event) @@ -463,6 +419,24 @@ void ContactManager::OnRequestReceived(const EventContactManagerUpdateBatchPtr & ContactQueueManagerSingleton::Instance().increaseQueueList(); event->switchToManualAnswer(); } + Catch (NotFoundException) + { + LoggerE("NotFoundException during updating persons : " << _rethrown_exception.GetMessage()); + event->setResult(false); + event->setExceptionCode(ExceptionCodes::NotFoundException); + } + Catch (PlatformException) + { + LoggerE("PlatformException during updating persons : " << _rethrown_exception.GetMessage()); + event->setResult(false); + event->setExceptionCode(ExceptionCodes::PlatformException); + } + Catch(InvalidArgumentException) + { + LoggerE("InvalidArgumentException during updating persons : " << _rethrown_exception.GetMessage()); + event->setResult(false); + event->setExceptionCode(ExceptionCodes::InvalidArgumentException); + } Catch (Exception) { LoggerE("Error during updating persons : " << _rethrown_exception.GetMessage()); @@ -536,142 +510,73 @@ void ContactManager::managerRemoveBatch(const EventContactManagerRemoveBatchPtr int errorCode = 0; StringArrayPtr personIds(NULL); - Try - { - if(!event->getPersonIdsIsSet()) - ThrowMsg(InvalidArgumentException, "Person IDs were not set."); + if(!event->getPersonIdsIsSet()) + ThrowMsg(InvalidArgumentException, "Person IDs were not set."); - personIds = event->getPersonIds(); - if(!personIds) - ThrowMsg(InvalidArgumentException, "No person."); + personIds = event->getPersonIds(); + if(!personIds) + ThrowMsg(InvalidArgumentException, "No person."); - } - Catch(InvalidArgumentException) + int *ids = new int[personIds->size()]; + int count = 0; + + if(errorCode != CONTACTS_ERROR_NONE) { - ContactQueueManagerSingleton::Instance().decreaseQueueList(); - bool isEmpty = ContactQueueManagerSingleton::Instance().empty(); - if(!isEmpty){ - ContactQueueManagerSingleton::Instance().pop(); - } - LoggerE("Invalid arguments for removing persons : " << _rethrown_exception.GetMessage()); - event->setResult(false); - event->setExceptionCode(ExceptionCodes::InvalidArgumentException); - return; + ThrowMsg(PlatformException, "Fail to create contacts_list_h"); } - Try + for(StringArray::iterator i = personIds->begin(); i != personIds->end(); i++) { - int *ids = new int[personIds->size()]; - int count = 0; + string personIdStr = *i; - if(errorCode != CONTACTS_ERROR_NONE) + Try { - ThrowMsg(PlatformException, "Fail to create contacts_list_h"); - } + int personId; - for(StringArray::iterator i = personIds->begin(); i != personIds->end(); i++) - { - string personIdStr = *i; + if(!validate("^[0-9]+$", personIdStr, VALIDATE_MATCH_CASELESS)) + ThrowMsg(InvalidArgumentException, "invalid" ); - Try + try { - int personId; - - if(!validate("^[0-9]+$", personIdStr, VALIDATE_MATCH_CASELESS)) - ThrowMsg(InvalidArgumentException, "invalid" ); - - try - { - istringstream iss(personIdStr); - iss >> personId; - } - catch (...) - { - ThrowMsg(InvalidArgumentException, "wrong" ); - } - - ids[count] = personId; - count++; + istringstream iss(personIdStr); + iss >> personId; } - Catch(Exception) + catch (...) { - ThrowMsg(NotFoundException, "Error during converting person object"); -// LoggerE("Error during converting person object : " << _rethrown_exception.GetMessage()); -// continue; + ThrowMsg(InvalidArgumentException, "wrong" ); } - } - KeySharePtrPair *keyPair = new KeySharePtrPair(); - keyPair->key = m_eventMapAcc; - keyPair->contactManager = this; - errorCode = contacts_db_delete_records_async(_contacts_person._uri, ids, count, personsRemoveBatchResultCallback, (void*)keyPair); - - if(ids != NULL) - { - delete [] ids; + ids[count] = personId; + count++; } - - if(errorCode != CONTACTS_ERROR_NONE) + Catch(InvalidArgumentException) { - delete keyPair; - ThrowMsg(PlatformException, "Error during add to list"); + ThrowMsg(InvalidArgumentException, "Error during converting person object"); +// LoggerE("Error during converting person object : " << _rethrown_exception.GetMessage()); +// continue; } + } - pair keyEventPair(m_eventMapAcc, event); - m_removeBatchEventMap.insert(keyEventPair); - - m_eventMapAcc++; + KeySharePtrPair *keyPair = new KeySharePtrPair(); + keyPair->key = m_eventMapAcc; + keyPair->contactManager = this; + errorCode = contacts_db_delete_records_async(_contacts_person._uri, ids, count, personsRemoveBatchResultCallback, (void*)keyPair); -// event->switchToManualAnswer(); - } - Catch (InvalidArgumentException) - { - ContactQueueManagerSingleton::Instance().decreaseQueueList(); - bool isEmpty = ContactQueueManagerSingleton::Instance().empty(); - if(!isEmpty){ - ContactQueueManagerSingleton::Instance().pop(); - } - LoggerE("Invalid person id : " << _rethrown_exception.GetMessage()); - event->setResult(false); - event->setExceptionCode(ExceptionCodes::InvalidArgumentException); - return; - } - Catch (NotFoundException) - { - ContactQueueManagerSingleton::Instance().decreaseQueueList(); - bool isEmpty = ContactQueueManagerSingleton::Instance().empty(); - if(!isEmpty){ - ContactQueueManagerSingleton::Instance().pop(); - } - LoggerE("Person doesn't exist : " << _rethrown_exception.GetMessage()); - event->setResult(false); - event->setExceptionCode(ExceptionCodes::NotFoundException); - return; - } - Catch (PlatformException) + if(ids != NULL) { - ContactQueueManagerSingleton::Instance().decreaseQueueList(); - bool isEmpty = ContactQueueManagerSingleton::Instance().empty(); - if(!isEmpty){ - ContactQueueManagerSingleton::Instance().pop(); - } - LoggerE("Error during removing persons : " << _rethrown_exception.GetMessage()); - event->setResult(false); - event->setExceptionCode(ExceptionCodes::PlatformException); - return; + delete [] ids; } - Catch (Exception) + + if(errorCode != CONTACTS_ERROR_NONE) { - ContactQueueManagerSingleton::Instance().decreaseQueueList(); - bool isEmpty = ContactQueueManagerSingleton::Instance().empty(); - if(!isEmpty){ - ContactQueueManagerSingleton::Instance().pop(); - } - LoggerE("Error during removing persons : " << _rethrown_exception.GetMessage()); - event->setResult(false); - event->setExceptionCode(ExceptionCodes::PlatformException); - return; + delete keyPair; + ThrowMsg(PlatformException, "Error during add to list"); } + + pair keyEventPair(m_eventMapAcc, event); + m_removeBatchEventMap.insert(keyEventPair); + + m_eventMapAcc++; } void ContactManager::OnRequestReceived(const EventContactManagerRemoveBatchPtr &event) @@ -689,9 +594,27 @@ void ContactManager::OnRequestReceived(const EventContactManagerRemoveBatchPtr & ContactQueueManagerSingleton::Instance().increaseQueueList(); event->switchToManualAnswer(); } + Catch (NotFoundException) + { + LoggerE("NotFoundException during deleting persons : " << _rethrown_exception.GetMessage()); + event->setResult(false); + event->setExceptionCode(ExceptionCodes::NotFoundException); + } + Catch (PlatformException) + { + LoggerE("PlatformException during deleting persons : " << _rethrown_exception.GetMessage()); + event->setResult(false); + event->setExceptionCode(ExceptionCodes::PlatformException); + } + Catch(InvalidArgumentException) + { + LoggerE("InvalidArgumentException during deleting persons : " << _rethrown_exception.GetMessage()); + event->setResult(false); + event->setExceptionCode(ExceptionCodes::InvalidArgumentException); + } Catch (Exception) { - LoggerE("Error during deleting contacts : " << _rethrown_exception.GetMessage()); + LoggerE("Error during deleting persons : " << _rethrown_exception.GetMessage()); event->setResult(false); event->setExceptionCode(ExceptionCodes::PlatformException); } diff --git a/src/Contact/ContactName.cpp b/src/Contact/ContactName.cpp index ce6a4b0..a5d9a60 100755 --- a/src/Contact/ContactName.cpp +++ b/src/Contact/ContactName.cpp @@ -34,6 +34,7 @@ ContactName::ContactName() : m_middleNameIsSet(false), m_lastNameIsSet(false), m_phoneticFirstNameIsSet(false), + m_phoneticMiddleNameIsSet(false), m_phoneticLastNameIsSet(false), m_displayNameIsSet(false) { @@ -213,6 +214,28 @@ bool ContactName::getPhoneticFirstNameIsSet() const return m_phoneticFirstNameIsSet; } +std::string ContactName::getPhoneticMiddleName() const +{ + return m_phoneticMiddleName; +} + +void ContactName::setPhoneticMiddleName(const std::string &value) +{ + m_phoneticMiddleName = value; + m_phoneticMiddleNameIsSet = true; +} + +void ContactName::unsetPhoneticMiddleName() +{ + m_phoneticMiddleName = ""; + m_phoneticMiddleNameIsSet = false; +} + +bool ContactName::getPhoneticMiddleNameIsSet() const +{ + return m_phoneticMiddleNameIsSet; +} + std::string ContactName::getPhoneticLastName() const { return m_phoneticLastName; @@ -282,6 +305,9 @@ void ContactName::clear() m_phoneticLastName = ""; m_phoneticLastNameIsSet = false; + m_phoneticMiddleName = ""; + m_phoneticMiddleNameIsSet = false; + m_displayName = ""; m_displayNameIsSet = false; } @@ -316,6 +342,9 @@ ContactNamePtr ContactName::clone() const result->m_phoneticFirstName = m_phoneticFirstName; result->m_phoneticFirstNameIsSet = m_phoneticFirstNameIsSet; + result->m_phoneticMiddleName = m_phoneticMiddleName; + result->m_phoneticMiddleNameIsSet = m_phoneticMiddleNameIsSet; + result->m_phoneticLastName = m_phoneticLastName; result->m_phoneticLastNameIsSet = m_phoneticLastNameIsSet; diff --git a/src/Contact/ContactName.h b/src/Contact/ContactName.h index 650f8fd..f7150b4 100755 --- a/src/Contact/ContactName.h +++ b/src/Contact/ContactName.h @@ -82,6 +82,11 @@ public: void unsetPhoneticFirstName(); bool getPhoneticFirstNameIsSet() const; + std::string getPhoneticMiddleName() const; + void setPhoneticMiddleName(const std::string &value); + void unsetPhoneticMiddleName(); + bool getPhoneticMiddleNameIsSet() const; + std::string getPhoneticLastName() const; void setPhoneticLastName(const std::string &value); void unsetPhoneticLastName(); @@ -125,6 +130,9 @@ private: std::string m_phoneticFirstName; bool m_phoneticFirstNameIsSet; + std::string m_phoneticMiddleName; + bool m_phoneticMiddleNameIsSet; + std::string m_phoneticLastName; bool m_phoneticLastNameIsSet; diff --git a/src/Contact/ContactObjectA2PConverter.cpp b/src/Contact/ContactObjectA2PConverter.cpp index f9e825b..c71d52d 100755 --- a/src/Contact/ContactObjectA2PConverter.cpp +++ b/src/Contact/ContactObjectA2PConverter.cpp @@ -184,7 +184,7 @@ void ContactObjectA2PConverter::importBaseInfoValue() } if(is_first) - contacts_record_add_child_record(m_platformContact, _contacts_contact.image, child_record); + contacts_record_add_child_record(m_platformContact, _contacts_contact.image, child_record); } // Contact.ringtoneURI @@ -225,6 +225,7 @@ void ContactObjectA2PConverter::importNameValue() && ( !contactName->getLastNameIsSet() || contactName->getLastName().empty() ) && ( !contactName->getMiddleNameIsSet() || contactName->getMiddleName().empty() ) && ( !contactName->getPhoneticFirstNameIsSet() || contactName->getPhoneticFirstName().empty() ) + && ( !contactName->getPhoneticMiddleNameIsSet() || contactName->getPhoneticMiddleName().empty() ) && ( !contactName->getPhoneticLastNameIsSet() || contactName->getPhoneticLastName().empty() ) && ( !contactName->getSuffixIsSet() || contactName->getSuffix().empty() ) && ( !contactName->getPrefixIsSet() || contactName->getPrefix().empty() ) ) ) @@ -403,6 +404,30 @@ void ContactObjectA2PConverter::importNameValueToExistingValue(contacts_record_h } } + // ContactName.phoneticMiddleName + newValueStr = NULL; + oldValueStr = NULL; + contacts_record_get_str_p(child_record, _contacts_name.phonetic_middle, &oldValueStr); + abstractValueStr = contactName->getPhoneticMiddleName(); + if(oldValueStr != NULL && (!contactName->getPhoneticMiddleNameIsSet() || abstractValueStr.empty()) ) + { + newValueStr = EMPTY_STRING; + } + else if(oldValueStr == NULL || abstractValueStr != oldValueStr) + { + newValueStr = abstractValueStr.c_str(); + } + + if(newValueStr != NULL) + { + errorCode = contacts_record_set_str(child_record, _contacts_name.phonetic_middle, newValueStr); + if(errorCode != CONTACTS_ERROR_NONE) + { + contacts_record_destroy(child_record, true); + ThrowMsg(PlatformException, "importing phoneticMiddleName E (err:" << errorCode); + } + } + // ContactName.phoneticLastName newValueStr = NULL; oldValueStr = NULL; @@ -522,6 +547,21 @@ void ContactObjectA2PConverter::importNameValueToNewValue(contacts_record_h chil } } + // ContactName.phoneticMiddleName + if(contactName->getPhoneticMiddleNameIsSet()) + { + string phoneticMiddleName = contactName->getPhoneticMiddleName(); + if(phoneticMiddleName != EMPTY_STRING) + { + errorCode = contacts_record_set_str(child_record, _contacts_name.phonetic_middle, phoneticMiddleName.c_str()); + if(errorCode != CONTACTS_ERROR_NONE) + { + contacts_record_destroy(child_record, true); + ThrowMsg(PlatformException, "importing phoneticMiddleName N (err:" << errorCode); + } + } + } + // ContactName.phoneticLastName if(contactName->getPhoneticLastNameIsSet()) { @@ -662,6 +702,106 @@ void ContactObjectA2PConverter::importCompanyList() } } + // ContactOrganization.assistant + if(organization->getAssistantIsSet()) + { + string assistant = organization->getAssistant(); + if(!assistant.empty()) + { + errorCode = contacts_record_set_str(child_record, _contacts_company.assistant_name, assistant.c_str()); + if(errorCode != CONTACTS_ERROR_NONE) + { + LoggerW("importing assistant N (err:" << errorCode); + contacts_record_destroy(child_record, true); + continue; + } + } + } + + // ContactOrganization.location + if(organization->getLocationIsSet()) + { + string location = organization->getLocation(); + if(!location.empty()) + { + errorCode = contacts_record_set_str(child_record, _contacts_company.location, location.c_str()); + if(errorCode != CONTACTS_ERROR_NONE) + { + LoggerW("importing location N (err:" << errorCode); + contacts_record_destroy(child_record, true); + continue; + } + } + } + + // ContactOrganization.description + if(organization->getDescriptionIsSet()) + { + string description = organization->getDescription(); + if(!description.empty()) + { + errorCode = contacts_record_set_str(child_record, _contacts_company.description, description.c_str()); + if(errorCode != CONTACTS_ERROR_NONE) + { + LoggerW("importing description N (err:" << errorCode); + contacts_record_destroy(child_record, true); + continue; + } + } + } + + // ContactOrganization.phoneticName + if(organization->getPhoneticNameIsSet()) + { + string phoneticName = organization->getPhoneticName(); + if(!phoneticName.empty()) + { + errorCode = contacts_record_set_str(child_record, _contacts_company.phonetic_name, phoneticName.c_str()); + if(errorCode != CONTACTS_ERROR_NONE) + { + LoggerW("importing phoneticName N (err:" << errorCode); + contacts_record_destroy(child_record, true); + continue; + } + } + } + + int ctsIntType = 0; + // ContactOrganization.label + if(organization->getLabelIsSet()) + { + string label = organization->getLabel(); + if(!label.empty()) + { + ctsIntType = ctsIntType | CONTACTS_COMPANY_TYPE_CUSTOM; + errorCode = contacts_record_set_str(child_record, _contacts_company.label, label.c_str()); + if(errorCode != CONTACTS_ERROR_NONE) + { + LoggerW("importing label N (err:" << errorCode); + contacts_record_destroy(child_record, true); + continue; + } + } + } + + // ContactOrganization.type + ContactOrganizationType type = organization->getType(); + + if(type == ORGANIZATION_TYPE_WORK) + ctsIntType = CONTACTS_COMPANY_TYPE_WORK; + else if(type == ORGANIZATION_TYPE_OTHER) + ctsIntType = CONTACTS_COMPANY_TYPE_OTHER; + else + ctsIntType = CONTACTS_COMPANY_TYPE_WORK; + + errorCode = contacts_record_set_int(child_record, _contacts_company.type, ctsIntType); + if(errorCode != CONTACTS_ERROR_NONE) + { + LoggerW("importing type N (err:" << errorCode); + contacts_record_destroy(child_record, true); + continue; + } + errorCode = contacts_record_add_child_record(m_platformContact, _contacts_contact.company, child_record); if(errorCode != CONTACTS_ERROR_NONE) { @@ -816,6 +956,8 @@ void ContactObjectA2PConverter::importNumberList() ctsIntType = ctsIntType | CONTACTS_NUMBER_TYPE_VIDEO; else if(type == CONTACT_PHONE_NUMBER_TYPE_PCS) ctsIntType = ctsIntType | CONTACTS_NUMBER_TYPE_PCS; + else if(type == CONTACT_PHONE_NUMBER_TYPE_ASSISTANT) + ctsIntType = ctsIntType | CONTACTS_NUMBER_TYPE_ASSISTANT; else ctsIntType = ctsIntType | CONTACTS_NUMBER_TYPE_VOICE; } @@ -845,6 +987,23 @@ void ContactObjectA2PConverter::importNumberList() continue; } + if(phoneNumber->getLabelIsSet()) + { + string label = phoneNumber->getLabel(); + + if(!label.empty()) + { + ctsIntType = ctsIntType | CONTACTS_NUMBER_TYPE_CUSTOM; + errorCode = contacts_record_set_str(child_record, _contacts_number.label, label.c_str()); + if(errorCode != CONTACTS_ERROR_NONE) + { + LoggerW("Fail to set number value to child_record custom type "); + contacts_record_destroy(child_record, true); + continue; + } + } + } + errorCode = contacts_record_set_int(child_record, _contacts_number.type, ctsIntType); if(errorCode != CONTACTS_ERROR_NONE) { @@ -853,17 +1012,6 @@ void ContactObjectA2PConverter::importNumberList() continue; } - //if(ctsStrCustomType != NULL) - //{ - // errorCode = contacts_record_set_str(child_record, _contacts_number.label, ctsStrCustomType); - // if(errorCode != CONTACTS_ERROR_NONE) - // { - // LoggerW("Fail to set number value to child_record custom type : " << ctsStrCustomType); - // contacts_record_destroy(child_record, true); - // continue; - // } - //} - errorCode = contacts_record_add_child_record(m_platformContact, _contacts_contact.number, child_record); if(errorCode != CONTACTS_ERROR_NONE) { @@ -930,6 +1078,8 @@ void ContactObjectA2PConverter::importEmailList() ctsIntType = ctsIntType | CONTACTS_EMAIL_TYPE_HOME; else if(type == CONTACT_EMAIL_TYPE_WORK) ctsIntType = ctsIntType | CONTACTS_EMAIL_TYPE_WORK; + else if(type == CONTACT_EMAIL_TYPE_MOBILE) + ctsIntType = ctsIntType | CONTACTS_EMAIL_TYPE_MOBILE; else ctsIntType = ctsIntType | CONTACTS_EMAIL_TYPE_HOME; } @@ -959,6 +1109,22 @@ void ContactObjectA2PConverter::importEmailList() continue; } + if(email->getLabelIsSet()) + { + string label = email->getLabel(); + if(!label.empty()) + { + ctsIntType = ctsIntType | CONTACTS_EMAIL_TYPE_CUSTOM; + errorCode = contacts_record_set_str(child_record, _contacts_email.label, label.c_str()); + if(errorCode != CONTACTS_ERROR_NONE) + { + LoggerW("Fail to set email value to child_record custom type"); + contacts_record_destroy(child_record, true); + continue; + } + } + } + errorCode = contacts_record_set_int(child_record, _contacts_email.type, ctsIntType); if(errorCode != CONTACTS_ERROR_NONE) { @@ -967,17 +1133,6 @@ void ContactObjectA2PConverter::importEmailList() continue; } - //if(ctsStrCustomType != NULL) - //{ - // errorCode = contacts_record_set_str(child_record, _contacts_email.label, ctsStrCustomType); - // if(errorCode != CONTACTS_ERROR_NONE) - // { - // LoggerW("Fail to set email value to child_record custom type : " << ctsStrCustomType); - // contacts_record_destroy(child_record, true); - // continue; - // } - //} - errorCode = contacts_record_add_child_record(m_platformContact, _contacts_contact.email, child_record); if(errorCode != CONTACTS_ERROR_NONE) { @@ -1267,7 +1422,6 @@ void ContactObjectA2PConverter::importPostalList() bool ctsBoolDefault = address->getIsDefault(); int ctsIntType = 0; - //char *ctsStrCustomType = NULL; ContactAddressTypeArray::iterator typesIter = types->begin(); for(; typesIter != types->end(); typesIter++) @@ -1277,6 +1431,14 @@ void ContactObjectA2PConverter::importPostalList() ctsIntType = ctsIntType | CONTACTS_ADDRESS_TYPE_HOME; else if(type == CONTACT_ADDRESS_TYPE_WORK) ctsIntType = ctsIntType | CONTACTS_ADDRESS_TYPE_WORK; + else if(type == CONTACT_ADDRESS_TYPE_DOM) + ctsIntType = ctsIntType | CONTACTS_ADDRESS_TYPE_DOM; + else if(type == CONTACT_ADDRESS_TYPE_INTL) + ctsIntType = ctsIntType | CONTACTS_ADDRESS_TYPE_INTL; + else if(type == CONTACT_ADDRESS_TYPE_POSTAL) + ctsIntType = ctsIntType | CONTACTS_ADDRESS_TYPE_POSTAL; + else if(type == CONTACT_ADDRESS_TYPE_PARCEL) + ctsIntType = ctsIntType | CONTACTS_ADDRESS_TYPE_PARCEL; else ctsIntType = ctsIntType | CONTACTS_ADDRESS_TYPE_HOME; } @@ -1370,6 +1532,22 @@ void ContactObjectA2PConverter::importPostalList() continue; } + if(address->getLabelIsSet()) + { + string label = address->getLabel(); + if(!label.empty()) + { + ctsIntType = ctsIntType | CONTACTS_ADDRESS_TYPE_CUSTOM; + errorCode = contacts_record_set_str(child_record, _contacts_address.label, label.c_str()); + if(errorCode != CONTACTS_ERROR_NONE) + { + LoggerW("Fail to set custom value to child_record type"); + contacts_record_destroy(child_record, true); + continue; + } + } + } + errorCode = contacts_record_set_int(child_record, _contacts_address.type, ctsIntType); if(errorCode != CONTACTS_ERROR_NONE) { @@ -1378,17 +1556,6 @@ void ContactObjectA2PConverter::importPostalList() continue; } - //if(ctsStrCustomType != NULL) - //{ - // errorCode = contacts_record_set_str(child_record, _contacts_address.label, ctsStrCustomType); - // if(errorCode != CONTACTS_ERROR_NONE) - // { - // LoggerW("Fail to set custom value to child_record type : " << ctsStrCustomType); - // contacts_record_destroy(child_record, true); - // continue; - // } - //} - errorCode = contacts_record_add_child_record(m_platformContact, _contacts_contact.address, child_record); if(errorCode != CONTACTS_ERROR_NONE) { @@ -1443,7 +1610,6 @@ void ContactObjectA2PConverter::importWebAddrList() string url = webSite->getUrl(); int ctsIntType = 0; -// char *ctsStrCustomType = NULL; if(type == WEBSITE_TYPE_HOMEPAGE) ctsIntType = CONTACTS_URL_TYPE_HOME; @@ -1476,18 +1642,22 @@ void ContactObjectA2PConverter::importWebAddrList() contacts_record_destroy(child_record, true); continue; } -/* - if(ctsStrCustomType != NULL) + + if(webSite->getLabelIsSet()) { - errorCode = contacts_record_set_str(child_record, _contacts_url.label, ctsStrCustomType); - if(errorCode != CONTACTS_ERROR_NONE) + string label = webSite->getLabel(); + if(!label.empty()) { - LoggerW("Fail to set custom value to child_record type : " << ctsStrCustomType); - contacts_record_destroy(child_record, true); - continue; + errorCode = contacts_record_set_str(child_record, _contacts_url.label, label.c_str()); + if(errorCode != CONTACTS_ERROR_NONE) + { + LoggerW("Fail to set custom value to child_record type : " << label); + contacts_record_destroy(child_record, true); + continue; + } } } -*/ + errorCode = contacts_record_add_child_record(m_platformContact, _contacts_contact.url, child_record); if(errorCode != CONTACTS_ERROR_NONE) { diff --git a/src/Contact/ContactObjectP2AConverter.cpp b/src/Contact/ContactObjectP2AConverter.cpp old mode 100644 new mode 100755 index c587be3..671b2ff --- a/src/Contact/ContactObjectP2AConverter.cpp +++ b/src/Contact/ContactObjectP2AConverter.cpp @@ -31,6 +31,7 @@ #include "Contact.h" #include "ContactUtility.h" #include +#include namespace DeviceAPI { namespace Contact { @@ -212,6 +213,9 @@ void ContactObjectP2AConverter::exportNameValue() if(contactName->getPhoneticFirstNameIsSet()) contactName->unsetPhoneticFirstName(); + if(contactName->getPhoneticMiddleNameIsSet()) + contactName->unsetPhoneticMiddleName(); + if(contactName->getPhoneticLastNameIsSet()) contactName->unsetPhoneticLastName(); } @@ -281,6 +285,15 @@ void ContactObjectP2AConverter::exportNameValue() contactName->unsetPhoneticFirstName(); } + contacts_record_get_str_p(child_record, _contacts_name.phonetic_middle, &charValue); + if (charValue) + contactName->setPhoneticMiddleName(charValue); + else + { + if(contactName->getPhoneticMiddleNameIsSet()) + contactName->unsetPhoneticMiddleName(); + } + contacts_record_get_str_p(child_record, _contacts_name.phonetic_last, &charValue); if (charValue) contactName->setPhoneticLastName(charValue); @@ -321,9 +334,8 @@ void ContactObjectP2AConverter::exportCompanyList() ContactOrganizationPtr organization(new ContactOrganization()); - organizations->push_back(organization); - char *charValue = NULL; + int intValue = 0; contacts_record_get_str_p(child_record, _contacts_company.name, &charValue); if (charValue) @@ -369,6 +381,62 @@ void ContactObjectP2AConverter::exportCompanyList() if(organization->getLogoURIIsSet()) organization->unsetLogoURI(); } + + contacts_record_get_str_p(child_record, _contacts_company.assistant_name, &charValue); + if (charValue) + organization->setAssistant(charValue); + else + { + if(organization->getAssistantIsSet()) + organization->unsetAssistant(); + } + + contacts_record_get_str_p(child_record, _contacts_company.location, &charValue); + if (charValue) + organization->setLocation(charValue); + else + { + if(organization->getLocationIsSet()) + organization->unsetLocation(); + } + + contacts_record_get_str_p(child_record, _contacts_company.description, &charValue); + if (charValue) + organization->setDescription(charValue); + else + { + if(organization->getDescriptionIsSet()) + organization->unsetDescription(); + } + + contacts_record_get_str_p(child_record, _contacts_company.phonetic_name, &charValue); + if (charValue) + organization->setPhoneticName(charValue); + else + { + if(organization->getPhoneticNameIsSet()) + organization->unsetPhoneticName(); + } + + contacts_record_get_int(child_record, _contacts_company.type, &intValue); + if(intValue == CONTACTS_COMPANY_TYPE_OTHER) + organization->setType(ORGANIZATION_TYPE_OTHER); + if(intValue == CONTACTS_COMPANY_TYPE_WORK) + organization->setType(ORGANIZATION_TYPE_WORK); + + if(organization->getTypeIsSet() == false) + organization->setType(ORGANIZATION_TYPE_WORK); + + contacts_record_get_str_p(child_record, _contacts_company.label, &charValue); + if (charValue) + organization->setLabel(charValue); + else + { + if(organization->getLabelIsSet()) + organization->unsetLabel(); + } + organizations->push_back(organization); + } } @@ -416,6 +484,9 @@ void ContactObjectP2AConverter::exportNumberList() if(m_abstractContact->getPhoneNumbersNum() > 0) m_abstractContact->clearPhoneNumbers(); + DPL::SharedPtr newContactT = DPL::StaticPointerCast(m_abstractContact); + newContactT->resetNumbersJSObj(); + errorCode = contacts_record_get_child_record_count(m_platformContact, _contacts_contact.number, &child_count); if(errorCode != CONTACTS_ERROR_NONE && errorCode != CONTACTS_ERROR_NO_DATA) ThrowMsg(UnknownException, "getting number list (err:" << errorCode << ")"); @@ -446,7 +517,6 @@ void ContactObjectP2AConverter::exportNumberList() if (charValue) { phoneNumber->setNumber(charValue); - phoneNumbers->push_back(phoneNumber); } else { @@ -484,17 +554,17 @@ void ContactObjectP2AConverter::exportNumberList() phoneNumber->addType(CONTACT_PHONE_NUMBER_TYPE_VIDEO); if(intValue & CONTACTS_NUMBER_TYPE_PCS) phoneNumber->addType(CONTACT_PHONE_NUMBER_TYPE_PCS); + if(intValue & CONTACTS_NUMBER_TYPE_ASSISTANT) + phoneNumber->addType(CONTACT_PHONE_NUMBER_TYPE_ASSISTANT); if(phoneNumber->getTypes()->size() == 0) phoneNumber->addType(CONTACT_PHONE_NUMBER_TYPE_VOICE); - // TODO Will be added after type changed to string -// if(intValue & CONTACTS_NUMBER_TYPE_CUSTOM) -// { -// contacts_record_get_str_p(child_record, _contacts_number.label, &charValue); -// if (charValue) -// phoneNumber->addType(CUSTOM); -// } + contacts_record_get_str_p(child_record, _contacts_number.label, &charValue); + if (charValue) + phoneNumber->setLabel(charValue); + + phoneNumbers->push_back(phoneNumber); } } @@ -506,6 +576,9 @@ void ContactObjectP2AConverter::exportEmailList() if(m_abstractContact->getEmailsNum() > 0) m_abstractContact->clearEmails(); + DPL::SharedPtr newContactT = DPL::StaticPointerCast(m_abstractContact); + newContactT->resetEmailsJSObj(); + errorCode = contacts_record_get_child_record_count(m_platformContact, _contacts_contact.email, &child_count); if(errorCode != CONTACTS_ERROR_NONE && errorCode != CONTACTS_ERROR_NO_DATA) ThrowMsg(UnknownException, "getting email list (err:" << errorCode << ")"); @@ -536,7 +609,6 @@ void ContactObjectP2AConverter::exportEmailList() if (charValue) { email->setEmail(charValue); - emails->push_back(email); } else { @@ -548,21 +620,24 @@ void ContactObjectP2AConverter::exportEmailList() email->setIsDefault(boolValue); contacts_record_get_int(child_record, _contacts_email.type, &intValue); + if(intValue & CONTACTS_EMAIL_TYPE_HOME) email->addType(CONTACT_EMAIL_TYPE_HOME); + if(intValue & CONTACTS_EMAIL_TYPE_WORK) email->addType(CONTACT_EMAIL_TYPE_WORK); + if(intValue & CONTACTS_EMAIL_TYPE_MOBILE) + email->addType(CONTACT_EMAIL_TYPE_MOBILE); + if(email->getTypes()->size() == 0) email->addType(CONTACT_EMAIL_TYPE_HOME); - // TODO Will be added after type changed to string -// if(intValue & CONTACTS_EMAIL_TYPE_CUSTOM) -// { -// contacts_record_get_str_p(child_record, _contacts_email.label, &charValue); -// if (charValue) -// email->addType(CUSTOM); -// } + contacts_record_get_str_p(child_record, _contacts_email.label, &charValue); + if (charValue) + email->setLabel(charValue); + + emails->push_back(email); } } @@ -683,6 +758,9 @@ void ContactObjectP2AConverter::exportPostalList() if(m_abstractContact->getAddressesNum() > 0) m_abstractContact->clearAddresses(); + DPL::SharedPtr newContactT = DPL::StaticPointerCast(m_abstractContact); + newContactT->resetAddressesJSObj(); + errorCode = contacts_record_get_child_record_count(m_platformContact, _contacts_contact.address, &child_count); if(errorCode != CONTACTS_ERROR_NONE && errorCode != CONTACTS_ERROR_NO_DATA) ThrowMsg(UnknownException, "getting address list (err:" << errorCode << ")"); @@ -693,7 +771,7 @@ void ContactObjectP2AConverter::exportPostalList() return; } - ContactAddressArrayPtr addresss = m_abstractContact->getAddresses(); + ContactAddressArrayPtr addresses = m_abstractContact->getAddresses(); for(unsigned int i=0; ipush_back(address); - contacts_record_get_str_p(child_record, _contacts_address.postal_code, &charValue); if (charValue) address->setPostalCode(charValue); @@ -743,17 +819,23 @@ void ContactObjectP2AConverter::exportPostalList() address->addType(CONTACT_ADDRESS_TYPE_HOME); if(intValue & CONTACTS_ADDRESS_TYPE_WORK) address->addType(CONTACT_ADDRESS_TYPE_WORK); + if(intValue & CONTACTS_ADDRESS_TYPE_DOM) + address->addType(CONTACT_ADDRESS_TYPE_DOM); + if(intValue & CONTACTS_ADDRESS_TYPE_INTL) + address->addType(CONTACT_ADDRESS_TYPE_INTL); + if(intValue & CONTACTS_ADDRESS_TYPE_POSTAL) + address->addType(CONTACT_ADDRESS_TYPE_POSTAL); + if(intValue & CONTACTS_ADDRESS_TYPE_PARCEL) + address->addType(CONTACT_ADDRESS_TYPE_PARCEL); if(address->getTypes()->size() == 0) address->addType(CONTACT_ADDRESS_TYPE_HOME); - // TODO Will be added after type changed to string -// if(intValue & CONTACTS_ADDRESS_TYPE_CUSTOM) -// { -// contacts_record_get_str_p(child_record, _contacts_address.label, &charValue); -// if (charValue) -// address->addType(CUSTOM); -// } + contacts_record_get_str_p(child_record, _contacts_address.label, &charValue); + if (charValue) + address->setLabel(charValue); + + addresses->push_back(address); } } @@ -790,8 +872,6 @@ void ContactObjectP2AConverter::exportWebAddrList() char *charValue = NULL; int intValue = 0; - urls->push_back(url); - contacts_record_get_str_p(child_record, _contacts_url.url, &charValue); if (charValue) url->setUrl(charValue); @@ -805,13 +885,11 @@ void ContactObjectP2AConverter::exportWebAddrList() if(url->getTypeIsSet() == false) url->setType(WEBSITE_TYPE_HOMEPAGE); - // TODO Will be added after type changed to string -// if(intValue & CONTACTS_URL_TYPE_CUSTOM) -// { -// contacts_record_get_int(child_record, _contacts_url.label, &intValue); -// if (charValue) -// url->setType(CUSTOM); -// } + contacts_record_get_str_p(child_record, _contacts_url.label, &charValue); + if (charValue) + url->setLabel(charValue); + + urls->push_back(url); } } diff --git a/src/Contact/ContactOrganization.cpp b/src/Contact/ContactOrganization.cpp index 597b1b9..3fb4463 100755 --- a/src/Contact/ContactOrganization.cpp +++ b/src/Contact/ContactOrganization.cpp @@ -166,6 +166,25 @@ void ContactOrganization::clear() m_logoURI = ""; m_logoURIIsSet = false; + + m_assistant = ""; + m_assistantIsSet = false; + + m_location = ""; + m_locationIsSet = false; + + m_description = ""; + m_descriptionIsSet = false; + + m_phoneticName = ""; + m_phoneticNameIsSet = false; + + m_type = ORGANIZATION_TYPE_WORK; + m_typeIsSet = false; + + m_label = ""; + m_labelIsSet = false; + } ContactOrganizationPtr ContactOrganization::clone() const @@ -187,8 +206,159 @@ ContactOrganizationPtr ContactOrganization::clone() const result->m_logoURI = m_logoURI; result->m_logoURIIsSet = m_logoURIIsSet; + result->m_assistant = m_assistant; + result->m_assistantIsSet = m_assistantIsSet; + + result->m_location = m_location; + result->m_locationIsSet = m_locationIsSet; + + result->m_description = m_description; + result->m_descriptionIsSet = m_descriptionIsSet; + + result->m_phoneticName = m_phoneticName; + result->m_phoneticNameIsSet = m_phoneticNameIsSet; + + result->m_type = m_type; + result->m_typeIsSet = m_typeIsSet; + + + result->m_label = m_label; + result->m_labelIsSet = m_labelIsSet; + return result; } +std::string ContactOrganization::getAssistant() const +{ + return m_assistant; +} + +void ContactOrganization::setAssistant(const std::string &value) +{ + m_assistant = value; + m_assistantIsSet = true; +} + +void ContactOrganization::unsetAssistant() +{ + m_assistant = ""; + m_assistantIsSet = false; +} + +bool ContactOrganization::getAssistantIsSet() const +{ + return m_assistantIsSet; +} + +std::string ContactOrganization::getLocation() const +{ + return m_location; +} + +void ContactOrganization::setLocation(const std::string &value) +{ + m_location = value; + m_locationIsSet = true; +} + +void ContactOrganization::unsetLocation() +{ + m_location = ""; + m_locationIsSet = false; +} + +bool ContactOrganization::getLocationIsSet() const +{ + return m_locationIsSet; +} + +std::string ContactOrganization::getDescription() const +{ + return m_description; +} + +void ContactOrganization::setDescription(const std::string &value) +{ + m_description = value; + m_descriptionIsSet = true; +} + +void ContactOrganization::unsetDescription() +{ + m_description = ""; + m_descriptionIsSet = false; +} + +bool ContactOrganization::getDescriptionIsSet() const +{ + return m_descriptionIsSet; +} + +std::string ContactOrganization::getPhoneticName() const +{ + return m_phoneticName; +} + +void ContactOrganization::setPhoneticName(const std::string &value) +{ + m_phoneticName = value; + m_phoneticNameIsSet = true; +} + +void ContactOrganization::unsetPhoneticName() +{ + m_phoneticName = ""; + m_phoneticNameIsSet = false; +} + +bool ContactOrganization::getPhoneticNameIsSet() const +{ + return m_phoneticNameIsSet; +} + +ContactOrganizationType ContactOrganization::getType() const +{ + return m_type; +} + +void ContactOrganization::setType(ContactOrganizationType value) +{ + m_type = value; + m_typeIsSet = true; +} + +void ContactOrganization::unsetType() +{ + m_type = ORGANIZATION_TYPE_WORK; + m_typeIsSet = false; +} + +bool ContactOrganization::getTypeIsSet() const +{ + return m_typeIsSet; +} + +std::string ContactOrganization::getLabel() const +{ + return m_label; +} + +void ContactOrganization::setLabel(const std::string &value) +{ + m_label = value; + m_labelIsSet = true; +} + +void ContactOrganization::unsetLabel() +{ + m_label = ""; + m_labelIsSet = false; +} + +bool ContactOrganization::getLabelIsSet() const +{ + return m_labelIsSet; +} + } // Contact } // DeviceAPI diff --git a/src/Contact/ContactOrganization.h b/src/Contact/ContactOrganization.h index 5f012bf..aba0363 100755 --- a/src/Contact/ContactOrganization.h +++ b/src/Contact/ContactOrganization.h @@ -28,6 +28,7 @@ #include #include #include +#include "ContactTypes.h" namespace DeviceAPI { namespace Contact { @@ -69,6 +70,36 @@ public: void unsetLogoURI(); bool getLogoURIIsSet() const; + std::string getAssistant() const; + void setAssistant(const std::string &value); + void unsetAssistant(); + bool getAssistantIsSet() const; + + std::string getLocation() const; + void setLocation(const std::string &value); + void unsetLocation(); + bool getLocationIsSet() const; + + std::string getDescription() const; + void setDescription(const std::string &value); + void unsetDescription(); + bool getDescriptionIsSet() const; + + std::string getPhoneticName() const; + void setPhoneticName(const std::string &value); + void unsetPhoneticName(); + bool getPhoneticNameIsSet() const; + + ContactOrganizationType getType() const; + void setType(ContactOrganizationType value); + void unsetType(); + bool getTypeIsSet() const; + + std::string getLabel() const; + void setLabel(const std::string &value); + void unsetLabel(); + bool getLabelIsSet() const; + void clear(); ContactOrganizationPtr clone() const; @@ -87,6 +118,25 @@ private: std::string m_logoURI; bool m_logoURIIsSet; + + std::string m_assistant; + bool m_assistantIsSet; + + std::string m_location; + bool m_locationIsSet; + + std::string m_description; + bool m_descriptionIsSet; + + std::string m_phoneticName; + bool m_phoneticNameIsSet; + + ContactOrganizationType m_type; + bool m_typeIsSet; + + std::string m_label; + bool m_labelIsSet; + }; } // Contact diff --git a/src/Contact/ContactPhoneNumber.cpp b/src/Contact/ContactPhoneNumber.cpp index 6ba79c2..6605a74 100755 --- a/src/Contact/ContactPhoneNumber.cpp +++ b/src/Contact/ContactPhoneNumber.cpp @@ -111,6 +111,9 @@ void ContactPhoneNumber::clear() m_number = ""; m_numberIsSet = false; + m_label = ""; + m_labelIsSet = false; + m_isDefault = false; m_types = ContactPhoneNumberTypeArrayPtr(new ContactPhoneNumberTypeArray()); @@ -125,6 +128,9 @@ ContactPhoneNumberPtr ContactPhoneNumber::clone() const result->m_isDefault = m_isDefault; + result->m_label = m_label; + result->m_labelIsSet = m_labelIsSet; + result->m_types = ContactPhoneNumberTypeArrayPtr(new ContactPhoneNumberTypeArray()); ContactPhoneNumberTypeArray::iterator typeIter; for(typeIter = m_types->begin(); typeIter != m_types->end(); typeIter++) @@ -136,6 +142,22 @@ ContactPhoneNumberPtr ContactPhoneNumber::clone() const return result; } +std::string ContactPhoneNumber::getLabel() const +{ + return m_label; +} + +void ContactPhoneNumber::setLabel(const std::string &value) +{ + m_label = value; + m_labelIsSet = true; +} + +bool ContactPhoneNumber::getLabelIsSet() const +{ + return m_labelIsSet; +} + void ContactPhoneNumber::setTypesJSArray(bool value, JSObjectRef initValue) { is_typesSetJSArray = value; diff --git a/src/Contact/ContactPhoneNumber.h b/src/Contact/ContactPhoneNumber.h index 34e44da..90003db 100755 --- a/src/Contact/ContactPhoneNumber.h +++ b/src/Contact/ContactPhoneNumber.h @@ -65,6 +65,10 @@ public: bool isTypeOf(const ContactPhoneNumberType value) const; int getTypesNum() const; + std::string getLabel() const; + void setLabel(const std::string &value); + bool getLabelIsSet() const; + void clear(); ContactPhoneNumberPtr clone() const; @@ -85,6 +89,9 @@ private: ContactPhoneNumberTypeArrayPtr m_types; + std::string m_label; + bool m_labelIsSet; + bool is_typesSetJSArray; JSValueRef m_typesJsValue; JSObjectRef m_typesObj; diff --git a/src/Contact/ContactSearchEngine.cpp b/src/Contact/ContactSearchEngine.cpp index 37a3aed..73d520a 100755 --- a/src/Contact/ContactSearchEngine.cpp +++ b/src/Contact/ContactSearchEngine.cpp @@ -92,6 +92,7 @@ ContactSearchEngine::AttributePropertiesMap ContactSearchEngine::attributeProper {"name.lastName", { _contacts_name._uri, _contacts_name.contact_id, _contacts_name.last, ContactSearchEngine::ContactSvcPrimitiveType_String, PrimitiveType_String } }, {"name.nicknames", { _contacts_nickname._uri, _contacts_nickname.contact_id, _contacts_nickname.name, ContactSearchEngine::ContactSvcPrimitiveType_String, PrimitiveType_String } }, {"name.phoneticFirstName", { _contacts_name._uri, _contacts_name.contact_id, _contacts_name.phonetic_first, ContactSearchEngine::ContactSvcPrimitiveType_String, PrimitiveType_String } }, + {"name.phoneticMiddleName", { _contacts_name._uri, _contacts_name.contact_id, _contacts_name.phonetic_middle, ContactSearchEngine::ContactSvcPrimitiveType_String, PrimitiveType_String } }, {"name.phoneticLastName", { _contacts_name._uri, _contacts_name.contact_id, _contacts_name.phonetic_last, ContactSearchEngine::ContactSvcPrimitiveType_String, PrimitiveType_String } }, {"name.displayName", { _contacts_simple_contact._uri, _contacts_simple_contact.id, _contacts_simple_contact.display_name, ContactSearchEngine::ContactSvcPrimitiveType_String, PrimitiveType_String } }, {"addresses.country", { _contacts_address._uri, _contacts_address.contact_id, _contacts_address.country, ContactSearchEngine::ContactSvcPrimitiveType_String, PrimitiveType_String } }, @@ -110,13 +111,18 @@ ContactSearchEngine::AttributePropertiesMap ContactSearchEngine::attributeProper {"emails.isDefault", { _contacts_email._uri, _contacts_email.contact_id, _contacts_email.is_default, ContactSearchEngine::ContactSvcPrimitiveType_Boolean, PrimitiveType_Boolean } }, {"emails.types", { _contacts_email._uri, _contacts_email.contact_id, _contacts_email.type, ContactSearchEngine::ContactSvcPrimitiveType_Int, PrimitiveType_Long } }, {"birthday", { _contacts_event._uri, _contacts_event.contact_id, _contacts_event.date, ContactSearchEngine::ContactSvcPrimitiveType_Int, PrimitiveType_Long } }, - {"anniversaries.date", { _contacts_event._uri, _contacts_event.contact_id, _contacts_event.date, ContactSearchEngine::ContactSvcPrimitiveType_String, PrimitiveType_String } }, + {"anniversaries.date", { _contacts_event._uri, _contacts_event.contact_id, _contacts_event.date, ContactSearchEngine::ContactSvcPrimitiveType_Int, PrimitiveType_Long } }, {"anniversaries.label", { _contacts_event._uri, _contacts_event.contact_id, _contacts_event.label, ContactSearchEngine::ContactSvcPrimitiveType_String, PrimitiveType_String } }, {"organizations.name", { _contacts_company._uri, _contacts_company.contact_id, _contacts_company.name, ContactSearchEngine::ContactSvcPrimitiveType_String, PrimitiveType_String } }, {"organizations.department",{ _contacts_company._uri, _contacts_company.contact_id, _contacts_company.department, ContactSearchEngine::ContactSvcPrimitiveType_String, PrimitiveType_String } }, {"organizations.title", { _contacts_company._uri, _contacts_company.contact_id, _contacts_company.job_title, ContactSearchEngine::ContactSvcPrimitiveType_String, PrimitiveType_String } }, {"organizations.role", { _contacts_company._uri, _contacts_company.contact_id, _contacts_company.role, ContactSearchEngine::ContactSvcPrimitiveType_String, PrimitiveType_String } }, {"organizations.logoURI", { _contacts_company._uri, _contacts_company.contact_id, _contacts_company.logo, ContactSearchEngine::ContactSvcPrimitiveType_String, PrimitiveType_String } }, + {"organizations.assistant", { _contacts_company._uri, _contacts_company.contact_id, _contacts_company.assistant_name, ContactSearchEngine::ContactSvcPrimitiveType_String, PrimitiveType_String } }, + {"organizations.location", { _contacts_company._uri, _contacts_company.contact_id, _contacts_company.location, ContactSearchEngine::ContactSvcPrimitiveType_String, PrimitiveType_String } }, + {"organizations.description", { _contacts_company._uri, _contacts_company.contact_id, _contacts_company.description, ContactSearchEngine::ContactSvcPrimitiveType_String, PrimitiveType_String } }, + {"organizations.phoneticName", { _contacts_company._uri, _contacts_company.contact_id, _contacts_company.phonetic_name, ContactSearchEngine::ContactSvcPrimitiveType_String, PrimitiveType_String } }, + {"organizations.type", { _contacts_company._uri, _contacts_company.contact_id, _contacts_company.type, ContactSearchEngine::ContactSvcPrimitiveType_String, PrimitiveType_Long } }, {"notes", { _contacts_note._uri, _contacts_note.contact_id, _contacts_note.note, ContactSearchEngine::ContactSvcPrimitiveType_String, PrimitiveType_String } }, {"urls.url", { _contacts_url._uri, _contacts_url.contact_id, _contacts_url.url, ContactSearchEngine::ContactSvcPrimitiveType_String, PrimitiveType_String } }, {"urls.type", { _contacts_url._uri, _contacts_url.contact_id, _contacts_url.type, ContactSearchEngine::ContactSvcPrimitiveType_Int, PrimitiveType_Long } }, @@ -209,7 +215,7 @@ ContactArrayPtr ContactSearchEngine::getContactSearchResult() LoggerD("length : " << length); if(length != 0) { - result = getContacts(m_filteredContactIds); + result = getContacts(m_filteredContactIds); }else{ ContactArrayPtr contacts(new ContactArray()); result = contacts; @@ -316,12 +322,16 @@ void ContactSearchEngine::visitAttribute(string& attrName, MatchFlag& matchFlag, if(properties.type == ContactSvcPrimitiveType_Boolean) { bool value = matchValue->getBool(); - queryAttributeBool(properties, idSet, value); } else if(properties.type == ContactSvcPrimitiveType_String) { - string value = matchValue->getString(); + string value; + if(attrName == "photoURI" || attrName == "ringtoneURI" || attrName == "organizations.logoURI") + value = ContactUtility::convertUriToPath(matchValue->getString()); + else + value = matchValue->getString(); + contacts_match_str_flag_e flag = CONTACTS_MATCH_EXISTS; if(matchFlag == MATCH_EXACTLY) @@ -343,16 +353,26 @@ void ContactSearchEngine::visitAttribute(string& attrName, MatchFlag& matchFlag, { int value; - if(attrName == "id") + if(attrName == "id" || attrName == "personId"){ value = ContactUtility::strToInt(matchValue->getString()); - else + }else if(attrName == "lastUpdated"){ + time_t tmpTime = mktime(matchValue->getDateTm()); + value = (int)tmpTime; + }else if(attrName == "birthday" || attrName == "anniversaries.date"){ + value = ContactUtility::toDateDbInt(*matchValue->getDateTm()); + }else{ value = matchValue->getLong(); + } contacts_match_int_flag_e flag; if(matchFlag == MATCH_EXISTS) { flag = CONTACTS_MATCH_GREATER_THAN_OR_EQUAL; value = 0; + }else if(matchFlag == MATCH_STARTSWITH || matchFlag == MATCH_CONTAINS){ + flag = CONTACTS_MATCH_GREATER_THAN_OR_EQUAL; + }else if(matchFlag == MATCH_ENDSWITH){ + flag = CONTACTS_MATCH_LESS_THAN_OR_EQUAL; }else{ flag = CONTACTS_MATCH_EQUAL; } @@ -462,13 +482,30 @@ void ContactSearchEngine::visitAttributeRange(string& attrName, AnyPtr& initialV int initialValueInt = 0; int endValueInt = 0; - if(attrName == "id") + if(attrName == "id" || attrName == "personId") { if(initialValueIsSet) initialValueInt = ContactUtility::strToInt(initialValue->getString()); if(endValueIsSet) endValueInt = ContactUtility::strToInt(endValue->getString()); } + else if(attrName == "lastUpdated"){ + if(initialValueIsSet){ + time_t tmpTime = mktime(initialValue->getDateTm()); + initialValueInt = (int)tmpTime; + } + if(endValueIsSet){ + time_t tmpTime = mktime(endValue->getDateTm()); + endValueInt = (int)tmpTime; + } + }else if(attrName == "birthday" || attrName == "anniversaries.date"){ + if(initialValueIsSet){ + initialValueInt = ContactUtility::toDateDbInt(*initialValue->getDateTm()); + } + if(endValueIsSet){ + endValueInt = ContactUtility::toDateDbInt(*initialValue->getDateTm()); + } + } else { if(initialValueIsSet) diff --git a/src/Contact/ContactTypes.h b/src/Contact/ContactTypes.h index 5b13af5..f506894 100755 --- a/src/Contact/ContactTypes.h +++ b/src/Contact/ContactTypes.h @@ -42,7 +42,8 @@ enum ContactEmailAddressType CONTACT_EMAIL_TYPE_NULL , CONTACT_EMAIL_TYPE_WORK , CONTACT_EMAIL_TYPE_PREF , - CONTACT_EMAIL_TYPE_HOME + CONTACT_EMAIL_TYPE_HOME , + CONTACT_EMAIL_TYPE_MOBILE }; enum ContactPhoneNumberType @@ -61,7 +62,8 @@ enum ContactPhoneNumberType CONTACT_PHONE_NUMBER_TYPE_CAR, CONTACT_PHONE_NUMBER_TYPE_ISDN, CONTACT_PHONE_NUMBER_TYPE_VIDEO, - CONTACT_PHONE_NUMBER_TYPE_PCS + CONTACT_PHONE_NUMBER_TYPE_PCS, + CONTACT_PHONE_NUMBER_TYPE_ASSISTANT }; enum ContactAddressType @@ -69,7 +71,11 @@ enum ContactAddressType CONTACT_ADDRESS_TYPE_NULL, CONTACT_ADDRESS_TYPE_WORK, CONTACT_ADDRESS_TYPE_PREF, - CONTACT_ADDRESS_TYPE_HOME + CONTACT_ADDRESS_TYPE_HOME, + CONTACT_ADDRESS_TYPE_DOM, + CONTACT_ADDRESS_TYPE_INTL, + CONTACT_ADDRESS_TYPE_POSTAL, + CONTACT_ADDRESS_TYPE_PARCEL }; enum ContactWebSiteType @@ -79,6 +85,13 @@ enum ContactWebSiteType WEBSITE_TYPE_BLOG }; +enum ContactOrganizationType +{ + ORGANIZATION_TYPE_NULL, + ORGANIZATION_TYPE_WORK, + ORGANIZATION_TYPE_OTHER +}; + enum ContactVCardFormat { VCARD_30_FORMAT diff --git a/src/Contact/ContactWebSite.cpp b/src/Contact/ContactWebSite.cpp index 651abdb..1b6fcfc 100755 --- a/src/Contact/ContactWebSite.cpp +++ b/src/Contact/ContactWebSite.cpp @@ -88,6 +88,9 @@ void ContactWebSite::clear() m_type = WEBSITE_TYPE_HOMEPAGE; m_typeIsSet = false; + + m_label = ""; + m_labelIsSet = false; } ContactWebSitePtr ContactWebSite::clone() const @@ -100,8 +103,27 @@ ContactWebSitePtr ContactWebSite::clone() const result->m_type = m_type; result->m_typeIsSet = m_typeIsSet; + result->m_label = m_label; + result->m_labelIsSet = m_labelIsSet; + return result; } +std::string ContactWebSite::getLabel() const +{ + return m_label; +} + +void ContactWebSite::setLabel(const std::string &value) +{ + m_label = value; + m_labelIsSet = true; +} + +bool ContactWebSite::getLabelIsSet() const +{ + return m_labelIsSet; +} + } // Contact } // DeviceAPI diff --git a/src/Contact/ContactWebSite.h b/src/Contact/ContactWebSite.h index fc56449..f7f7efe 100755 --- a/src/Contact/ContactWebSite.h +++ b/src/Contact/ContactWebSite.h @@ -58,12 +58,20 @@ public: void clear(); ContactWebSitePtr clone() const; + std::string getLabel() const; + void setLabel(const std::string &value); + bool getLabelIsSet() const; + private: std::string m_url; bool m_urlIsSet; ContactWebSiteType m_type; bool m_typeIsSet; + + std::string m_label; + bool m_labelIsSet; + }; } // Contact diff --git a/src/Contact/ContactsSvcObjectConverter.cpp b/src/Contact/ContactsSvcObjectConverter.cpp index 983a14b..4e34980 100755 --- a/src/Contact/ContactsSvcObjectConverter.cpp +++ b/src/Contact/ContactsSvcObjectConverter.cpp @@ -375,13 +375,14 @@ void ContactsSvcObjectConverter::convertToPlatform(PersonPtr& person, contacts_r } // displayContactId -// int intValue = ContactUtility::strToInt(person->getDisplayContactId()); -// errorCode = contacts_record_set_int(record, _contacts_person.display_contact_id, intValue); -// if(errorCode != CONTACTS_ERROR_NONE) -// { -// ThrowMsg(PlatformException, "importing displayContactId E (err:" << -// errorCode << ", value:" << intValue << ")"); -// } // FIXME platform still has problem on this field. + int intValue = ContactUtility::strToInt(person->getDisplayContactId()); + LoggerD("displayContactId : " << intValue); + + errorCode = contacts_record_set_int(record, _contacts_person.display_contact_id, intValue); + if(errorCode != CONTACTS_ERROR_NONE) + { + ThrowMsg(PlatformException, "importing displayContactId E (err:" << errorCode << ", value:" << intValue << ")"); + } } void ContactsSvcObjectConverter::convertToAbstract(contacts_record_h record, ContactPtr& contact) @@ -466,7 +467,7 @@ void ContactsSvcObjectConverter::convertToAbstract(contacts_record_h record, Con group->unsetRingtoneURI(); } - // isFavorite + // is_read_only errorCode = contacts_record_get_bool(record, _contacts_group.is_read_only, &boolValue); if(errorCode != CONTACTS_ERROR_NONE) ThrowMsg(PlatformException, "error on contacts_record_get_bool (is_read_only) (errorCode:" << errorCode << ")"); diff --git a/src/Contact/IAddressBook.cpp b/src/Contact/IAddressBook.cpp old mode 100644 new mode 100755 index 2f03f23..c771fe2 --- a/src/Contact/IAddressBook.cpp +++ b/src/Contact/IAddressBook.cpp @@ -67,6 +67,7 @@ void IAddressBook::get(const EventAddressBookGetPtr &event) void IAddressBook::add(const EventAddressBookAddPtr &event) { + LoggerD("entered"); //post event to PLATFORM implementation EventRequestReceiver< EventAddressBookAdd >::PostRequest(event); } diff --git a/src/Contact/JSAddressBook.cpp b/src/Contact/JSAddressBook.cpp old mode 100644 new mode 100755 index 99dfe5f..33eac7d --- a/src/Contact/JSAddressBook.cpp +++ b/src/Contact/JSAddressBook.cpp @@ -65,7 +65,8 @@ namespace DeviceAPI { namespace Contact { using namespace DeviceAPI::Common; -using namespace DeviceAPI::Tizen; using namespace WrtDeviceApis::Commons; +using namespace DeviceAPI::Tizen; +using namespace WrtDeviceApis::Commons; using namespace WrtDeviceApis::CommonsJavaScript; JSClassRef JSAddressBook::m_jsClassRef = NULL; @@ -1272,7 +1273,7 @@ JSValueRef JSAddressBook::getGroup(JSContextRef context, case ExceptionCodes::NotFoundException: case ExceptionCodes::InvalidArgumentException: LoggerE("Not Found error : " << id); - oss << "No Contact id '" << id << "'"; + oss << "No Group id '" << id << "'"; return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::NOT_FOUND_ERROR, oss.str()); break; @@ -1463,7 +1464,7 @@ JSValueRef JSAddressBook::updateGroup(JSContextRef context, { case ExceptionCodes::NotFoundException: case ExceptionCodes::InvalidArgumentException: - oss << "No Contact id '" << contact->getId() << "'"; + oss << "No Group id '" << contact->getId() << "'"; return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::NOT_FOUND_ERROR, oss.str()); break; @@ -1544,7 +1545,7 @@ JSValueRef JSAddressBook::removeGroup(JSContextRef context, case ExceptionCodes::NotFoundException: case ExceptionCodes::InvalidArgumentException: LoggerE("Not Found error : " << groupId); - oss << "No Contact id '" << groupId << "'"; + oss << "No Group id '" << groupId << "'"; return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::NOT_FOUND_ERROR, oss.str()); break; @@ -1615,7 +1616,7 @@ JSValueRef JSAddressBook::getGroups(JSContextRef context, case ExceptionCodes::NotFoundException: case ExceptionCodes::InvalidArgumentException: LoggerE("Not Found error : " << id); - oss << "No Contact id '" << id << "'"; + oss << "No Group id '" << id << "'"; return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::NOT_FOUND_ERROR, oss.str()); break; diff --git a/src/Contact/JSContact.cpp b/src/Contact/JSContact.cpp index c20c1dd..b26820e 100755 --- a/src/Contact/JSContact.cpp +++ b/src/Contact/JSContact.cpp @@ -314,6 +314,7 @@ JSValueRef JSContact::getId(JSContextRef context, ContactConverterFactory::ConverterType converter = ContactConverterFactory::getConverter(context); ContactPtr contact = getPrivData(object); + if(!contact->getIdIsSet()) return JSValueMakeNull(context); else @@ -1154,18 +1155,18 @@ JSValueRef JSContact::convertToString(JSContextRef context, std::string format; if(argumentCount > 0){ - ArgumentValidator validator(context, argumentCount, arguments); - try { - format = validator.toString(0, false); - } catch (const TypeMismatchException& err ) { - return JSWebAPIErrorFactory::postException(context, exception, err); - } catch(const BasePlatformException& err) { - return JSWebAPIErrorFactory::postException(context, exception, err); - } catch(const ConversionException& err) { - return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, ""); - } catch(const NullPointerException& err) { - return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, ""); - } + ArgumentValidator validator(context, argumentCount, arguments); + try { + format = validator.toString(0, false); + } catch (const TypeMismatchException& err ) { + return JSWebAPIErrorFactory::postException(context, exception, err); + } catch(const BasePlatformException& err) { + return JSWebAPIErrorFactory::postException(context, exception, err); + } catch(const ConversionException& err) { + return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, ""); + } catch(const NullPointerException& err) { + return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, ""); + } }else{ format = "VCARD_30"; } diff --git a/src/Contact/JSContactAddress.cpp b/src/Contact/JSContactAddress.cpp index 8e7d116..2c9b9f8 100755 --- a/src/Contact/JSContactAddress.cpp +++ b/src/Contact/JSContactAddress.cpp @@ -40,6 +40,7 @@ #define CONTACT_ATTR_POSTAL_CODE "postalCode" #define CONTACT_ATTR_IS_DEFAULT "isDefault" #define CONTACT_ATTR_TYPES "types" +#define CONTACT_ATTR_LABEL "label" namespace DeviceAPI { namespace Contact { @@ -78,6 +79,7 @@ JSStaticValue JSContactAddress::m_property[] = { { CONTACT_ATTR_POSTAL_CODE, getPostalCode, setPostalCode, kJSPropertyAttributeNone }, { CONTACT_ATTR_IS_DEFAULT, getIsDefault, setIsDefault, kJSPropertyAttributeNone }, { CONTACT_ATTR_TYPES, getTypes, setTypes, kJSPropertyAttributeNone }, + { CONTACT_ATTR_LABEL, getLabel, setLabel, kJSPropertyAttributeNone }, { 0, 0, 0, 0 } }; @@ -195,13 +197,13 @@ JSObjectRef JSContactAddress::constructor(JSContextRef context, ContactConverterFactory::ConverterType converter = ContactConverterFactory::getConverter(gContext); - ContactAddressPtr contactEmailAddress(NULL); + ContactAddressPtr contactAddress(NULL); Try { if(js1stParamIsObject) - contactEmailAddress = converter->toContactAddressFromInit(arguments[0]); + contactAddress = converter->toContactAddressFromInit(arguments[0]); else - contactEmailAddress = ContactAddressPtr(new ContactAddress()); + contactAddress = ContactAddressPtr(new ContactAddress()); } Catch(Exception) { LoggerE("Argument type mismatch : " << _rethrown_exception.GetMessage()); @@ -212,7 +214,7 @@ JSObjectRef JSContactAddress::constructor(JSContextRef context, JSObjectRef jsobject; Try { - jsobject = createJSObject(gContext, contactEmailAddress); + jsobject = createJSObject(gContext, contactAddress); } Catch(Exception) { LoggerE("Argument type mismatch : " << _rethrown_exception.GetMessage()); *exception = JSWebAPIErrorFactory::makeErrorObject(context, JSWebAPIErrorFactory::UNKNOWN_ERROR, "Internal error"); @@ -626,5 +628,48 @@ bool JSContactAddress::setTypes(JSContextRef context, return true; } +JSValueRef JSContactAddress::getLabel(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception) +{ + Try + { + ContactConverterFactory::ConverterType converter = ContactConverterFactory::getConverter(context); + ContactAddressPtr contactAddress = getPrivData(object); + if(!contactAddress->getLabelIsSet()) + return JSValueMakeNull(context); + else + return converter->toJSValueRef(contactAddress->getLabel()); + } + Catch(WrtDeviceApis::Commons::Exception) + { + LoggerW("trying to get incorrect value"); + } + return JSValueMakeUndefined(context); +} + +bool JSContactAddress::setLabel(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef value, + JSValueRef* exception) +{ + Try + { + ContactAddressPtr contactAddress = getPrivData(object); + ContactConverterFactory::ConverterType converter = ContactConverterFactory::getConverter(context); + BasicValidator validator = + BasicValidatorFactory::getValidator(context, exception); + contactAddress->setLabel(converter->toString(value)); + } + Catch(WrtDeviceApis::Commons::Exception) + { + LoggerW("trying to set incorrect value"); + JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch"); + } + return true; +} + } // Contact } // DeviceAPI diff --git a/src/Contact/JSContactAddress.h b/src/Contact/JSContactAddress.h index f200ca6..b9d6e9e 100755 --- a/src/Contact/JSContactAddress.h +++ b/src/Contact/JSContactAddress.h @@ -178,6 +178,18 @@ private: JSStringRef propertyName, JSValueRef value, JSValueRef* exception); + + static JSValueRef getLabel(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception); + + static bool setLabel(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef value, + JSValueRef* exception); + }; } // Contact diff --git a/src/Contact/JSContactEmailAddress.cpp b/src/Contact/JSContactEmailAddress.cpp index 362b566..c1b527c 100755 --- a/src/Contact/JSContactEmailAddress.cpp +++ b/src/Contact/JSContactEmailAddress.cpp @@ -35,6 +35,7 @@ #define CONTACT_ATTR_EMAIL "email" #define CONTACT_ATTR_TYPES "types" #define CONTACT_ATTR_IS_DEFAULT "isDefault" +#define CONTACT_ATTR_LABEL "label" namespace DeviceAPI { namespace Contact { @@ -68,6 +69,7 @@ JSStaticValue JSContactEmailAddress::m_property[] = { { CONTACT_ATTR_EMAIL, getEmail, setEmail, kJSPropertyAttributeNone }, { CONTACT_ATTR_TYPES, getTypes, setTypes, kJSPropertyAttributeNone }, { CONTACT_ATTR_IS_DEFAULT, getIsDefault, setIsDefault, kJSPropertyAttributeNone }, + { CONTACT_ATTR_LABEL, getLabel, setLabel, kJSPropertyAttributeNone }, { 0, 0, 0, 0 } }; @@ -168,6 +170,7 @@ JSObjectRef JSContactEmailAddress::constructor(JSContextRef context, std::string email; ContactEmailAddressTypeArrayPtr types(NULL); bool isDefault = false; + std::string label; try { ArgumentValidator Argvalidator(context, argumentCount, arguments); @@ -185,6 +188,9 @@ JSObjectRef JSContactEmailAddress::constructor(JSContextRef context, if (argumentCount >= 3) isDefault = Argvalidator.toBool(2, false); + if (argumentCount >= 4) + label = Argvalidator.toString(3, false); + } catch (const TypeMismatchException& err ) { JSWebAPIErrorFactory::postException(context, exception, err); return NULL; @@ -203,6 +209,7 @@ JSObjectRef JSContactEmailAddress::constructor(JSContextRef context, contactEmailAddress->setEmail(email); contactEmailAddress->setTypes(types); contactEmailAddress->setIsDefault(isDefault); + contactEmailAddress->setLabel(label); JSObjectRef jsobject; @@ -370,5 +377,44 @@ bool JSContactEmailAddress::setTypes(JSContextRef context, return true; } +JSValueRef JSContactEmailAddress::getLabel(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception) +{ + Try + { + ContactConverterFactory::ConverterType converter = ContactConverterFactory::getConverter(context); + ContactEmailAddressPtr emailAddress = getPrivData(object); + return converter->toJSValueRef(emailAddress->getLabel()); + } + Catch(WrtDeviceApis::Commons::Exception) + { + LoggerW("trying to get incorrect value"); + } + return JSValueMakeUndefined(context); +} + +bool JSContactEmailAddress::setLabel(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef value, + JSValueRef* exception) +{ + Try + { + ContactEmailAddressPtr emailAddress = getPrivData(object); + ContactConverterFactory::ConverterType converter = ContactConverterFactory::getConverter(context); + emailAddress->setLabel(converter->toString(value)); + } + Catch(WrtDeviceApis::Commons::Exception) + { + LoggerW("trying to set incorrect value"); + JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch"); + } + + return true; +} + } // Contact } // DeviceAPI diff --git a/src/Contact/JSContactEmailAddress.h b/src/Contact/JSContactEmailAddress.h index 3e33651..0f37786 100755 --- a/src/Contact/JSContactEmailAddress.h +++ b/src/Contact/JSContactEmailAddress.h @@ -123,6 +123,18 @@ private: JSStringRef propertyName, JSValueRef value, JSValueRef* exception); + + static JSValueRef getLabel(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception); + + static bool setLabel(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef value, + JSValueRef* exception); + }; } // Contact diff --git a/src/Contact/JSContactManager.cpp b/src/Contact/JSContactManager.cpp old mode 100644 new mode 100755 index 73ceda6..4ea72c6 --- a/src/Contact/JSContactManager.cpp +++ b/src/Contact/JSContactManager.cpp @@ -425,7 +425,7 @@ JSValueRef JSContactManager::getAddressBook(JSContextRef context, case ExceptionCodes::NotFoundException: case ExceptionCodes::InvalidArgumentException: LoggerE("Not Found error : " << addressBookId); - oss << "No Contact id '" << addressBookId << "'"; + oss << "No addressBookId id '" << addressBookId << "'"; return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::NOT_FOUND_ERROR, oss.str()); break; case ExceptionCodes::PlatformException: @@ -480,7 +480,7 @@ JSValueRef JSContactManager::get(JSContextRef context, if (argumentCount < 1) { /* 1st Argument must be string. */ LoggerE("1st argument must not be undefined."); - return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::NOT_FOUND_ERROR, "No Contact id 'undefined'"); + return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::NOT_FOUND_ERROR, "No id 'undefined'"); } std::string id; @@ -615,7 +615,7 @@ JSValueRef JSContactManager::update(JSContextRef context, { case ExceptionCodes::NotFoundException: case ExceptionCodes::InvalidArgumentException: - oss << "No Contact id '" << person->getId() << "'"; + oss << "No id '" << person->getId() << "'"; return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::NOT_FOUND_ERROR, oss.str()); break; case ExceptionCodes::PlatformException: @@ -789,7 +789,7 @@ JSValueRef JSContactManager::remove(JSContextRef context, case ExceptionCodes::NotFoundException: case ExceptionCodes::InvalidArgumentException: LoggerE("Not Found error : " << personId); - oss << "No Contact id '" << personId << "'"; + oss << "No id '" << personId << "'"; return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::NOT_FOUND_ERROR, oss.str()); break; @@ -1086,7 +1086,7 @@ JSValueRef JSContactManager::addChangeListener(JSContextRef context, } if (onpersonsadded == NULL && onpersonsupdated == NULL && onpersonsdeleted == NULL) - ThrowMsg(ConversionException, "2nd argument must have at least one function"); + ThrowMsg(ConversionException, "invalid 2nd argument"); } Catch(ConversionException) { LoggerE("Error on conversion : " << _rethrown_exception.GetMessage()); diff --git a/src/Contact/JSContactName.cpp b/src/Contact/JSContactName.cpp old mode 100644 new mode 100755 index 60ace3f..c304ac9 --- a/src/Contact/JSContactName.cpp +++ b/src/Contact/JSContactName.cpp @@ -39,6 +39,7 @@ #define CONTACT_PROP_ATTR_NICKNAMES "nicknames" #define CONTACT_PROP_ATTR_PHONETIC_NAME "phoneticName" #define CONTACT_PROP_ATTR_PHONETIC_FIRST_NAME "phoneticFirstName" +#define CONTACT_PROP_ATTR_PHONETIC_MIDDLE_NAME "phoneticMiddleName" #define CONTACT_PROP_ATTR_PHONETIC_LAST_NAME "phoneticLastName" #define CONTACT_PROP_ATTR_DISPLAY_NAME "displayName" @@ -79,6 +80,7 @@ JSStaticValue JSContactName::m_property[] = { { CONTACT_PROP_ATTR_NICKNAMES, getNicknames, setNicknames, kJSPropertyAttributeNone }, { CONTACT_PROP_ATTR_PHONETIC_NAME, getPhoneticName, setPhoneticName, kJSPropertyAttributeNone }, { CONTACT_PROP_ATTR_PHONETIC_FIRST_NAME, getPhoneticFirstName, setPhoneticFirstName, kJSPropertyAttributeNone }, + { CONTACT_PROP_ATTR_PHONETIC_MIDDLE_NAME, getPhoneticMiddleName, setPhoneticMiddleName, kJSPropertyAttributeNone }, { CONTACT_PROP_ATTR_PHONETIC_LAST_NAME, getPhoneticLastName, setPhoneticLastName, kJSPropertyAttributeNone }, { CONTACT_PROP_ATTR_DISPLAY_NAME, getDisplayName, NULL, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { 0, 0, 0, 0 } @@ -614,6 +616,56 @@ bool JSContactName::setPhoneticFirstName(JSContextRef context, return true; } +JSValueRef JSContactName::getPhoneticMiddleName(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception) +{ + Try + { + ContactConverterFactory::ConverterType converter = + ContactConverterFactory::getConverter(context); + ContactNamePtr contactName = getPrivData(object); + + if(!contactName->getPhoneticMiddleNameIsSet()) + return JSValueMakeNull(context); + else + return converter->toJSValueRef(contactName->getPhoneticMiddleName()); + } + Catch(WrtDeviceApis::Commons::Exception) + { + LoggerW("trying to get incorrect value"); + } + + return JSValueMakeUndefined(context); +} + +bool JSContactName::setPhoneticMiddleName(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef value, + JSValueRef* exception) +{ + Try + { + ContactNamePtr contactName = getPrivData(object); + ContactConverterFactory::ConverterType converter = + ContactConverterFactory::getConverter(context); + BasicValidator validator = + BasicValidatorFactory::getValidator(context, exception); + if(validator->isNullOrUndefined(value)) + contactName->unsetPhoneticMiddleName(); + else + contactName->setPhoneticMiddleName(converter->toString(value)); + } + Catch(WrtDeviceApis::Commons::Exception) + { + LoggerW("trying to set incorrect value"); + JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch"); + } + + return true; +} JSValueRef JSContactName::getPhoneticLastName(JSContextRef context, JSObjectRef object, diff --git a/src/Contact/JSContactName.h b/src/Contact/JSContactName.h index b49f492..a1dc8eb 100755 --- a/src/Contact/JSContactName.h +++ b/src/Contact/JSContactName.h @@ -179,6 +179,17 @@ private: JSValueRef value, JSValueRef* exception); + static JSValueRef getPhoneticMiddleName(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception); + + static bool setPhoneticMiddleName(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef value, + JSValueRef* exception); + static JSValueRef getPhoneticLastName(JSContextRef context, JSObjectRef object, JSStringRef propertyName, diff --git a/src/Contact/JSContactOrganization.cpp b/src/Contact/JSContactOrganization.cpp old mode 100644 new mode 100755 index 17df015..39ceb8f --- a/src/Contact/JSContactOrganization.cpp +++ b/src/Contact/JSContactOrganization.cpp @@ -34,11 +34,17 @@ #define CONTACT_ATTR_NAME "name" #define CONTACT_ATTR_DEPARTMENT "department" -#define CONTACT_ATTR_OFFICE "office" #define CONTACT_ATTR_TITLE "title" #define CONTACT_ATTR_ROLE "role" #define CONTACT_ATTR_LOGO_URI "logoURI" +#define CONTACT_ATTR_ASSISTANT_NAME "assistant" +#define CONTACT_ATTR_LOCATION "location" +#define CONTACT_ATTR_DESCRIPTION "description" +#define CONTACT_ATTR_PHONETIC_NAME "phoneticName" +#define CONTACT_ATTR_TYPE "type" +#define CONTACT_ATTR_LABEL "label" + namespace DeviceAPI { namespace Contact { @@ -70,10 +76,15 @@ JSClassDefinition JSContactOrganization::m_classInfo = JSStaticValue JSContactOrganization::m_property[] = { { CONTACT_ATTR_NAME, getName, setName, kJSPropertyAttributeNone }, { CONTACT_ATTR_DEPARTMENT, getDepartment, setDepartment, kJSPropertyAttributeNone }, - { CONTACT_ATTR_OFFICE, getOffice, setOffice, kJSPropertyAttributeNone }, { CONTACT_ATTR_TITLE, getTitle, setTitle, kJSPropertyAttributeNone }, { CONTACT_ATTR_ROLE, getRole, setRole, kJSPropertyAttributeNone }, { CONTACT_ATTR_LOGO_URI, getLogoURI, setLogoURI, kJSPropertyAttributeNone }, + { CONTACT_ATTR_ASSISTANT_NAME, getAssistant, setAssistant, kJSPropertyAttributeNone }, + { CONTACT_ATTR_LOCATION, getLocation, setLocation, kJSPropertyAttributeNone }, + { CONTACT_ATTR_DESCRIPTION, getDescription, setDescription, kJSPropertyAttributeNone }, + { CONTACT_ATTR_PHONETIC_NAME, getPhoneticName, setPhoneticName, kJSPropertyAttributeNone }, + { CONTACT_ATTR_TYPE, getType, setType, kJSPropertyAttributeNone }, + { CONTACT_ATTR_LABEL, getLabel, setLabel, kJSPropertyAttributeNone }, { 0, 0, 0, 0 } }; @@ -322,25 +333,6 @@ bool JSContactOrganization::setDepartment(JSContextRef context, return true; } -JSValueRef JSContactOrganization::getOffice(JSContextRef context, - JSObjectRef object, - JSStringRef propertyName, - JSValueRef* exception) -{ - // NOTE: Deprecated field. - return JSValueMakeNull(context); -} - -bool JSContactOrganization::setOffice(JSContextRef context, - JSObjectRef object, - JSStringRef propertyName, - JSValueRef value, - JSValueRef* exception) -{ - // NOTE: Deprecated field. - return true; -} - JSValueRef JSContactOrganization::getTitle(JSContextRef context, JSObjectRef object, JSStringRef propertyName, @@ -485,5 +477,287 @@ bool JSContactOrganization::setLogoURI(JSContextRef context, return true; } +JSValueRef JSContactOrganization::getAssistant(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception) +{ + Try + { + ContactConverterFactory::ConverterType converter = + ContactConverterFactory::getConverter(context); + ContactOrganizationPtr organization = getPrivData(object); + if(!organization->getAssistantIsSet()) + return JSValueMakeNull(context); + else + return converter->toJSValueRef(organization->getAssistant()); + } + Catch(WrtDeviceApis::Commons::Exception) + { + LoggerW("trying to get incorrect value"); + } + return JSValueMakeUndefined(context); +} + +bool JSContactOrganization::setAssistant(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef value, + JSValueRef* exception) +{ + Try + { + ContactOrganizationPtr organization = getPrivData(object); + ContactConverterFactory::ConverterType converter = + ContactConverterFactory::getConverter(context); + BasicValidator validator = + BasicValidatorFactory::getValidator(context, exception); + if(validator->isNullOrUndefined(value)) + organization->unsetAssistant(); + else + organization->setAssistant(converter->toString(value)); + } + Catch(WrtDeviceApis::Commons::Exception) + { + LoggerW("trying to set incorrect value"); + JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch"); + } + return true; +} + +JSValueRef JSContactOrganization::getLocation(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception) +{ + Try + { + ContactConverterFactory::ConverterType converter = + ContactConverterFactory::getConverter(context); + ContactOrganizationPtr organization = getPrivData(object); + return converter->toJSValueRef(organization->getLocation()); + } + Catch(WrtDeviceApis::Commons::Exception) + { + LoggerW("trying to get incorrect value"); + } + return JSValueMakeUndefined(context); +} + +bool JSContactOrganization::setLocation(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef value, + JSValueRef* exception) +{ + Try + { + ContactOrganizationPtr organization = getPrivData(object); + ContactConverterFactory::ConverterType converter = + ContactConverterFactory::getConverter(context); + BasicValidator validator = + BasicValidatorFactory::getValidator(context, exception); + if(validator->isNullOrUndefined(value)) + organization->unsetLocation(); + else + organization->setLocation(converter->toString(value)); + } + Catch(WrtDeviceApis::Commons::Exception) + { + LoggerW("trying to set incorrect value"); + JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch"); + } + return true; +} + +JSValueRef JSContactOrganization::getDescription(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception) +{ + Try + { + ContactConverterFactory::ConverterType converter = + ContactConverterFactory::getConverter(context); + ContactOrganizationPtr organization = getPrivData(object); + if(!organization->getDescriptionIsSet()) + return JSValueMakeNull(context); + else + return converter->toJSValueRef(organization->getDescription()); + } + Catch(WrtDeviceApis::Commons::Exception) + { + LoggerW("trying to get incorrect value"); + } + return JSValueMakeUndefined(context); +} + +bool JSContactOrganization::setDescription(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef value, + JSValueRef* exception) +{ + Try + { + ContactOrganizationPtr organization = getPrivData(object); + ContactConverterFactory::ConverterType converter = + ContactConverterFactory::getConverter(context); + BasicValidator validator = + BasicValidatorFactory::getValidator(context, exception); + if(validator->isNullOrUndefined(value)) + organization->unsetDescription(); + else + organization->setDescription(converter->toString(value)); + } + Catch(WrtDeviceApis::Commons::Exception) + { + LoggerW("trying to set incorrect value"); + JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch"); + } + return true; +} + +JSValueRef JSContactOrganization::getPhoneticName(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception) +{ + Try + { + ContactConverterFactory::ConverterType converter = + ContactConverterFactory::getConverter(context); + ContactOrganizationPtr organization = getPrivData(object); + if(!organization->getPhoneticNameIsSet()) + return JSValueMakeNull(context); + else + return converter->toJSValueRef(organization->getPhoneticName()); + } + Catch(WrtDeviceApis::Commons::Exception) + { + LoggerW("trying to get incorrect value"); + } + return JSValueMakeUndefined(context); +} + +bool JSContactOrganization::setPhoneticName(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef value, + JSValueRef* exception) +{ + Try + { + ContactOrganizationPtr organization = getPrivData(object); + ContactConverterFactory::ConverterType converter = + ContactConverterFactory::getConverter(context); + BasicValidator validator = + BasicValidatorFactory::getValidator(context, exception); + if(validator->isNullOrUndefined(value)) + organization->unsetPhoneticName(); + else + organization->setPhoneticName(converter->toString(value)); + } + Catch(WrtDeviceApis::Commons::Exception) + { + LoggerW("trying to set incorrect value"); + JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch"); + } + return true; +} + +JSValueRef JSContactOrganization::getType(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception) +{ + Try + { + ContactConverterFactory::ConverterType converter = + ContactConverterFactory::getConverter(context); + ContactOrganizationPtr organization = getPrivData(object); + if(!organization->getTypeIsSet()) + return JSValueMakeNull(context); + else + return converter->toJSValueRef(organization->getType()); + } + Catch(WrtDeviceApis::Commons::Exception) + { + LoggerW("trying to get incorrect value"); + } + return JSValueMakeUndefined(context); +} + +bool JSContactOrganization::setType(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef value, + JSValueRef* exception) +{ + Try + { + ContactOrganizationPtr organization = getPrivData(object); + ContactConverterFactory::ConverterType converter = + ContactConverterFactory::getConverter(context); + BasicValidator validator = + BasicValidatorFactory::getValidator(context, exception); + if(validator->isNullOrUndefined(value)) + organization->unsetType(); + else + organization->setType(converter->toContactOrganizationType(value)); + } + Catch(WrtDeviceApis::Commons::Exception) + { + LoggerW("trying to set incorrect value"); + JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch"); + } + return true; +} + +JSValueRef JSContactOrganization::getLabel(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception) +{ + Try + { + ContactConverterFactory::ConverterType converter = + ContactConverterFactory::getConverter(context); + ContactOrganizationPtr organization = getPrivData(object); + return converter->toJSValueRef(organization->getLabel()); + } + Catch(WrtDeviceApis::Commons::Exception) + { + LoggerW("trying to get incorrect value"); + } + return JSValueMakeUndefined(context); +} + +bool JSContactOrganization::setLabel(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef value, + JSValueRef* exception) +{ + Try + { + ContactOrganizationPtr organization = getPrivData(object); + ContactConverterFactory::ConverterType converter = + ContactConverterFactory::getConverter(context); + BasicValidator validator = + BasicValidatorFactory::getValidator(context, exception); + if(validator->isNullOrUndefined(value)) + organization->unsetLabel(); + else + organization->setLabel(converter->toString(value)); + } + Catch(WrtDeviceApis::Commons::Exception) + { + LoggerW("trying to set incorrect value"); + JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch"); + } + return true; +} + } // Contact } // DeviceAPI diff --git a/src/Contact/JSContactOrganization.h b/src/Contact/JSContactOrganization.h index b565ea1..f8a5a31 100755 --- a/src/Contact/JSContactOrganization.h +++ b/src/Contact/JSContactOrganization.h @@ -113,45 +113,100 @@ private: JSValueRef value, JSValueRef* exception); - static JSValueRef getOffice(JSContextRef context, + static JSValueRef getTitle(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception); - static bool setOffice(JSContextRef context, + static bool setTitle(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSValueRef* exception); - static JSValueRef getTitle(JSContextRef context, + static JSValueRef getRole(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception); - static bool setTitle(JSContextRef context, + static bool setRole(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSValueRef* exception); - static JSValueRef getRole(JSContextRef context, + static JSValueRef getLogoURI(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception); - static bool setRole(JSContextRef context, + static bool setLogoURI(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSValueRef* exception); - static JSValueRef getLogoURI(JSContextRef context, + static JSValueRef getAssistant(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception); - static bool setLogoURI(JSContextRef context, + static bool setAssistant(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef value, + JSValueRef* exception); + + static JSValueRef getLocation(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception); + + static bool setLocation(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef value, + JSValueRef* exception); + + static JSValueRef getDescription(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception); + + static bool setDescription(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef value, + JSValueRef* exception); + + static JSValueRef getPhoneticName(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception); + + static bool setPhoneticName(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef value, + JSValueRef* exception); + + static JSValueRef getType(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception); + + static bool setType(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef value, + JSValueRef* exception); + + static JSValueRef getLabel(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception); + + static bool setLabel(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef value, diff --git a/src/Contact/JSContactPhoneNumber.cpp b/src/Contact/JSContactPhoneNumber.cpp index b212775..557b2c9 100755 --- a/src/Contact/JSContactPhoneNumber.cpp +++ b/src/Contact/JSContactPhoneNumber.cpp @@ -35,6 +35,7 @@ #define CONTACT_ATTR_NUMBER "number" #define CONTACT_ATTR_TYPES "types" #define CONTACT_ATTR_IS_DEFAULT "isDefault" +#define CONTACT_ATTR_LABEL "label" namespace DeviceAPI { namespace Contact { @@ -68,6 +69,7 @@ JSStaticValue JSContactPhoneNumber::m_property[] = { { CONTACT_ATTR_NUMBER, getNumber, setNumber, kJSPropertyAttributeNone }, { CONTACT_ATTR_TYPES, getTypes, setTypes, kJSPropertyAttributeNone }, { CONTACT_ATTR_IS_DEFAULT, getIsDefault, setIsDefault, kJSPropertyAttributeNone }, + { CONTACT_ATTR_LABEL, getLabel, setLabel, kJSPropertyAttributeNone }, { 0, 0, 0, 0 } }; @@ -166,6 +168,7 @@ JSObjectRef JSContactPhoneNumber::constructor(JSContextRef context, std::string number; ContactPhoneNumberTypeArrayPtr types(NULL); bool isDefault = false; + std::string label; try { ArgumentValidator Argvalidator(context, argumentCount, arguments); @@ -183,6 +186,9 @@ JSObjectRef JSContactPhoneNumber::constructor(JSContextRef context, if (argumentCount >= 3) isDefault = Argvalidator.toBool(2, false); + if (argumentCount >= 4) + label = Argvalidator.toString(3, false); + } catch (const TypeMismatchException& err ) { JSWebAPIErrorFactory::postException(context, exception, err); return NULL; @@ -201,6 +207,7 @@ JSObjectRef JSContactPhoneNumber::constructor(JSContextRef context, contactPhoneNumber->setNumber(number); contactPhoneNumber->setTypes(types); contactPhoneNumber->setIsDefault(isDefault); + contactPhoneNumber->setLabel(label); JSObjectRef jsobject; @@ -274,6 +281,8 @@ JSValueRef JSContactPhoneNumber::getIsDefault(JSContextRef context, ContactConverterFactory::ConverterType converter = ContactConverterFactory::getConverter(context); ContactPhoneNumberPtr contactPhoneNumber = getPrivData(object); + LoggerD("contactPhoneNumber->getIsDefault() : " << contactPhoneNumber->getIsDefault()); + return converter->toJSValueRef(contactPhoneNumber->getIsDefault()); } Catch(WrtDeviceApis::Commons::Exception) @@ -366,5 +375,44 @@ bool JSContactPhoneNumber::setTypes(JSContextRef context, return true; } +JSValueRef JSContactPhoneNumber::getLabel(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception) +{ + Try + { + ContactConverterFactory::ConverterType converter = ContactConverterFactory::getConverter(context); + ContactPhoneNumberPtr contactPhoneNumber = getPrivData(object); + + return converter->toJSValueRef(contactPhoneNumber->getLabel()); + } + Catch(WrtDeviceApis::Commons::Exception) + { + LoggerW("trying to get incorrect value"); + } + return JSValueMakeUndefined(context); +} + +bool JSContactPhoneNumber::setLabel(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef value, + JSValueRef* exception) +{ + Try + { + ContactPhoneNumberPtr contactPhoneNumber = getPrivData(object); + ContactConverterFactory::ConverterType converter = ContactConverterFactory::getConverter(context); + contactPhoneNumber->setLabel(converter->toString(value)); + } + Catch(WrtDeviceApis::Commons::Exception) + { + LoggerW("trying to set incorrect value"); + JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch"); + } + return true; +} + } // Contact } // DeviceAPI diff --git a/src/Contact/JSContactPhoneNumber.h b/src/Contact/JSContactPhoneNumber.h index aba9bcf..0aa7cd9 100755 --- a/src/Contact/JSContactPhoneNumber.h +++ b/src/Contact/JSContactPhoneNumber.h @@ -123,6 +123,18 @@ private: JSStringRef propertyName, JSValueRef value, JSValueRef* exception); + + static JSValueRef getLabel(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception); + + static bool setLabel(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef value, + JSValueRef* exception); + }; } // Contact diff --git a/src/Contact/JSContactWebSite.cpp b/src/Contact/JSContactWebSite.cpp old mode 100644 new mode 100755 index a87ea6d..588fd26 --- a/src/Contact/JSContactWebSite.cpp +++ b/src/Contact/JSContactWebSite.cpp @@ -34,6 +34,7 @@ #define CONTACT_ATTR_URL "url" #define CONTACT_ATTR_TYPE "type" +#define CONTACT_ATTR_LABEL "label" namespace DeviceAPI { namespace Contact { @@ -66,6 +67,7 @@ JSClassDefinition JSContactWebSite::m_classInfo = JSStaticValue JSContactWebSite::m_property[] = { { CONTACT_ATTR_URL, getUrl, setUrl, kJSPropertyAttributeNone }, { CONTACT_ATTR_TYPE, getType, setType, kJSPropertyAttributeNone }, + { CONTACT_ATTR_LABEL, getLabel, setLabel, kJSPropertyAttributeNone }, { 0, 0, 0, 0 } }; @@ -164,16 +166,21 @@ JSObjectRef JSContactWebSite::constructor(JSContextRef context, std::string stringType; ContactWebSiteType type = WEBSITE_TYPE_HOMEPAGE; ContactConverterFactory::ConverterType converter = ContactConverterFactory::getConverter(gContext); + std::string label; try { ArgumentValidator Argvalidator(context, argumentCount, arguments); url = Argvalidator.toString(0, false); if (argumentCount >= 2){ - stringType = Argvalidator.toString(1, true); + stringType = Argvalidator.toString(1, false); type = converter->toContactWebSiteType(stringType); } + if (argumentCount >= 3){ + label = Argvalidator.toString(2, false); + } + } catch (const TypeMismatchException& err ) { JSWebAPIErrorFactory::postException(context, exception, err); return NULL; @@ -191,6 +198,7 @@ JSObjectRef JSContactWebSite::constructor(JSContextRef context, ContactWebSitePtr contactWebSite(new ContactWebSite()); contactWebSite->setUrl(url); contactWebSite->setType(type); + contactWebSite->setLabel(label); JSObjectRef jsobject; @@ -306,5 +314,43 @@ bool JSContactWebSite::setType(JSContextRef context, return true; } +JSValueRef JSContactWebSite::getLabel(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception) +{ + Try + { + ContactConverterFactory::ConverterType converter = ContactConverterFactory::getConverter(context); + ContactWebSitePtr webSite = getPrivData(object); + return converter->toJSValueRef(webSite->getLabel()); + } + Catch(WrtDeviceApis::Commons::Exception) + { + LoggerW("trying to get incorrect value"); + } + return JSValueMakeUndefined(context); +} + +bool JSContactWebSite::setLabel(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef value, + JSValueRef* exception) +{ + Try + { + ContactWebSitePtr webSite = getPrivData(object); + ContactConverterFactory::ConverterType converter = ContactConverterFactory::getConverter(context); + webSite->setLabel(converter->toString(value)); + } + Catch(WrtDeviceApis::Commons::Exception) + { + LoggerW("trying to set incorrect value"); + JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch"); + } + return true; +} + } // Contact } // DeviceAPI diff --git a/src/Contact/JSContactWebSite.h b/src/Contact/JSContactWebSite.h index da35e66..554de22 100755 --- a/src/Contact/JSContactWebSite.h +++ b/src/Contact/JSContactWebSite.h @@ -113,6 +113,17 @@ private: JSValueRef value, JSValueRef* exception); + static JSValueRef getLabel(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception); + + static bool setLabel(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef value, + JSValueRef* exception); + }; } // Contact diff --git a/src/Contact/JSPerson.cpp b/src/Contact/JSPerson.cpp old mode 100644 new mode 100755 index e0dcb9c..88a97af --- a/src/Contact/JSPerson.cpp +++ b/src/Contact/JSPerson.cpp @@ -637,17 +637,17 @@ JSValueRef JSPerson::unlink(JSContextRef context, switch (dplEvent->getExceptionCode()) { case ExceptionCodes::InvalidArgumentException: - oss << "No Contact id is wrong : '" << contactId << "'"; + oss << "The argument is wrong"; return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::INVALID_VALUES_ERROR, oss.str()); break; case ExceptionCodes::NotFoundException: - oss << "No Contact id '" << contactId << "'"; + oss << "Not handled by Platform"; return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::INVALID_VALUES_ERROR, oss.str()); break; case ExceptionCodes::OutOfRangeException: - oss << "Contact (id:'" << contactId << "') is not a member of person"; + oss << "Contact is not a member of person"; return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::INVALID_VALUES_ERROR, oss.str()); break; diff --git a/src/Contact/PersonSearchEngine.cpp b/src/Contact/PersonSearchEngine.cpp old mode 100644 new mode 100755 index 7a9fbe9..3d2bc3a --- a/src/Contact/PersonSearchEngine.cpp +++ b/src/Contact/PersonSearchEngine.cpp @@ -48,7 +48,7 @@ map PersonSearchEngine::attrEn {"isFavorite", { _contacts_person.is_favorite, PrimitiveType_Boolean } }, {"photoURI", { _contacts_person.image_thumbnail_path,PrimitiveType_String } }, {"ringtoneURI", { _contacts_person.ringtone_path, PrimitiveType_String } }, - {"displayContactId", { _contacts_person.display_contact_id, PrimitiveType_String } }, + {"displayContactId", { _contacts_person.display_contact_id, PrimitiveType_Long } }, }; PersonSearchEngine::PersonSearchEngine() : @@ -212,7 +212,7 @@ void PersonSearchEngine::visitAttribute(string& attrName, MatchFlag& matchFlag, if(property.type == PrimitiveType_Long) { int value = 0; - if(attrName == "id") + if(attrName == "id" || attrName == "displayContactId") { string valueStr = matchValue->getString(); value = ContactUtility::strToInt(valueStr); @@ -222,15 +222,26 @@ void PersonSearchEngine::visitAttribute(string& attrName, MatchFlag& matchFlag, contacts_match_int_flag_e flag; if(matchFlag == MATCH_EXISTS) - flag = CONTACTS_MATCH_NONE; - else + { + flag = CONTACTS_MATCH_GREATER_THAN_OR_EQUAL; + value = 0; + }else if(matchFlag == MATCH_STARTSWITH || matchFlag == MATCH_CONTAINS){ + flag = CONTACTS_MATCH_GREATER_THAN_OR_EQUAL; + }else if(matchFlag == MATCH_ENDSWITH){ + flag = CONTACTS_MATCH_LESS_THAN_OR_EQUAL; + }else{ flag = CONTACTS_MATCH_EQUAL; + } errorCode = contacts_filter_add_int(filter, property.propertyId, flag, value); } else if(property.type == PrimitiveType_String) { - string value = matchValue->getString(); + string value; + if(attrName == "photoURI" || attrName == "ringtoneURI") + value = ContactUtility::convertUriToPath(matchValue->getString()); + else + value = matchValue->getString(); contacts_match_str_flag_e flag = CONTACTS_MATCH_EXISTS; if(matchFlag == MATCH_EXACTLY) diff --git a/src/DataControl/SqlDataControlConsumer.cpp b/src/DataControl/SqlDataControlConsumer.cpp index 0e45b08..597ff90 100644 --- a/src/DataControl/SqlDataControlConsumer.cpp +++ b/src/DataControl/SqlDataControlConsumer.cpp @@ -696,13 +696,69 @@ void SQLDataControlConsumer::addArrayToBundle(bundle* passData, std::vector(pEvent) != NULL) + { + EventInsertPendingEvent* pendingInsertEvent = (EventInsertPendingEvent*)pEvent; + EventInsertPtr insertEvent = pendingInsertEvent->getEvent(); + insertEvent->setExceptionCode((WrtDeviceApis::Commons::ExceptionCodes::Enumeration)code); + insertEvent->setErrorMsg(msg); + + WrtDeviceApis::Commons::EventRequestReceiver::ManualAnswer(insertEvent); + } + else if (dynamic_cast(pEvent) != NULL) + { + EventUpdatePendingEvent* pendingUpdateEvent = (EventUpdatePendingEvent*)pEvent; + EventUpdatePtr updateEvent = pendingUpdateEvent->getEvent(); + updateEvent->setExceptionCode((WrtDeviceApis::Commons::ExceptionCodes::Enumeration)code); + updateEvent->setErrorMsg(msg); + + WrtDeviceApis::Commons::EventRequestReceiver::ManualAnswer(updateEvent); + } + else if (dynamic_cast(pEvent) != NULL) + { + EventSelectPendingEvent* pendingSelectEvent = (EventSelectPendingEvent*)pEvent; + EventSelectPtr selectEvent = pendingSelectEvent->getEvent(); + selectEvent->setExceptionCode((WrtDeviceApis::Commons::ExceptionCodes::Enumeration)code); + selectEvent->setErrorMsg(msg); + + WrtDeviceApis::Commons::EventRequestReceiver::ManualAnswer(selectEvent); + } + else if (dynamic_cast(pEvent) != NULL) + { + EventDeletePendingEvent* pendingDeleteEvent = (EventDeletePendingEvent*)pEvent; + EventDeletePtr deleteEvent = pendingDeleteEvent->getEvent(); + deleteEvent->setExceptionCode((WrtDeviceApis::Commons::ExceptionCodes::Enumeration)code); + deleteEvent->setErrorMsg(msg); + + WrtDeviceApis::Commons::EventRequestReceiver::ManualAnswer(deleteEvent); + } + } + catch (const WrtDeviceApis::Commons::Exception& ex) + { + LoggerE("Exception: " << ex.GetMessage()); + } +} void SQLDataControlConsumer::handlePendingEvent(const EventInsertPtr& event) { LoggerD("OK"); WrtDeviceApis::Commons::EventRequestReceiver::ManualAnswer(event); + CommonPendingEvent* userData = NULL; + try { - CommonPendingEvent* userData = (CommonPendingEvent*)DataControlAsyncCallbackManagerSingleton::Instance().getRemainingSQLOperation(); + userData = (CommonPendingEvent*)DataControlAsyncCallbackManagerSingleton::Instance().getRemainingSQLOperation(); if (userData) { @@ -711,15 +767,27 @@ void SQLDataControlConsumer::handlePendingEvent(const EventInsertPtr& event) } catch (const WrtDeviceApis::Commons::Exception& ex) { + if (event.Get() == NULL) + { + LoggerD("event removed, invalid cb"); + return; + } LoggerE("Exception: " << ex.GetMessage()); + + if (userData) + { + handleCommonErrorEvent(userData, ex.getCode(), ex.GetMessage()); + } } } void SQLDataControlConsumer::handlePendingEvent(const EventDeletePtr& event) { WrtDeviceApis::Commons::EventRequestReceiver::ManualAnswer(event); + CommonPendingEvent* userData = NULL; + try { - CommonPendingEvent* userData = (CommonPendingEvent*)DataControlAsyncCallbackManagerSingleton::Instance().getRemainingSQLOperation(); + userData = (CommonPendingEvent*)DataControlAsyncCallbackManagerSingleton::Instance().getRemainingSQLOperation(); if (userData) { @@ -728,7 +796,17 @@ void SQLDataControlConsumer::handlePendingEvent(const EventDeletePtr& event) } catch (const WrtDeviceApis::Commons::Exception& ex) { + if (event.Get() == NULL) + { + LoggerD("event removed, invalid cb"); + return; + } LoggerE("Exception: " << ex.GetMessage()); + + if (userData) + { + handleCommonErrorEvent(userData, ex.getCode(), ex.GetMessage()); + } } @@ -736,8 +814,10 @@ void SQLDataControlConsumer::handlePendingEvent(const EventDeletePtr& event) void SQLDataControlConsumer::handlePendingEvent(const EventSelectPtr& event) { WrtDeviceApis::Commons::EventRequestReceiver::ManualAnswer(event); + CommonPendingEvent* userData = NULL; + try { - CommonPendingEvent* userData = (CommonPendingEvent*)DataControlAsyncCallbackManagerSingleton::Instance().getRemainingSQLOperation(); + userData = (CommonPendingEvent*)DataControlAsyncCallbackManagerSingleton::Instance().getRemainingSQLOperation(); if (userData) { @@ -746,16 +826,30 @@ void SQLDataControlConsumer::handlePendingEvent(const EventSelectPtr& event) } catch (const WrtDeviceApis::Commons::Exception& ex) { + if (event.Get() == NULL) + { + LoggerD("event removed, invalid cb"); + return; + } LoggerE("Exception: " << ex.GetMessage()); + + if (userData) + { + handleCommonErrorEvent(userData, ex.getCode(), ex.GetMessage()); + } + } + } void SQLDataControlConsumer::handlePendingEvent(const EventUpdatePtr& event) { WrtDeviceApis::Commons::EventRequestReceiver::ManualAnswer(event); + CommonPendingEvent* userData = NULL; + try { - CommonPendingEvent* userData = (CommonPendingEvent*)DataControlAsyncCallbackManagerSingleton::Instance().getRemainingSQLOperation(); + userData = (CommonPendingEvent*)DataControlAsyncCallbackManagerSingleton::Instance().getRemainingSQLOperation(); if (userData) { @@ -764,7 +858,17 @@ void SQLDataControlConsumer::handlePendingEvent(const EventUpdatePtr& event) } catch (const WrtDeviceApis::Commons::Exception& ex) { + if (event.Get() == NULL) + { + LoggerD("event removed, invalid cb"); + return; + } LoggerE("Exception: " << ex.GetMessage()); + + if (userData) + { + handleCommonErrorEvent(userData, ex.getCode(), ex.GetMessage()); + } } } @@ -970,7 +1074,7 @@ void SQLDataControlConsumer::SendAppControlLaunchToProvider(void* event) stringBuffer = convertIntToString(columnSize); queryItem.push_back(stringBuffer); - for (int index = 0; index < columnSize; index++) + for (size_t index = 0; index < columnSize; index++) { queryItem.push_back(columns[index]); } diff --git a/src/DataControl/SqlDataControlConsumer.h b/src/DataControl/SqlDataControlConsumer.h index 7cc9e26..5fdcd81 100755 --- a/src/DataControl/SqlDataControlConsumer.h +++ b/src/DataControl/SqlDataControlConsumer.h @@ -65,6 +65,8 @@ private: std::string getProviderPkgId(const std::string& appId); std::string getCurrentApplicationId(); void addArrayToBundle(bundle* passData, std::vector& array); + void handleCommonErrorEvent(void* userData, unsigned int code, std::string msg); + std::string convertIntToString(unsigned int data); static std::vector m_currentReqIds; diff --git a/src/Messaging/MessagingService.cpp b/src/Messaging/MessagingService.cpp index eef97fa..8bb5ec1 100644 --- a/src/Messaging/MessagingService.cpp +++ b/src/Messaging/MessagingService.cpp @@ -113,13 +113,14 @@ int MessagingService::createOpId(int type) lastIndex = it->first; } - if ( (cnt * MESSAGING_SERVICE_OP_COUNT) >= lastIndex ) + if ( (cnt * MESSAGING_SERVICE_OP_COUNT) > lastIndex ) { index = ( lastIndex + MESSAGING_SERVICE_OP_COUNT - ( lastIndex % MESSAGING_SERVICE_OP_COUNT) ) + type; } else { int preValue = 0; + bool checkFirstEmpty = TRUE; OpRequestsIterator iter; @@ -127,19 +128,25 @@ int MessagingService::createOpId(int type) { int currentValue = iter->first; - if ( currentValue - preValue > MESSAGING_SERVICE_OP_COUNT) + if(checkFirstEmpty ==TRUE && currentValue >= MESSAGING_SERVICE_OP_COUNT) { - index = ( preValue + MESSAGING_SERVICE_OP_COUNT - ( preValue % MESSAGING_SERVICE_OP_COUNT) ) + type; + index = type; break; } + checkFirstEmpty = FALSE; + + if ( currentValue - preValue < MESSAGING_SERVICE_OP_COUNT*2 ) + { + preValue = currentValue - ( currentValue % MESSAGING_SERVICE_OP_COUNT); + } else { - index = ( currentValue + MESSAGING_SERVICE_OP_COUNT - ( currentValue % MESSAGING_SERVICE_OP_COUNT) ) + type; + index = preValue + MESSAGING_SERVICE_OP_COUNT + type; + break; } } } - } else { @@ -253,7 +260,7 @@ void MessagingService::setEventToOpId(int opIdx, EventMessagingServicePtr & even if ( m_opRequests.end() != it) { - LoggerD("set Message "); + LoggerD("set event "); if (event) { LoggerD("vaild event "); diff --git a/src/Notification/StatusNotification.cpp b/src/Notification/StatusNotification.cpp index 86249e7..ecd5b2c 100755 --- a/src/Notification/StatusNotification.cpp +++ b/src/Notification/StatusNotification.cpp @@ -1789,7 +1789,7 @@ bool StatusNotification::isColorFormatNumberic(std::string& color) std::string hexCode = "0123456789abcdef"; if (color.length() == 7 && !color.compare(0, 1, "#") ) { - for ( int i = 1 ; i < color.length() ; i++) + for ( size_t i = 1 ; i < color.length() ; i++) { if (std::string::npos == hexCode.find(color[i])) return false; @@ -1834,7 +1834,7 @@ void StatusNotification::setLight(std::string color) LoggerI("color.length()=" << color.length()); if (color.length() == 0) { - if (notification_set_led(m_notiHandle, NOTIFICATION_LED_OP_OFF, NULL) != NOTIFICATION_ERROR_NONE) + if (notification_set_led(m_notiHandle, NOTIFICATION_LED_OP_OFF, 0) != NOTIFICATION_ERROR_NONE) { throw UnknownException("set notification led "); } diff --git a/src/SecureElement/JSSEChannel.cpp b/src/SecureElement/JSSEChannel.cpp old mode 100644 new mode 100755 index 7de6c27..16aa6fd --- a/src/SecureElement/JSSEChannel.cpp +++ b/src/SecureElement/JSSEChannel.cpp @@ -239,7 +239,7 @@ JSValueRef JSSEChannel::transmit(JSContextRef context, EventSEChannelTransmitPtr event(new EventSEChannelTransmit(convert.toVectorOfUChars(arguments[0]))); event->setPrivateData( DPL::StaticPointerCast(callbackManager) ); event->setForAsynchronousCall(&SEResponseDispatcher::getInstance()); - + callbackManager->setObject(thisObject); seChannel->transmit(event); SEAsyncCallbackManagerSingleton::Instance().registerCallbackManager(callbackManager, privateObject->getContext()); diff --git a/src/SecureElement/JSSEReader.cpp b/src/SecureElement/JSSEReader.cpp old mode 100644 new mode 100755 index 0241dc5..638d780 --- a/src/SecureElement/JSSEReader.cpp +++ b/src/SecureElement/JSSEReader.cpp @@ -227,7 +227,7 @@ JSValueRef JSSEReader::openSession(JSContextRef context, EventSEOpenSessionPtr event(new EventSEOpenSession()); event->setPrivateData( DPL::StaticPointerCast(callbackManager) ); event->setForAsynchronousCall(&SEResponseDispatcher::getInstance()); - + callbackManager->setObject(thisObject); seReader->openSession(event); SEAsyncCallbackManagerSingleton::Instance().registerCallbackManager(callbackManager, privateObject->getContext()); diff --git a/src/SecureElement/JSSEService.cpp b/src/SecureElement/JSSEService.cpp index ec90166..903179b 100755 --- a/src/SecureElement/JSSEService.cpp +++ b/src/SecureElement/JSSEService.cpp @@ -169,9 +169,9 @@ JSValueRef JSSEService::getReaders(JSContextRef context, JSCallbackManagerPtr callbackManager = JSCallbackManager::createObject(privateObject->getContext(), onSuccessForCbm, onErrorForCbm, true, true); Try { EventListSEsPtr event(new EventListSEs()); - event->setPrivateData( DPL::StaticPointerCast(callbackManager) ); + event->setPrivateData( DPL::StaticPointerCast(callbackManager)); event->setForAsynchronousCall(&SEResponseDispatcher::getInstance()); - + callbackManager->setObject(thisObject); seService->getReaders(event); SEAsyncCallbackManagerSingleton::Instance().registerCallbackManager(callbackManager, privateObject->getContext()); diff --git a/src/SecureElement/JSSESession.cpp b/src/SecureElement/JSSESession.cpp old mode 100644 new mode 100755 index a063acf..d01b191 --- a/src/SecureElement/JSSESession.cpp +++ b/src/SecureElement/JSSESession.cpp @@ -294,7 +294,7 @@ JSValueRef JSSESession::openBasicChannel(JSContextRef context, EventSEOpenChannelPtr event(new EventSEOpenChannel(aid, true)); event->setPrivateData( DPL::StaticPointerCast(callbackManager) ); event->setForAsynchronousCall(&SEResponseDispatcher::getInstance()); - + callbackManager->setObject(thisObject); seSession->openChannel(event); SEAsyncCallbackManagerSingleton::Instance().registerCallbackManager(callbackManager, privateObject->getContext()); @@ -367,7 +367,7 @@ JSValueRef JSSESession::openLogicalChannel(JSContextRef context, EventSEOpenChannelPtr event(new EventSEOpenChannel(aid, false)); event->setPrivateData( DPL::StaticPointerCast(callbackManager) ); event->setForAsynchronousCall(&SEResponseDispatcher::getInstance()); - + callbackManager->setObject(thisObject); seSession->openChannel(event); SEAsyncCallbackManagerSingleton::Instance().registerCallbackManager(callbackManager, privateObject->getContext()); diff --git a/src/Systeminfo/JSDeviceCapabilitiesInfo.cpp b/src/Systeminfo/JSDeviceCapabilitiesInfo.cpp index e2117d7..565de6f 100755 --- a/src/Systeminfo/JSDeviceCapabilitiesInfo.cpp +++ b/src/Systeminfo/JSDeviceCapabilitiesInfo.cpp @@ -627,7 +627,7 @@ JSValueRef JSDeviceCapabilitiesInfo::getProperty(JSContextRef context, JSObjectR return convert.toJSValueRef(deviceCapabilitiesInfo->platformCoreCpuArch); } else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_PLATFORMCOREFPUARCH)) { bool fpuArch = false; - bool data = true; + bool data = false; char* platformCoreFpuArch = NULL; char platformCoreFpuArchFull[MAXBUFSIZE]; platformCoreFpuArchFull[0] = '\0'; @@ -670,7 +670,7 @@ JSValueRef JSDeviceCapabilitiesInfo::getProperty(JSContextRef context, JSObjectR return JSValueMakeUndefined(context); } - deviceCapabilitiesInfo->platformCoreCpuArch = platformCoreFpuArch; + deviceCapabilitiesInfo->platformCoreFpuArch = platformCoreFpuArch; free(platformCoreFpuArch); return convert.toJSValueRef(deviceCapabilitiesInfo->platformCoreFpuArch); diff --git a/src/Systeminfo/Systeminfo.cpp b/src/Systeminfo/Systeminfo.cpp index 05fc1a3..8f49a1c 100755 --- a/src/Systeminfo/Systeminfo.cpp +++ b/src/Systeminfo/Systeminfo.cpp @@ -606,36 +606,36 @@ void Systeminfo::OnRequestReceived(const EventGetSysteminfoPtr& event) switch(simCardState) { case TAPI_SIM_STATUS_CARD_NOT_PRESENT : case TAPI_SIM_STATUS_CARD_REMOVED : - simState = "ABSENT"; + simState = strdup("ABSENT"); break; case TAPI_SIM_STATUS_SIM_INITIALIZING : - simState = "INITIALIZING"; + simState = strdup("INITIALIZING"); break; case TAPI_SIM_STATUS_SIM_INIT_COMPLETED : - simState = "READY"; + simState = strdup("READY"); break; case TAPI_SIM_STATUS_SIM_PIN_REQUIRED : - simState = "PIN_REQUIRED"; + simState = strdup("PIN_REQUIRED"); break; case TAPI_SIM_STATUS_SIM_PUK_REQUIRED : - simState = "PUK_REQUIRED"; + simState = strdup("PUK_REQUIRED"); break; case TAPI_SIM_STATUS_SIM_LOCK_REQUIRED : case TAPI_SIM_STATUS_CARD_BLOCKED : - simState = "SIM_LOCKED"; + simState = strdup("SIM_LOCKED"); break; case TAPI_SIM_STATUS_SIM_NCK_REQUIRED : case TAPI_SIM_STATUS_SIM_NSCK_REQUIRED : - simState = "NETWORK_LOCKED"; - break; - case TAPI_SIM_STATUS_UNKNOWN : - case TAPI_SIM_STATUS_CARD_ERROR : - //case TAPI_SIM_STATUS_CARD_CRASHED : - default: - simState = "UNKNOWN"; - break; + simState = strdup("NETWORK_LOCKED"); + break; + default: + simState = strdup("UNKNOWN"); + break; } + LoggerD("simState : " << simState); event->setSimState(simState); + if (simState) + free(simState); if(strcmp(simState, "READY") == 0) { if (tel_get_sim_imsi(m_tapiHandle, &imsi) == TAPI_API_SUCCESS) { LoggerD("mcc : " << imsi.szMcc << " mnc : " << imsi.szMnc << " msin : " << imsi.szMsin); @@ -651,8 +651,10 @@ void Systeminfo::OnRequestReceived(const EventGetSysteminfoPtr& event) tel_get_sim_iccid(m_tapiHandle, SimIccidValueCallback, iccidPendingEvent); SysteminfoAsyncPendingEvent *spnPendingEvent = new SysteminfoAsyncPendingEvent((void *)this, event); tel_get_sim_spn(m_tapiHandle, SimSpnValueCallback, spnPendingEvent); + } else { + event->makeSimObject(); + EventRequestReceiver::ManualAnswer(event); } - LoggerD("test"); } else { LoggerE("get fail sim state"); } diff --git a/src/Tizen/AnyFactory.cpp b/src/Tizen/AnyFactory.cpp index 9e4a19d..6b46eba 100644 --- a/src/Tizen/AnyFactory.cpp +++ b/src/Tizen/AnyFactory.cpp @@ -45,7 +45,6 @@ public: private: bool isDate(JSContextRef jsContext, JSValueRef jsValue) const; - std::tm *toDateTm(time_t time) const; std::string toJSON(JSContextRef jsContext, JSValueRef jsValue) const; std::string toString(JSContextRef jsContext, JSValueRef jsValue) const; }; @@ -88,7 +87,10 @@ PrivateAny::PrivateAny(JSContextRef context, const JSValueRef value, PrimitiveTy *m_value.str = JSUtil::JSValueToString(context, value); } else if(type == PrimitiveType_Time) - m_value.t = toDateTm(JSUtil::JSValueToTimeT(context, value)); + { + m_value.t = new std::tm; + *m_value.t = JSUtil::JSValueToDateTm(context, value); + } } catch(BasePlatformException &e) { @@ -133,28 +135,6 @@ bool PrivateAny::isDate(JSContextRef jsContext, JSValueRef jsValue) const return JSValueIsInstanceOfConstructor(jsContext, jsValue, jsObjectDate, NULL); } -std::tm * PrivateAny::toDateTm(time_t time) const -{ - char* currentLocale = setlocale(LC_TIME, NULL); - if (currentLocale == NULL) - throw UnknownException("Fail to get current locale"); - char* currentLocaleDup = strdup(currentLocale); - if (currentLocaleDup == NULL) - throw UnknownException("Fail to dup current locale"); - if (setlocale(LC_TIME, "C") == NULL) - throw UnknownException("Fail to set locale"); - - std::tm *timeTm = new std::tm; - memcpy(timeTm, localtime(&time), sizeof(std::tm)); - - if (setlocale(LC_TIME, currentLocaleDup) == NULL) - throw UnknownException("Fail to set locale"); - - free(currentLocaleDup); - - return timeTm; -} - std::string PrivateAny::toJSON(JSContextRef context, JSValueRef value) const { JSValueRef jsError = NULL; diff --git a/src/Tizen/JSAttributeFilter.cpp b/src/Tizen/JSAttributeFilter.cpp index cf8b90f..882f600 100644 --- a/src/Tizen/JSAttributeFilter.cpp +++ b/src/Tizen/JSAttributeFilter.cpp @@ -149,7 +149,8 @@ JSObjectRef JSAttributeFilter::constructor(JSContextRef context, } catch(BasePlatformException &e) { - return JSWebAPIErrorFactory::postException(context, exception, e); + LoggerW("Failed to convert 1st parameter to string. Using default value."); + attributeName = ""; } try @@ -179,7 +180,8 @@ JSObjectRef JSAttributeFilter::constructor(JSContextRef context, } catch(BasePlatformException &e) { - return JSWebAPIErrorFactory::postException(context, exception, e); + LoggerW("Failed to convert 2nd parameter to match flag. Using default value."); + matchFlag = MATCH_EXACTLY; } matchValue = AnyFactory::createAnyEmpty(context); @@ -191,7 +193,7 @@ JSObjectRef JSAttributeFilter::constructor(JSContextRef context, AttributeFilterPtr attributeFilter(new AttributeFilter(attributeName, matchFlag, matchValue)); - JSObjectRef jsobject; + JSObjectRef jsobject = NULL; Try { @@ -200,10 +202,11 @@ JSObjectRef JSAttributeFilter::constructor(JSContextRef context, Catch(Exception) { LoggerE("Argument type mismatch : " << _rethrown_exception.GetMessage()); - return JSWebAPIErrorFactory::postException(context, exception, - TypeMismatchException("Error occurred while creating object")); } + if(jsobject == NULL) + return JSObjectMake(context, NULL, NULL); + return jsobject; } diff --git a/src/Tizen/JSAttributeRangeFilter.cpp b/src/Tizen/JSAttributeRangeFilter.cpp index 97eb7fb..fafd903 100644 --- a/src/Tizen/JSAttributeRangeFilter.cpp +++ b/src/Tizen/JSAttributeRangeFilter.cpp @@ -150,7 +150,8 @@ JSObjectRef JSAttributeRangeFilter::constructor(JSContextRef context, } catch(BasePlatformException &e) { - return JSWebAPIErrorFactory::postException(context, exception, e); + LoggerW("Failed to convert 1st parameter to string. Using default value."); + attributeName = ""; } initialValue = AnyFactory::createAnyEmpty(context); @@ -169,7 +170,7 @@ JSObjectRef JSAttributeRangeFilter::constructor(JSContextRef context, AttributeRangeFilterPtr attributeRangeFilter(new AttributeRangeFilter(attributeName, initialValue, endValue)); - JSObjectRef jsobject; + JSObjectRef jsobject = NULL; Try { @@ -178,10 +179,11 @@ JSObjectRef JSAttributeRangeFilter::constructor(JSContextRef context, Catch(Exception) { LoggerE("Argument type mismatch : " << _rethrown_exception.GetMessage()); - return JSWebAPIErrorFactory::postException(context, exception, - TypeMismatchException("Error occurred while creating object")); } + if(jsobject == NULL) + return JSObjectMake(context, NULL, NULL); + return jsobject; } diff --git a/src/Tizen/JSCompositeFilter.cpp b/src/Tizen/JSCompositeFilter.cpp index 306dc8b..51e11a1 100644 --- a/src/Tizen/JSCompositeFilter.cpp +++ b/src/Tizen/JSCompositeFilter.cpp @@ -149,7 +149,8 @@ JSObjectRef JSCompositeFilter::constructor(JSContextRef context, } catch(BasePlatformException &e) { - return JSWebAPIErrorFactory::postException(context, exception, e); + LoggerW("Failed to convert 1st parameter to filter type. Using default value."); + type = UNION_FILTER; } try @@ -165,12 +166,13 @@ JSObjectRef JSCompositeFilter::constructor(JSContextRef context, } catch(BasePlatformException &e) { - return JSWebAPIErrorFactory::postException(context, exception, e); + LoggerW("Failed to convert 2nd parameter to filter array. Using default value."); + jsValueFilters = JSCreateArrayObject(context, 0, NULL); } CompositeFilterPtr compositeFilter(new CompositeFilter(type, FilterArrayPtr(new FilterArray()))); - JSObjectRef jsobject; + JSObjectRef jsobject = NULL; Try { @@ -179,10 +181,11 @@ JSObjectRef JSCompositeFilter::constructor(JSContextRef context, Catch(Exception) { LoggerE("Argument type mismatch : " << _rethrown_exception.GetMessage()); - return JSWebAPIErrorFactory::postException(context, exception, - TypeMismatchException("Error occurred while creating object")); } + if(jsobject == NULL) + return JSObjectMake(context, NULL, NULL); + return jsobject; } diff --git a/src/Tizen/JSSimpleCoordinates.cpp b/src/Tizen/JSSimpleCoordinates.cpp index 256deb3..4fcd71a 100644 --- a/src/Tizen/JSSimpleCoordinates.cpp +++ b/src/Tizen/JSSimpleCoordinates.cpp @@ -133,16 +133,26 @@ JSObjectRef JSSimpleCoordinates::constructor(JSContextRef context, try { latitude = validator.toDouble(0, false); + } + catch(BasePlatformException &e) + { + LoggerW("Failed to convert 1st parameter to double. Using default value."); + latitude = 0.0; + } + + try + { longitude = validator.toDouble(1, false); } catch(BasePlatformException &e) { - return JSWebAPIErrorFactory::postException(context, exception, e); + LoggerW("Failed to convert 2nd parameter to double. Using default value."); + longitude = 0.0; } SimpleCoordinatesPtr simpleCoordinates(new SimpleCoordinates(latitude, longitude)); - JSObjectRef jsobject; + JSObjectRef jsobject = NULL; Try { @@ -151,10 +161,11 @@ JSObjectRef JSSimpleCoordinates::constructor(JSContextRef context, Catch(Exception) { LoggerE("Argument type mismatch : " << _rethrown_exception.GetMessage()); - return JSWebAPIErrorFactory::postException(context, exception, - TypeMismatchException("Error occurred while creating object")); } + if(jsobject == NULL) + return JSObjectMake(context, NULL, NULL); + return jsobject; } diff --git a/src/Tizen/JSSortMode.cpp b/src/Tizen/JSSortMode.cpp index 3f3cfc8..3d6e41d 100644 --- a/src/Tizen/JSSortMode.cpp +++ b/src/Tizen/JSSortMode.cpp @@ -135,7 +135,8 @@ JSObjectRef JSSortMode::constructor(JSContextRef context, } catch(BasePlatformException &e) { - return JSWebAPIErrorFactory::postException(context, exception, e); + LoggerW("Failed to convert 1st parameter to string. Using default value."); + attributeName = ""; } try @@ -157,12 +158,13 @@ JSObjectRef JSSortMode::constructor(JSContextRef context, } catch(BasePlatformException &e) { - return JSWebAPIErrorFactory::postException(context, exception, e); + LoggerW("Failed to convert 2nd parameter to sort order. Using default value."); + sortOrder = ASCENDING_SORT_ORDER; } SortModePtr sortMode(new SortMode(attributeName, sortOrder)); - JSObjectRef jsobject; + JSObjectRef jsobject = NULL; Try { @@ -171,10 +173,11 @@ JSObjectRef JSSortMode::constructor(JSContextRef context, Catch(Exception) { LoggerE("Argument type mismatch : " << _rethrown_exception.GetMessage()); - return JSWebAPIErrorFactory::postException(context, exception, - TypeMismatchException("Error occurred while creating object")); } + if(jsobject == NULL) + return JSObjectMake(context, NULL, NULL); + return jsobject; } diff --git a/src/Tizen/JSTizen.cpp b/src/Tizen/JSTizen.cpp index e656b09..3b87f27 100644 --- a/src/Tizen/JSTizen.cpp +++ b/src/Tizen/JSTizen.cpp @@ -22,7 +22,6 @@ * @brief */ -#include #include #include #include diff --git a/src/WebSetting/JSWebSettingManager.cpp b/src/WebSetting/JSWebSettingManager.cpp index fb19d37..d0b45e6 100755 --- a/src/WebSetting/JSWebSettingManager.cpp +++ b/src/WebSetting/JSWebSettingManager.cpp @@ -15,18 +15,17 @@ // limitations under the License. // -#include -#include -#include #include #include +#include +#include +#include #include #include -#include +#include #include "plugin_config.h" - #include "JSWebSettingManager.h" using namespace WrtDeviceApis::Commons; @@ -78,22 +77,19 @@ const JSClassDefinition* JSWebSettingManager::getClassInfo() void JSWebSettingManager::initialize(JSContextRef context, JSObjectRef object) { - SLoggerI("JSWebSettingManager::initialize: called once when the .so loaded for the web app"); if (!JSObjectGetPrivate(object)) { - WebSettingManager *priv = new WebSettingManager(); - if (!JSObjectSetPrivate(object, static_cast(priv))) { - delete priv; - } + SLoggerI("JSWebSettingManager::initialize called..."); + WebSettingManager *priv = WebSettingManager::getInstance(); + JSObjectSetPrivate(object, static_cast(priv)); } } void JSWebSettingManager::finalize(JSObjectRef object) { - SLoggerI("JSWebSettingManager::initialize: called once when the .so unloaded for the web app"); + SLoggerI("JSWebSettingManager::finalize called..."); WebSettingManager *priv = static_cast(JSObjectGetPrivate(object)); if (priv) { JSObjectSetPrivate(object, NULL); - delete priv; } } @@ -111,7 +107,7 @@ JSValueRef JSWebSettingManager::setUserAgentString(JSContextRef context, throw TypeMismatchException("Private object is NULL."); } ArgumentValidator validator(context, argumentCount, arguments); - MultiCallbackUserDataPtr callbacks(new MultiCallbackUserData(GlobalContextManager::getInstance()->getGlobalContext(context))); + MultiCallbackUserData* callbacks = new MultiCallbackUserData(GlobalContextManager::getInstance()->getGlobalContext(context)); // userAgent std::string userAgent = validator.toString(0); @@ -161,7 +157,7 @@ JSValueRef JSWebSettingManager::removeAllCookies(JSContextRef context, } ArgumentValidator validator(context, argumentCount, arguments); - MultiCallbackUserDataPtr callbacks(new MultiCallbackUserData(GlobalContextManager::getInstance()->getGlobalContext(context))); + MultiCallbackUserData* callbacks = new MultiCallbackUserData(GlobalContextManager::getInstance()->getGlobalContext(context)); // successCallback JSObjectRef successCallbackObj = validator.toFunction(0, true); diff --git a/src/WebSetting/WebSettingManager.cpp b/src/WebSetting/WebSettingManager.cpp index ce64957..65200f4 100755 --- a/src/WebSetting/WebSettingManager.cpp +++ b/src/WebSetting/WebSettingManager.cpp @@ -29,88 +29,81 @@ namespace DeviceAPI { namespace WebSetting { +std::list WebSettingManager::mUserAgentCallbacks; +std::list WebSettingManager::mDeleteAllCookiesCallbacks; + WebSettingManager::WebSettingManager() { + SLoggerI("Constructor of WebSettingManager..."); } WebSettingManager::~WebSettingManager() { + SLoggerI("Desstructor of WebSettingManager..."); +} + +WebSettingManager* WebSettingManager::getInstance() +{ + SLoggerI("Getting instance of WebSettingManager..."); + static WebSettingManager instance; + return &instance; } void WebSettingManager::onAsyncUAStringReplyCallback(unsigned int num, void* user_data, const char* result) { - WebSettingManager* object = static_cast(user_data); - - if (strncmp(result,"success", strlen("success")) == 0) { - //invoke success callback here. - if (object->mSetUserAgentCallbacks != NULL ){ - SLoggerI("[WebSettingManager::onAsyncReplyCallback] onsuccess start. "); - object->mSetUserAgentCallbacks->invokeCallback("onsuccess", NULL); - SLoggerI("[WebSettingManager::onAsyncReplyCallback] onsuccess end. "); - } - else { - SLoggerI("[WebSettingManager::onAsyncReplyCallback] object->mSetUserAgentCallbacks is NULL so no callback can be invoked." << __LINE__);; + MultiCallbackUserData* multiPointer = static_cast(user_data); + if (multiPointer != NULL) { + int successStrLength = strlen("success"); + if ((strncmp(result,"success", successStrLength)== 0) && (strlen(result) == successStrLength)) { + multiPointer->invokeCallback("onsuccess", NULL); } - } - else { - if (object->mSetUserAgentCallbacks != NULL ) { - SLoggerI("[WebSettingManager::onAsyncReplyCallback] onerror start. "); + else { UnknownException error("Unknown"); - JSObjectRef errorObj = JSWebAPIErrorFactory::makeErrorObject(object->mSetUserAgentCallbacks->getContext(), error); - object->mSetUserAgentCallbacks->invokeCallback("onerror", errorObj); - SLoggerI("[WebSettingManager::onAsyncReplyCallback] onerror end. "); - } - else { - SLoggerI("[WebSettingManager::onAsyncReplyCallback] object->mSetUserAgentCallbacks is NULL so no callback can be invoked." << __LINE__);; - } - } + JSObjectRef errorObj = JSWebAPIErrorFactory::makeErrorObject(multiPointer->getContext(), error); + multiPointer->invokeCallback("onerror", errorObj); + } + WebSettingManager::mUserAgentCallbacks.remove(multiPointer); + delete multiPointer;; + } + else { + SLoggerI("[WebSettingManager::onAsyncUAStringReplyCallback] Warning. MultiCallbackUserData is NULL." << __LINE__);; + } } void WebSettingManager::onAsyncReplyRemoveAllCookiesCallback(unsigned int num, void* user_data, const char* result) { - WebSettingManager* object = static_cast(user_data); - - if (strncmp(result,"success", strlen("success")) == 0) { - //invoke success callback here. - if (object->mRemoveAllCookiesCallbacks != NULL ) { - SLoggerI("[WebSettingManager::onAsyncReplyCallback] onsuccess start. "); - object->mRemoveAllCookiesCallbacks->invokeCallback("onsuccess", NULL); - SLoggerI("[WebSettingManager::onAsyncReplyCallback] onsuccess end. "); - } - else { - SLoggerI("[WebSettingManager::onAsyncReplyCallback] object->mSetUserAgentCallbacks is NULL so no callback can be invoked." << __LINE__);; - } - } - else { - if (object->mRemoveAllCookiesCallbacks != NULL) { - SLoggerI("[WebSettingManager::onAsyncReplyCallback] onerror start. "); + MultiCallbackUserData* multiPointer = static_cast(user_data); + if (multiPointer != NULL) { + int successStrLength = strlen("success"); + if ((strncmp(result,"success", successStrLength)== 0) && (strlen(result) == successStrLength)) { + multiPointer->invokeCallback("onsuccess", NULL); + } + else { UnknownException error("Unknown"); - JSObjectRef errorObj = JSWebAPIErrorFactory::makeErrorObject(object->mSetUserAgentCallbacks->getContext(), error); - object->mRemoveAllCookiesCallbacks->invokeCallback("onerror", errorObj); - SLoggerI("[WebSettingManager::onAsyncReplyCallback] onerror end. "); - } - else { - SLoggerI("[WebSettingManager::onAsyncReplyCallback] object->mSetUserAgentCallbacks is NULL so no callback can be invoked." << __LINE__);; - } - } + JSObjectRef errorObj = JSWebAPIErrorFactory::makeErrorObject(multiPointer->getContext(), error); + multiPointer->invokeCallback("onerror", errorObj); + } + WebSettingManager::mDeleteAllCookiesCallbacks.remove(multiPointer); + delete multiPointer;; + } + else { + SLoggerI("[WebSettingManager::onAsyncReplyRemoveAllCookiesCallback] Warning. MultiCallbackUserData is NULL." << __LINE__);; + } } -void WebSettingManager::setUserAgentString(std::string userAgent, MultiCallbackUserDataPtr callbacks) +void WebSettingManager::setUserAgentString(std::string userAgent, MultiCallbackUserData* callbacks) { SLoggerI("WebSetting:setUserAgentString: " << userAgent); - mSetUserAgentCallbacks = callbacks; - IPCMessageSupport::sendAsyncMessageToUiProcess(IPCMessageSupport::TIZEN_CHANGE_USERAGENT, userAgent.c_str(), WebSettingManager::onAsyncUAStringReplyCallback, this); - //IPCMessageSupport::sendAsyncMessageToUiProcess("tizen://changeUA", "Mozilla/5.0 ~", WebSettingManager::onAsyncReplyCallback, this); - SLoggerI("WebSetting:setUserAgentString done"); + WebSettingManager::mUserAgentCallbacks.push_back(callbacks); + IPCMessageSupport::sendAsyncMessageToUiProcess(IPCMessageSupport::TIZEN_CHANGE_USERAGENT, userAgent.c_str(), WebSettingManager::onAsyncUAStringReplyCallback, callbacks); } -void WebSettingManager::removeAllCookies(MultiCallbackUserDataPtr callbacks) +void WebSettingManager::removeAllCookies(MultiCallbackUserData* callbacks) { SLoggerI("WebSetting:removeAllCookies: "); - mRemoveAllCookiesCallbacks = callbacks; - IPCMessageSupport::sendAsyncMessageToUiProcess(IPCMessageSupport::TIZEN_DELETE_ALL_COOKIES, NULL, WebSettingManager::onAsyncReplyRemoveAllCookiesCallback, this); - SLoggerI("WebSetting:removeAllCookies done"); -} // WebSetting + WebSettingManager::mDeleteAllCookiesCallbacks.push_back(callbacks); + IPCMessageSupport::sendAsyncMessageToUiProcess(IPCMessageSupport::TIZEN_DELETE_ALL_COOKIES, NULL, WebSettingManager::onAsyncReplyRemoveAllCookiesCallback, callbacks); +} -} // DeviceAPI +} } diff --git a/src/WebSetting/WebSettingManager.h b/src/WebSetting/WebSettingManager.h index a3942af..bc75787 100755 --- a/src/WebSetting/WebSettingManager.h +++ b/src/WebSetting/WebSettingManager.h @@ -19,8 +19,8 @@ #define __TIZEN_WEB_SETTING_MANAGER_H__ #include - #include "WebSettingTypes.h" +#include using namespace DeviceAPI::Common; @@ -30,15 +30,18 @@ namespace WebSetting { class WebSettingManager { public: - WebSettingManager(); - virtual ~WebSettingManager(); - void setUserAgentString(std::string userAgent, MultiCallbackUserDataPtr callbacks); - void removeAllCookies(MultiCallbackUserDataPtr callbacks); - Common::MultiCallbackUserDataPtr mSetUserAgentCallbacks; - Common::MultiCallbackUserDataPtr mRemoveAllCookiesCallbacks; + void setUserAgentString(std::string userAgent, MultiCallbackUserData* callbacks); + void removeAllCookies(MultiCallbackUserData* callbacks); + + static std::list mUserAgentCallbacks; + static std::list mDeleteAllCookiesCallbacks; + static void onAsyncUAStringReplyCallback(unsigned int num, void* user_data, const char* result); static void onAsyncReplyRemoveAllCookiesCallback(unsigned int num, void* user_data, const char* result); + static WebSettingManager* getInstance(); private: + WebSettingManager(); + virtual ~WebSettingManager(); }; } // WebSetting