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
LoggerW("userData is NULL");
return;
}
-
+
+ LoggerD("changed name: " << std::string(name));
// call onnamechanged in ChangeListener
if(object->mChangeListener != NULL) {
LoggerD("call onnamechanged in ChangeListener");
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;
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;
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}
#include "BluetoothAdapter.h"
#include "JSBluetoothHealthProfileHandler.h"
+#include <system_info.h>
#include <TimeTracer.h>
#include <Logger.h>
const JSValueRef arguments[],
JSValueRef* exception)
{
+ LoggerD("Enter");
+
TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 1);
// Access Check
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
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 ){
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;
}
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;
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);
return JSArrayToType_<bool>(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;
+}
}
}
#include <map>
#include <vector>
#include "PlatformException.h"
-#include <time.h>
+#include <ctime>
namespace DeviceAPI {
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.
return jsResult;
};
+private:
+ static bool JSValueIsDateObject(JSContextRef ctx, JSValueRef jsValue);
};
}}
//
#include "JSWebAPIErrorFactory.h"
+
#include <map>
-#include <dpl/assert.h>
+
#include "JSStringRefWrapper.h"
#include "JSWebAPIException.h"
#include "JSWebAPIError.h"
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);
JSValueRef* exception,
const BasePlatformException& error)
{
- Assert(exception && "Exception object can't be NULL.");
-
return postException(context, exception, error.getName(), error.getMessage());
}
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())
JSValueRef StandaloneConsole::RunLineEx(const char* line, JSValueRef *exception){
JSStringRef jsScript = JSStringCreateWithUTF8CString(line);
int size = strlen(line);
- if( size != JSStringGetLength(jsScript) ){
+ if( size != static_cast <int>(JSStringGetLength(jsScript))){
cout <<"error - fail to converting JSStringRef"<<endl;
}
JSValueRef ret = JSEvaluateScript(mGlobalContext, jsScript, NULL, NULL, 0, exception);
ContactObjectP2AConverterPtr contactObjConverterForInserted(
new ContactObjectP2AConverter(get_contacts_record, false));
ContactPtr insertedContact = contactObjConverterForInserted->getAbstractContact();
- contact->copy(insertedContact);
+ contact->copy(insertedContact);
event->setResult(true);
event->setExceptionCode(ExceptionCodes::None);
}
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<Contact> newContactT =
+ DPL::StaticPointerCast<Contact>(contact);
+ contacts_record = newContactT->getPlatformContactObject();
+ if(contacts_record == NULL)
{
- DPL::SharedPtr<Contact> newContactT =
- DPL::StaticPointerCast<Contact>(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<long, EventAddressBookAddBatchPtr> 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<long, EventAddressBookAddBatchPtr> keyEventPair(m_eventMapAcc, event);
+ m_addBatchEventMap.insert(keyEventPair);
+
+ m_eventMapAcc++;
+
}
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());
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();
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<Contact> newContactT = DPL::StaticPointerCast<Contact>(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<Contact> newContactT =
- DPL::StaticPointerCast<Contact>(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<long, EventAddressBookUpdateBatchPtr> 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<long, EventAddressBookUpdateBatchPtr> keyEventPair(m_eventMapAcc, event);
+ m_updateBatchEventMap.insert(keyEventPair);
+
+ m_eventMapAcc++;
}
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);
}
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<long, EventAddressBookRemoveBatchPtr> keyEventPair(m_eventMapAcc, event);
+ m_removeBatchEventMap.insert(keyEventPair);
- pair<long, EventAddressBookRemoveBatchPtr> 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)
{
m_postalCode = "";
m_postalCodeIsSet = false;
+ m_label = "";
+ m_labelIsSet = false;
+
m_isDefault = false;
m_types = ContactAddressTypeArrayPtr(new ContactAddressTypeArray());
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++)
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;
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();
ContactAddressTypeArrayPtr m_types;
+ std::string m_label;
+ bool m_labelIsSet;
+
bool is_typesSetJSArray;
JSValueRef m_typesJsValue;
JSObjectRef m_typesObj;
#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"
#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"
#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"
#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 {
ContactPtr tmpContactObj = toContact(element);
duplicate = false;
- for(int j=0; j<result->size(); j++){
+ for(unsigned int j=0; j<result->size(); j++){
if(result->at(j) == tmpContactObj)
duplicate = true;
}
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);
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;
std::string lastName;
StringArrayPtr nicknames;
std::string phoneticFirstName;
+ std::string phoneticMiddleName;
std::string phoneticLastName;
ContactNamePtr result = ContactNamePtr(new ContactName());
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");
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);
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) {
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;
}
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);
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;
std::string postalCode;
bool isDefault;
ContactAddressTypeArrayPtr types;
+ std::string label;
ContactAddressPtr result(new ContactAddress());
if (!result) {
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;
}
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;
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);
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);
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);
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);
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; j<result->size(); j++){
+ if(result->at(j) == tempType)
+ duplicate = true;
+ }
+ if(!duplicate)
+ result->push_back(toContactPhoneNumberType(element));
} Catch (Exception) {
// nothing
}
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);
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);
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; j<result->size(); j++){
+ if(result->at(j) == tempType)
+ duplicate = true;
+ }
+ if(!duplicate)
+ result->push_back(toContactEmailAddressType(element));
+
} Catch (Exception) {
// nothing
}
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);
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);
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;
}
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);
m_email = "";
m_emailIsSet = false;
+ m_label = "";
+ m_labelIsSet = false;
+
m_isDefault = false;
m_types = ContactEmailAddressTypeArrayPtr(new ContactEmailAddressTypeArray());
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++)
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;
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();
ContactEmailAddressTypeArrayPtr m_types;
+ std::string m_label;
+ bool m_labelIsSet;
+
bool is_typesSetJSArray;
JSValueRef m_typesJsValue;
JSObjectRef m_typesObj;
{ "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 },
{ "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 },
{"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},
{"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},
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<long, EventContactManagerUpdateBatchPtr> 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<long, EventContactManagerUpdateBatchPtr> keyEventPair(m_eventMapAcc, event);
+ m_updateBatchEventMap.insert(keyEventPair);
+
+ m_eventMapAcc++;
}
void ContactManager::OnRequestReceived(const EventContactManagerUpdateBatchPtr &event)
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());
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<long, EventContactManagerRemoveBatchPtr> 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<long, EventContactManagerRemoveBatchPtr> keyEventPair(m_eventMapAcc, event);
+ m_removeBatchEventMap.insert(keyEventPair);
+
+ m_eventMapAcc++;
}
void ContactManager::OnRequestReceived(const EventContactManagerRemoveBatchPtr &event)
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);
}
m_middleNameIsSet(false),
m_lastNameIsSet(false),
m_phoneticFirstNameIsSet(false),
+ m_phoneticMiddleNameIsSet(false),
m_phoneticLastNameIsSet(false),
m_displayNameIsSet(false)
{
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;
m_phoneticLastName = "";
m_phoneticLastNameIsSet = false;
+ m_phoneticMiddleName = "";
+ m_phoneticMiddleNameIsSet = false;
+
m_displayName = "";
m_displayNameIsSet = false;
}
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;
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();
std::string m_phoneticFirstName;
bool m_phoneticFirstNameIsSet;
+ std::string m_phoneticMiddleName;
+ bool m_phoneticMiddleNameIsSet;
+
std::string m_phoneticLastName;
bool m_phoneticLastNameIsSet;
}
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
&& ( !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() ) ) )
}
}
+ // 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;
}
}
+ // 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())
{
}
}
+ // 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)
{
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;
}
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)
{
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)
{
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;
}
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)
{
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)
{
bool ctsBoolDefault = address->getIsDefault();
int ctsIntType = 0;
- //char *ctsStrCustomType = NULL;
ContactAddressTypeArray::iterator typesIter = types->begin();
for(; typesIter != types->end(); typesIter++)
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;
}
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)
{
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)
{
string url = webSite->getUrl();
int ctsIntType = 0;
-// char *ctsStrCustomType = NULL;
if(type == WEBSITE_TYPE_HOMEPAGE)
ctsIntType = CONTACTS_URL_TYPE_HOME;
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)
{
#include "Contact.h"
#include "ContactUtility.h"
#include <Logger.h>
+#include <dpl/shared_ptr.h>
namespace DeviceAPI {
namespace Contact {
if(contactName->getPhoneticFirstNameIsSet())
contactName->unsetPhoneticFirstName();
+ if(contactName->getPhoneticMiddleNameIsSet())
+ contactName->unsetPhoneticMiddleName();
+
if(contactName->getPhoneticLastNameIsSet())
contactName->unsetPhoneticLastName();
}
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);
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)
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);
+
}
}
if(m_abstractContact->getPhoneNumbersNum() > 0)
m_abstractContact->clearPhoneNumbers();
+ DPL::SharedPtr<Contact> newContactT = DPL::StaticPointerCast<Contact>(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 << ")");
if (charValue)
{
phoneNumber->setNumber(charValue);
- phoneNumbers->push_back(phoneNumber);
}
else
{
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);
}
}
if(m_abstractContact->getEmailsNum() > 0)
m_abstractContact->clearEmails();
+ DPL::SharedPtr<Contact> newContactT = DPL::StaticPointerCast<Contact>(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 << ")");
if (charValue)
{
email->setEmail(charValue);
- emails->push_back(email);
}
else
{
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);
}
}
if(m_abstractContact->getAddressesNum() > 0)
m_abstractContact->clearAddresses();
+ DPL::SharedPtr<Contact> newContactT = DPL::StaticPointerCast<Contact>(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 << ")");
return;
}
- ContactAddressArrayPtr addresss = m_abstractContact->getAddresses();
+ ContactAddressArrayPtr addresses = m_abstractContact->getAddresses();
for(unsigned int i=0; i<child_count; i++)
{
bool boolValue = false;
int intValue = 0;
- addresss->push_back(address);
-
contacts_record_get_str_p(child_record, _contacts_address.postal_code, &charValue);
if (charValue)
address->setPostalCode(charValue);
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);
}
}
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);
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);
}
}
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
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
#include <string>
#include <vector>
#include <dpl/shared_ptr.h>
+#include "ContactTypes.h"
namespace DeviceAPI {
namespace Contact {
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;
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
m_number = "";
m_numberIsSet = false;
+ m_label = "";
+ m_labelIsSet = false;
+
m_isDefault = false;
m_types = ContactPhoneNumberTypeArrayPtr(new ContactPhoneNumberTypeArray());
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++)
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;
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;
ContactPhoneNumberTypeArrayPtr m_types;
+ std::string m_label;
+ bool m_labelIsSet;
+
bool is_typesSetJSArray;
JSValueRef m_typesJsValue;
JSObjectRef m_typesObj;
{"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 } },
{"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 } },
LoggerD("length : " << length);
if(length != 0)
{
- result = getContacts(m_filteredContactIds);
+ result = getContacts(m_filteredContactIds);
}else{
ContactArrayPtr contacts(new ContactArray());
result = contacts;
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)
{
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;
}
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)
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
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
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
WEBSITE_TYPE_BLOG
};
+enum ContactOrganizationType
+{
+ ORGANIZATION_TYPE_NULL,
+ ORGANIZATION_TYPE_WORK,
+ ORGANIZATION_TYPE_OTHER
+};
+
enum ContactVCardFormat
{
VCARD_30_FORMAT
m_type = WEBSITE_TYPE_HOMEPAGE;
m_typeIsSet = false;
+
+ m_label = "";
+ m_labelIsSet = false;
}
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
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
}
// 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)
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 << ")");
void IAddressBook::add(const EventAddressBookAddPtr &event)
{
+ LoggerD("entered");
//post event to PLATFORM implementation
EventRequestReceiver< EventAddressBookAdd >::PostRequest(event);
}
namespace Contact {
using namespace DeviceAPI::Common;
-using namespace DeviceAPI::Tizen;\rusing namespace WrtDeviceApis::Commons;
+using namespace DeviceAPI::Tizen;
+using namespace WrtDeviceApis::Commons;
using namespace WrtDeviceApis::CommonsJavaScript;
JSClassRef JSAddressBook::m_jsClassRef = NULL;
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;
{
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;
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;
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;
ContactConverterFactory::ConverterType converter =
ContactConverterFactory::getConverter(context);
ContactPtr contact = getPrivData(object);
+
if(!contact->getIdIsSet())
return JSValueMakeNull(context);
else
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";
}
#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 {
{ 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 }
};
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());
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");
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
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
#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 {
{ 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 }
};
std::string email;
ContactEmailAddressTypeArrayPtr types(NULL);
bool isDefault = false;
+ std::string label;
try {
ArgumentValidator Argvalidator(context, argumentCount, arguments);
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;
contactEmailAddress->setEmail(email);
contactEmailAddress->setTypes(types);
contactEmailAddress->setIsDefault(isDefault);
+ contactEmailAddress->setLabel(label);
JSObjectRef jsobject;
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
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
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:
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;
{
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:
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;
}
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());
#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"
{ 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 }
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,
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,
#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 {
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 }
};
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,
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
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,
#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 {
{ 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 }
};
std::string number;
ContactPhoneNumberTypeArrayPtr types(NULL);
bool isDefault = false;
+ std::string label;
try {
ArgumentValidator Argvalidator(context, argumentCount, arguments);
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;
contactPhoneNumber->setNumber(number);
contactPhoneNumber->setTypes(types);
contactPhoneNumber->setIsDefault(isDefault);
+ contactPhoneNumber->setLabel(label);
JSObjectRef jsobject;
ContactConverterFactory::ConverterType converter =
ContactConverterFactory::getConverter(context);
ContactPhoneNumberPtr contactPhoneNumber = getPrivData(object);
+ LoggerD("contactPhoneNumber->getIsDefault() : " << contactPhoneNumber->getIsDefault());
+
return converter->toJSValueRef(contactPhoneNumber->getIsDefault());
}
Catch(WrtDeviceApis::Commons::Exception)
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
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
#define CONTACT_ATTR_URL "url"
#define CONTACT_ATTR_TYPE "type"
+#define CONTACT_ATTR_LABEL "label"
namespace DeviceAPI {
namespace Contact {
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 }
};
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;
ContactWebSitePtr contactWebSite(new ContactWebSite());
contactWebSite->setUrl(url);
contactWebSite->setType(type);
+ contactWebSite->setLabel(label);
JSObjectRef jsobject;
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
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
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;
{"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() :
if(property.type == PrimitiveType_Long)
{
int value = 0;
- if(attrName == "id")
+ if(attrName == "id" || attrName == "displayContactId")
{
string valueStr = matchValue->getString();
value = ContactUtility::strToInt(valueStr);
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)
arr = NULL;
}
+void SQLDataControlConsumer::handleCommonErrorEvent(void* userData, unsigned int code, std::string msg)
+{
+ if (userData == NULL)
+ {
+ LoggerD("userData null");
+ return;
+ }
+
+ CommonPendingEvent* pEvent = (CommonPendingEvent*)userData;
+
+ try
+ {
+ if (dynamic_cast<EventInsertPendingEvent*>(pEvent) != NULL)
+ {
+ EventInsertPendingEvent* pendingInsertEvent = (EventInsertPendingEvent*)pEvent;
+ EventInsertPtr insertEvent = pendingInsertEvent->getEvent();
+ insertEvent->setExceptionCode((WrtDeviceApis::Commons::ExceptionCodes::Enumeration)code);
+ insertEvent->setErrorMsg(msg);
+
+ WrtDeviceApis::Commons::EventRequestReceiver<EventInsert>::ManualAnswer(insertEvent);
+ }
+ else if (dynamic_cast<EventUpdatePendingEvent*>(pEvent) != NULL)
+ {
+ EventUpdatePendingEvent* pendingUpdateEvent = (EventUpdatePendingEvent*)pEvent;
+ EventUpdatePtr updateEvent = pendingUpdateEvent->getEvent();
+ updateEvent->setExceptionCode((WrtDeviceApis::Commons::ExceptionCodes::Enumeration)code);
+ updateEvent->setErrorMsg(msg);
+
+ WrtDeviceApis::Commons::EventRequestReceiver<EventUpdate>::ManualAnswer(updateEvent);
+ }
+ else if (dynamic_cast<EventSelectPendingEvent*>(pEvent) != NULL)
+ {
+ EventSelectPendingEvent* pendingSelectEvent = (EventSelectPendingEvent*)pEvent;
+ EventSelectPtr selectEvent = pendingSelectEvent->getEvent();
+ selectEvent->setExceptionCode((WrtDeviceApis::Commons::ExceptionCodes::Enumeration)code);
+ selectEvent->setErrorMsg(msg);
+
+ WrtDeviceApis::Commons::EventRequestReceiver<EventSelect>::ManualAnswer(selectEvent);
+ }
+ else if (dynamic_cast<EventDeletePendingEvent*>(pEvent) != NULL)
+ {
+ EventDeletePendingEvent* pendingDeleteEvent = (EventDeletePendingEvent*)pEvent;
+ EventDeletePtr deleteEvent = pendingDeleteEvent->getEvent();
+ deleteEvent->setExceptionCode((WrtDeviceApis::Commons::ExceptionCodes::Enumeration)code);
+ deleteEvent->setErrorMsg(msg);
+
+ WrtDeviceApis::Commons::EventRequestReceiver<EventDelete>::ManualAnswer(deleteEvent);
+ }
+ }
+ catch (const WrtDeviceApis::Commons::Exception& ex)
+ {
+ LoggerE("Exception: " << ex.GetMessage());
+ }
+}
void SQLDataControlConsumer::handlePendingEvent(const EventInsertPtr& event)
{
LoggerD("OK");
WrtDeviceApis::Commons::EventRequestReceiver<EventInsert>::ManualAnswer(event);
+ CommonPendingEvent* userData = NULL;
+
try {
- CommonPendingEvent* userData = (CommonPendingEvent*)DataControlAsyncCallbackManagerSingleton::Instance().getRemainingSQLOperation();
+ userData = (CommonPendingEvent*)DataControlAsyncCallbackManagerSingleton::Instance().getRemainingSQLOperation();
if (userData)
{
}
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<EventDelete>::ManualAnswer(event);
+ CommonPendingEvent* userData = NULL;
+
try {
- CommonPendingEvent* userData = (CommonPendingEvent*)DataControlAsyncCallbackManagerSingleton::Instance().getRemainingSQLOperation();
+ userData = (CommonPendingEvent*)DataControlAsyncCallbackManagerSingleton::Instance().getRemainingSQLOperation();
if (userData)
{
}
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 EventSelectPtr& event)
{
WrtDeviceApis::Commons::EventRequestReceiver<EventSelect>::ManualAnswer(event);
+ CommonPendingEvent* userData = NULL;
+
try {
- CommonPendingEvent* userData = (CommonPendingEvent*)DataControlAsyncCallbackManagerSingleton::Instance().getRemainingSQLOperation();
+ userData = (CommonPendingEvent*)DataControlAsyncCallbackManagerSingleton::Instance().getRemainingSQLOperation();
if (userData)
{
}
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<EventUpdate>::ManualAnswer(event);
+ CommonPendingEvent* userData = NULL;
+
try {
- CommonPendingEvent* userData = (CommonPendingEvent*)DataControlAsyncCallbackManagerSingleton::Instance().getRemainingSQLOperation();
+ userData = (CommonPendingEvent*)DataControlAsyncCallbackManagerSingleton::Instance().getRemainingSQLOperation();
if (userData)
{
}
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());
+ }
}
}
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]);
}
std::string getProviderPkgId(const std::string& appId);
std::string getCurrentApplicationId();
void addArrayToBundle(bundle* passData, std::vector<std::string>& array);
+ void handleCommonErrorEvent(void* userData, unsigned int code, std::string msg);
+
std::string convertIntToString(unsigned int data);
static std::vector<unsigned int> m_currentReqIds;
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;
{
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
{
if ( m_opRequests.end() != it)
{
- LoggerD("set Message ");
+ LoggerD("set event ");
if (event)
{
LoggerD("vaild event ");
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;
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 ");
}
EventSEChannelTransmitPtr event(new EventSEChannelTransmit(convert.toVectorOfUChars(arguments[0])));
event->setPrivateData( DPL::StaticPointerCast<IEventPrivateData>(callbackManager) );
event->setForAsynchronousCall(&SEResponseDispatcher::getInstance());
-
+ callbackManager->setObject(thisObject);
seChannel->transmit(event);
SEAsyncCallbackManagerSingleton::Instance().registerCallbackManager(callbackManager, privateObject->getContext());
EventSEOpenSessionPtr event(new EventSEOpenSession());
event->setPrivateData( DPL::StaticPointerCast<IEventPrivateData>(callbackManager) );
event->setForAsynchronousCall(&SEResponseDispatcher::getInstance());
-
+ callbackManager->setObject(thisObject);
seReader->openSession(event);
SEAsyncCallbackManagerSingleton::Instance().registerCallbackManager(callbackManager, privateObject->getContext());
JSCallbackManagerPtr callbackManager = JSCallbackManager::createObject(privateObject->getContext(), onSuccessForCbm, onErrorForCbm, true, true);
Try {
EventListSEsPtr event(new EventListSEs());
- event->setPrivateData( DPL::StaticPointerCast<IEventPrivateData>(callbackManager) );
+ event->setPrivateData( DPL::StaticPointerCast<IEventPrivateData>(callbackManager));
event->setForAsynchronousCall(&SEResponseDispatcher::getInstance());
-
+ callbackManager->setObject(thisObject);
seService->getReaders(event);
SEAsyncCallbackManagerSingleton::Instance().registerCallbackManager(callbackManager, privateObject->getContext());
EventSEOpenChannelPtr event(new EventSEOpenChannel(aid, true));
event->setPrivateData( DPL::StaticPointerCast<IEventPrivateData>(callbackManager) );
event->setForAsynchronousCall(&SEResponseDispatcher::getInstance());
-
+ callbackManager->setObject(thisObject);
seSession->openChannel(event);
SEAsyncCallbackManagerSingleton::Instance().registerCallbackManager(callbackManager, privateObject->getContext());
EventSEOpenChannelPtr event(new EventSEOpenChannel(aid, false));
event->setPrivateData( DPL::StaticPointerCast<IEventPrivateData>(callbackManager) );
event->setForAsynchronousCall(&SEResponseDispatcher::getInstance());
-
+ callbackManager->setObject(thisObject);
seSession->openChannel(event);
SEAsyncCallbackManagerSingleton::Instance().registerCallbackManager(callbackManager, privateObject->getContext());
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';
return JSValueMakeUndefined(context);
}
- deviceCapabilitiesInfo->platformCoreCpuArch = platformCoreFpuArch;
+ deviceCapabilitiesInfo->platformCoreFpuArch = platformCoreFpuArch;
free(platformCoreFpuArch);
return convert.toJSValueRef(deviceCapabilitiesInfo->platformCoreFpuArch);
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 << \r" mnc : " << imsi.szMnc << " msin : " << imsi.szMsin);
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<EventGetSysteminfo>::ManualAnswer(event);
}
- LoggerD("test");
} else {
LoggerE("get fail sim state");
}
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;
};
*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)
{
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;
}
catch(BasePlatformException &e)
{
- return JSWebAPIErrorFactory::postException(context, exception, e);
+ LoggerW("Failed to convert 1st parameter to string. Using default value.");
+ attributeName = "";
}
try
}
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);
AttributeFilterPtr attributeFilter(new AttributeFilter(attributeName, matchFlag, matchValue));
- JSObjectRef jsobject;
+ JSObjectRef jsobject = NULL;
Try
{
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;
}
}
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);
AttributeRangeFilterPtr attributeRangeFilter(new AttributeRangeFilter(attributeName, initialValue, endValue));
- JSObjectRef jsobject;
+ JSObjectRef jsobject = NULL;
Try
{
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;
}
}
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
}
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
{
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;
}
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
{
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;
}
}
catch(BasePlatformException &e)
{
- return JSWebAPIErrorFactory::postException(context, exception, e);
+ LoggerW("Failed to convert 1st parameter to string. Using default value.");
+ attributeName = "";
}
try
}
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
{
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;
}
* @brief
*/
-#include <cassert>
#include <vector>
#include <CommonsJavaScript/PrivateObject.h>
#include <CommonsJavaScript/Converter.h>
// limitations under the License.
//
-#include <SecurityExceptions.h>
-#include <JSUtil.h>
-#include <JSWebAPIError.h>
#include <ArgumentValidator.h>
#include <GlobalContextManager.h>
+#include <JSUtil.h>
+#include <JSWebAPIError.h>
+#include <Logger.h>
#include <MultiCallbackUserData.h>
#include <PlatformException.h>
-#include <Logger.h>
+#include <SecurityExceptions.h>
#include "plugin_config.h"
-
#include "JSWebSettingManager.h"
using namespace WrtDeviceApis::Commons;
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<void*>(priv))) {
- delete priv;
- }
+ SLoggerI("JSWebSettingManager::initialize called...");
+ WebSettingManager *priv = WebSettingManager::getInstance();
+ JSObjectSetPrivate(object, static_cast<void*>(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<WebSettingManager*>(JSObjectGetPrivate(object));
if (priv) {
JSObjectSetPrivate(object, NULL);
- delete priv;
}
}
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);
}
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);
namespace DeviceAPI {
namespace WebSetting {
+std::list<Common::MultiCallbackUserData *> WebSettingManager::mUserAgentCallbacks;
+std::list<Common::MultiCallbackUserData *> 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<WebSettingManager*>(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<MultiCallbackUserData *>(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<WebSettingManager*>(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<MultiCallbackUserData *>(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
+}
}
#define __TIZEN_WEB_SETTING_MANAGER_H__
#include <MultiCallbackUserData.h>
-
#include "WebSettingTypes.h"
+#include <list>
using namespace DeviceAPI::Common;
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<Common::MultiCallbackUserData *> mUserAgentCallbacks;
+ static std::list<Common::MultiCallbackUserData *> 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