m_addressBooks(new AddressBookArray()),
m_defaultAddressBookIndex(-1)
{
- //when it is first instance then open connection to database
- int ret = contacts_svc_connect();
- if (ret != CTS_SUCCESS)
- {
- //error during opening contacts database
- LogError("Error occurred during opening contacts database. (ret:" << ret << ")");
- m_opened = false;
-
- return;
+ if (!m_opened) {
+ init();
}
-
- //contacts-service has properly connected.
- LogDebug("Contact db has properly opened.");
- m_opened = true;
-
- loadAddressBooks();
}
ContactsSvcWrapper::~ContactsSvcWrapper()
void ContactsSvcWrapper::init()
{
+ int ret = contacts_svc_connect();
+ if (ret != CTS_SUCCESS)
+ {
+ //error during opening contacts database
+ LogError("Error occurred during opening contacts database. (ret:" << ret << ")");
+ m_opened = false;
+
+ return;
+ }
+
+ //contacts-service has properly connected.
+ LogDebug("Contact db has properly opened.");
+ m_opened = true;
+
+ loadAddressBooks();
}
{
if(!m_opened)
{
- //when database is not opened then set result as failed
- LogError("Contact db is not open.");
- ThrowMsg(PlatformException, "Contact DB is not open.");
+ init();
+
+ if(!m_opened) {
+ //when database is not opened then set result as failed
+ LogError("Contact db is not open.");
+ ThrowMsg(PlatformException, "Contact DB is not open.");
+ }
}
if(m_idMap.find(id) == m_idMap.end())
return m_addressBooks->at(index);
}
-AddressBookPtr ContactsSvcWrapper::getDefaultAddressBook() const
+AddressBookPtr ContactsSvcWrapper::getDefaultAddressBook()
{
if(!m_opened)
{
- //when database is not opened then set result as failed
- LogError("Contact db is not open.");
- ThrowMsg(PlatformException, "Contact DB is not open.");
+ init();
+
+ if(!m_opened) {
+ //when database is not opened then set result as failed
+ LogError("Contact db is not open.");
+ ThrowMsg(PlatformException, "Contact DB is not open.");
+ }
}
if(m_defaultAddressBookIndex == -1 || m_addressBooks->size() == 0)
return m_addressBooks->at(m_defaultAddressBookIndex);
}
-AddressBookArrayPtr ContactsSvcWrapper::getAddressBooks() const
+AddressBookArrayPtr ContactsSvcWrapper::getAddressBooks()
{
if(!m_opened)
{
- //when database is not opened then set result as failed
- LogError("Contact db is not open.");
- ThrowMsg(PlatformException, "Contact DB is not open.");
+ init();
+
+ if(!m_opened) {
+ //when database is not opened then set result as failed
+ LogError("Contact db is not open.");
+ ThrowMsg(PlatformException, "Contact DB is not open.");
+ }
}
AddressBookArrayPtr newArray(new AddressBookArray());
}
if (system_info_get_value_string(SYSTEM_INFO_KEY_KEYBOARD_TYPE, &inputKeyboard) == SYSTEM_INFO_ERROR_NONE) {
- LogDebug("inputKeyboard : " << inputKeyboard);
- deviceCapabilities->inputKeyboard = inputKeyboard;
+ if (inputKeyboard != NULL) {
+ LogDebug("inputKeyboard : " << inputKeyboard);
+ deviceCapabilities->inputKeyboard = inputKeyboard;
+ free(inputKeyboard);
+ }
}
if (system_info_get_value_bool(SYSTEM_INFO_KEY_WIFI_SUPPORTED, &wifi) == SYSTEM_INFO_ERROR_NONE) {
}
if (system_info_get_value_string(SYSTEM_INFO_KEY_OPENGLES_VERSION, &openglesVersion) == SYSTEM_INFO_ERROR_NONE) {
- LogDebug("openglesVersion : " << openglesVersion);
- if (strcmp(openglesVersion, "1.0") == 0) {
- deviceCapabilities->openglesVersion1_1 = true;
- deviceCapabilities->openglesVersion2_0 = false;
- } else if (strcmp(openglesVersion, "2.0") == 0) {
- deviceCapabilities->openglesVersion1_1 = false;
- deviceCapabilities->openglesVersion2_0 = true;
- } else if (strcmp(openglesVersion, "1.0/2.0") == 0) {
- deviceCapabilities->openglesVersion1_1 = true;
- deviceCapabilities->openglesVersion2_0 = true;
+ if (openglesVersion!= NULL) {
+ LogDebug("openglesVersion : " << openglesVersion);
+ if (strcmp(openglesVersion, "1.0") == 0) {
+ deviceCapabilities->openglesVersion1_1 = true;
+ deviceCapabilities->openglesVersion2_0 = false;
+ } else if (strcmp(openglesVersion, "2.0") == 0) {
+ deviceCapabilities->openglesVersion1_1 = false;
+ deviceCapabilities->openglesVersion2_0 = true;
+ } else if (strcmp(openglesVersion, "1.0/2.0") == 0) {
+ deviceCapabilities->openglesVersion1_1 = true;
+ deviceCapabilities->openglesVersion2_0 = true;
+ }
+ free(openglesVersion);
}
}
}
if (system_info_get_value_string(SYSTEM_INFO_KEY_TIZEN_VERSION_NAME, &platformVersion) == SYSTEM_INFO_ERROR_NONE) {
- LogDebug("platformVersion : " << platformVersion);
- deviceCapabilities->platformVersion = platformVersion;
+ if (platformVersion) {
+ LogDebug("platformVersion : " << platformVersion);
+ deviceCapabilities->platformVersion = platformVersion;
+ free(platformVersion);
+ }
}
if (system_info_get_value_string(SYSTEM_INFO_KEY_PLATFORM_NAME, &platformName) == SYSTEM_INFO_ERROR_NONE) {
- LogDebug("platformName : " << platformName);
- deviceCapabilities->platformName = platformName;
+ if (platformName) {
+ LogDebug("platformName : " << platformName);
+ deviceCapabilities->platformName = platformName;
+ free(platformName);
+ }
}
if (system_info_get_value_bool(SYSTEM_INFO_KEY_FRONT_CAMERA_SUPPORTED, &cameraFront) == SYSTEM_INFO_ERROR_NONE) {
}
if (system_info_get_value_string(SYSTEM_INFO_KEY_CORE_CPU_ARCH, &platformCoreCpuArch) == SYSTEM_INFO_ERROR_NONE) {
- LogDebug("platformCoreCpuArch : " << platformCoreCpuArch);
- deviceCapabilities->platformCoreCpuArch = platformCoreCpuArch;
+ if (platformCoreCpuArch) {
+ LogDebug("platformCoreCpuArch : " << platformCoreCpuArch);
+ deviceCapabilities->platformCoreCpuArch = platformCoreCpuArch;
+ free(platformCoreCpuArch);
+ }
}
if (system_info_get_value_string(SYSTEM_INFO_KEY_CORE_FPU_ARCH, &platformCoreFpuArch) == SYSTEM_INFO_ERROR_NONE) {
- LogDebug("platformCoreFpuArch : " << platformCoreFpuArch);
- deviceCapabilities->platformCoreFpuArch = platformCoreFpuArch;
+ if (platformCoreFpuArch) {
+ LogDebug("platformCoreFpuArch : " << platformCoreFpuArch);
+ deviceCapabilities->platformCoreFpuArch = platformCoreFpuArch;
+ free(platformCoreFpuArch);
+ }
}
if (system_info_get_value_bool(SYSTEM_INFO_KEY_SIP_VOIP_SUPPORTED, &sipVoip) == SYSTEM_INFO_ERROR_NONE) {
}
if (system_info_get_value_string(SYSTEM_INFO_KEY_DEVICE_UUID, &duid) == SYSTEM_INFO_ERROR_NONE) {
- LogDebug("duid : " << duid);
- deviceCapabilities->duid = duid;
+ if (duid) {
+ LogDebug("duid : " << duid);
+ deviceCapabilities->duid = duid;
+ free(duid);
+ }
}
if (system_info_get_value_bool(SYSTEM_INFO_KEY_SPEECH_RECOGNITION_SUPPORTED, &speechRecognition) == SYSTEM_INFO_ERROR_NONE) {